The parser instance takes a String and callback and will return an expression when there's a match.
compiler.parser.plugin("var rewire", function (expr) {
//if you original module has 'var rewire'
//you now have a handle on the expresssion object
return true;
});
program(ast)
bailingGeneral purpose plugin interface for the AST of a code fragment.
statement(statement: Statement)
bailingGeneral purpose plugin interface for the statements of the code fragment.
call <identifier>(expr: Expression)
bailingabc(1)
=> call abc
a.b.c(1)
=> call a.b.c
expression <identifier>(expr: Expression)
bailingabc
=> expression abc
a.b.c
=> expression a.b.c
expression ?:(expr: Expression)
bailing(abc ? 1 : 2)
=> expression ?!
Return a boolean value to omit parsing of the wrong path.
typeof <identifier>(expr: Expression)
bailingtypeof a.b.c
=> typeof a.b.c
statement if(statement: Statement)
bailingif(abc) {}
=> statement if
Return a boolean value to omit parsing of the wrong path.
label <labelname>(statement: Statement)
bailingxyz: abc
=> label xyz
var <name>(statement: Statement)
bailingvar abc, def
=> var abc
+ var def
Return false
to not add the variable to the known definitions.
evaluate <expression type>(expr: Expression)
bailingEvaluate an expression.
evaluate typeof <identifier>(expr: Expression)
bailingEvaluate the type of an identifier.
evaluate Identifier <identifier>(expr: Expression)
bailingEvaluate a identifier that is a free var.
evaluate defined Identifier <identifier>(expr: Expression)
bailingEvaluate a identifier that is a defined var.
evaluate CallExpression .<property>(expr: Expression)
bailingEvaluate a call to a member function of a successfully evaluated expression.