Methods
evaluate(expr, scope)
evaluate the given expression on the given enviroment/scope
and return his value
Parameters:
Name | Type | Description |
---|---|---|
expr |
Object | Abstract Syntax Tree to evaluate |
scope |
Object | Actual enviroment |
Returns:
The value of the expression
exportToFile(ast, fileName)
export the given AST tree on the given file as a .evm file
.evm format is JSON
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | an AST tree of an EGG program |
fileName |
String | String that contains the file name to save the generated AST tree |
nextToken()
extract the new token, assigned it to lookahead variable
and return it
Returns:
the new lookahead value
parse(eggProgram) → {Object}
Parse the given eggProgram and return an object that represents
the AST tree
Parameters:
Name | Type | Description |
---|---|---|
eggProgram |
String | A string that contains the egg program |
Returns:
ASTtree
- Type
- Object
parseApply(AbstractSyntaxTree)
This function is called when the parsing reach an apply node
apply nodes can have arguments, these nodes are words
parseApply can parse words nodes, this nodes can have other childs
Parameters:
Name | Type | Description |
---|---|---|
AbstractSyntaxTree |
Array.<Object> |
parseExpression()
all on egg language are expression, parse expresion parse it.
It can call parseApply if a word node is reached.
ParseExpression can only parse literal nodes, such as string or numbers.
These nodes are leaf nodes
Returns:
AST, it can be a fragment of the complete one
parseFile(fileRoute) → {Object}
Read the given source file and returns the result of calling
the parse function
Parameters:
Name | Type | Description |
---|---|---|
fileRoute |
String | the source file route to parse |
Returns:
ASTtree
- Type
- Object
parseFromFileToFile(programFile, fileName)
reads a file that contains an egg program and export it
on the given .evm file
Parameters:
Name | Type | Description |
---|---|---|
programFile |
String | file that contains an egg program |
fileName |
String | name of the .evm file that will cointain the AST tree of the programFile program. .If it isnt defined, uses programFile value |
parseToFile(eggProgram, fileName)
export the AST tree of the given egg program on the given file
Parameters:
Name | Type | Description |
---|---|---|
eggProgram |
String | String that contains an eggprogram |
fileName |
String | String that contains the file name to save the generated AST tree |
run(program)
evaluate the egg program that is inside of the given string
Parameters:
Name | Type | Description |
---|---|---|
program |
String | String that contains an egg program |
Returns:
the last evaluated value of the egg program
runEVM(program)
evaluate an egg program, the program must be on evm (JSON) format
Parameters:
Name | Type | Description |
---|---|---|
program |
Object | compiled egg program (JSON) evm format |
Returns:
the last evaluated value of the egg program
runFromEVM(fileRoute)
read the file and run it with runEVM
Parameters:
Name | Type | Description |
---|---|---|
fileRoute |
String | to the file that contains a compiled egg program |
Returns:
the last evaluated value of the egg program
runFromFile(fileRoute)
open a .egg file and run it with the run function
Parameters:
Name | Type | Description |
---|---|---|
fileRoute |
String | to the .egg program |
Returns:
the last evaluated value of the egg program