Florian Rappl, iQuest
comparison_operator ::= '>' | '>=' | '<=' | '<' | '==' | '~=' | '&&' | '||'
arithmetic_operator ::= '+' | '-' | '*' | '/' | '\' | '%' | '^'
computing_operator ::= arithmetic_operator | pipe_operator
binary_operator ::= comparison_operator | computing_operator
binary ::= expr space* binary_operator space* expr
explicit_multiplication ::= expr space* '*' space* expr
implicit_multiplication ::= expr space* (identifier | literal)
multiplication ::= explicit_multiplication | implicit_multiplication
property ::= (identifier | string) space* colon space* expr space*
properties ::= property (comma space* property)* comma? space*
object ::= 'new' space* '{' space* properties? '}'
member ::= expr space* '.' space* identifier
block_stmt ::= '{' space* (stmt space*)* '}'
public interface IWalkable
{
void Accept(ITreeWalker visitor);
}
public interface ITreeWalker
{
void Visit(VarStatement statement);
void Visit(BlockStatement statement);
void Visit(BinaryExpression expression);
void Visit(FunctionExpression expression);
// ...
}
A virtual machine (VM) is an emulation of a computer system.
Dinstinguish between:
Process VMs are designed to execute computer programs in a platform-independent environment.
SWM> il("3 + 1 * 2 * 4 + 5")
const 1074266112
const 1072693248
const 1073741824
const 20234383
getc 2
const 1074790400
const 20234383
getc 2
const 20234383
getc 2
const 1075052544
const 20234383
getc 2
SWM> il("f = (x) => sin(x) * cos(x)")
newfunc start
arg 0 x
args args
gets x
gets sin
getc 1
gets x
gets cos
getc 1
const 20234383
getc 2
newfunc end
sets f