Package org.ek9lang.compiler
Class CompilableSource
java.lang.Object
org.ek9lang.compiler.CompilableSource
- All Implemented Interfaces:
Serializable
,Source
,TokenConsumptionListener
public final class CompilableSource
extends Object
implements Source, Serializable, TokenConsumptionListener
Holds a reference to the name of the file being compiled a checksum of the
file and the date time last modified.
This is used to detect changes in source that needs to have a new parse tree
generated.
But also note it can be created with just an inputStream so the in memory ek9 source can also be supplied and parsed.
But also note it can be created with just an inputStream so the in memory ek9 source can also be supplied and parsed.
- See Also:
-
Constructor Summary
ConstructorDescriptionCompilableSource
(String filename) Create compilable source for a specific filename.CompilableSource
(String filename, InputStream inputStream) Create a compilable source with a name, but provide the inputStream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Provide access to the main compilation context.Access the error listener, only check after parsing.Used in debugging built-in sources.int
hashCode()
boolean
boolean
isDev()
boolean
isLib()
boolean
Checks if the file content have changed from when first calculated.nearestToken
(int line, int characterPosition) Get the nearest source token on a particular line and character position.parse()
Actually parse the source code.Sets up the compilable source to be parsed.prepareToParse
(InputStream inputStream) Prepare to parse but with a provided input stream of what to parse.void
Just updates the last modified and the check sum to current values.setDev
(boolean dev) void
Set this compilable source as a library.void
tokenConsumed
(org.antlr.v4.runtime.Token token) Informed when a token have been consumed out of the Lexer.toString()
-
Constructor Details
-
CompilableSource
Create compilable source for a specific filename. -
CompilableSource
Create a compilable source with a name, but provide the inputStream. This is useful for internal supplied sources.
-
-
Method Details
-
tokenConsumed
public void tokenConsumed(org.antlr.v4.runtime.Token token) Informed when a token have been consumed out of the Lexer.- Specified by:
tokenConsumed
in interfaceTokenConsumptionListener
-
nearestToken
Get the nearest source token on a particular line and character position. -
getCompilationUnitContext
Provide access to the main compilation context. This is only valid if a prepareToParse and parse has been run. -
hasNotBeenSuccessfullyParsed
public boolean hasNotBeenSuccessfullyParsed() -
isDev
public boolean isDev() -
setDev
-
isLib
public boolean isLib() -
getPackageModuleName
-
setLib
Set this compilable source as a library. -
isModified
public boolean isModified()Checks if the file content have changed from when first calculated.- Returns:
- true if modified, false if modified time and checksum are the same.
-
resetDetails
public void resetDetails()Just updates the last modified and the check sum to current values. -
hashCode
public int hashCode() -
equals
-
getSourceAsStringForDebugging
Used in debugging built-in sources. -
prepareToParse
Sets up the compilable source to be parsed. -
prepareToParse
Prepare to parse but with a provided input stream of what to parse. -
completeParsing
-
parse
Actually parse the source code. -
getErrorListener
Access the error listener, only check after parsing. -
toString
-
getFileName
- Specified by:
getFileName
in interfaceSource
-
getGeneralIdentifier
-