Class: KipperCompiler
compiler.KipperCompiler
The main Compiler class that contains the functions for parsing and compiling a file.
This class will per default use a KipperLogger and log events while processing. To define custom behaviour initialise KipperLogger yourself and overwrite emitHandler.
Since
0.0.1
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new KipperCompiler(logger?
)
Parameters
Name | Type |
---|---|
logger |
KipperLogger |
Defined in
kipper/core/src/compiler/compiler.ts:37
Properties
_logger
• Private
Readonly
_logger: KipperLogger
The private field '_logger' that actually stores the variable data, which is returned inside the this.logger.
Defined in
kipper/core/src/compiler/compiler.ts:35
Accessors
internalFunctions
• Private
get
internalFunctions(): InternalFunction
[]
An array of all internal functions that are available to the compiler
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/compiler.ts:53
logger
• get
logger(): KipperLogger
Returns the initialised logger for this class
Returns
Defined in
kipper/core/src/compiler/compiler.ts:44
Methods
compile
▸ compile(stream
, compilerOptions
): Promise
<KipperCompileResult
>
Compiles a file and generates a KipperCompileResult instance representing the generated code.
This function is async to not render-block the browser and allow rendering to happen in-between the async processing.
Throws
If any syntactical, semantic or logical issues were encountered during the compilation.
Parameters
Name | Type | Description |
---|---|---|
stream |
string | KipperFileStream |
The input to compile, which may be either a String or KipperFileStream. |
compilerOptions |
CompileConfig |
Compilation Configuration, which defines how the compiler should handle the program and compilation. |
Returns
The created KipperCompileResult instance.
Defined in
kipper/core/src/compiler/compiler.ts:168
getProgramCtx
▸ getProgramCtx(parseData
, compilerOptions
): Promise
<KipperProgramContext
>
Creates a new KipperProgramContext based on the passed parseData and compilerOptions.
Since
0.10.0
Parameters
Name | Type | Description |
---|---|---|
parseData |
LexerParserData |
The parsing data of the file. |
compilerOptions |
EvaluatedCompileConfig | CompileConfig |
The compilation config. |
Returns
The newly created KipperProgramContext instance, which contains the metadata of the compiled program.
Defined in
kipper/core/src/compiler/compiler.ts:145
getTokensForChannel
▸ Private
getTokensForChannel(tokenStream
, channel
): Token
[]
Returns all tokens for a specific channel from the token stream.
Since
0.11.0
Parameters
Name | Type | Description |
---|---|---|
tokenStream |
CommonTokenStream |
The token stream to get the tokens from. |
channel |
number |
The channel to get the tokens from. |
Returns
Token
[]
Defined in
kipper/core/src/compiler/compiler.ts:83
handleStreamInput
▸ Private
handleStreamInput(stream
, name?
): Promise
<KipperFileStream
>
Handles the input for a file-based function of the KipperCompiler.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
stream |
string | KipperFileStream |
undefined |
The input, which may be either a String or KipperFileStream. |
name |
string |
"anonymous-script" |
The encoding to read the file with. |
Returns
Defined in
kipper/core/src/compiler/compiler.ts:62
parse
▸ parse(parseStream
): Promise
<LexerParserData
>
Parses a file and generates a parse tree using the Antlr4 KipperLexer and KipperParser.
Throws
KipperSyntaxError If a syntax exception was encountered while running.
Parameters
Name | Type | Description |
---|---|---|
parseStream |
KipperFileStream |
The KipperFileStream instance that contains the required file content. |
Returns
An object containing the parse data.
Defined in
kipper/core/src/compiler/compiler.ts:100
syntaxAnalyse
▸ syntaxAnalyse(stream
): Promise
<void
>
Analyses the syntax of the given file. Errors will be raised as an exception and warnings logged using the this.logger.
If this function executes without any errors, then the syntax check succeeded.
This function is async to not render-block the browser and allow rendering to happen in-between the async processing.
Throws
If a syntax exception was encountered while running.
Parameters
Name | Type | Description |
---|---|---|
stream |
string | KipperFileStream |
The input to analyse, which may be either a String or KipperFileStream. |
Returns
Promise
<void
>
Defined in
kipper/core/src/compiler/compiler.ts:248