Add parser support for block params
This commit is contained in:
@@ -9,10 +9,11 @@ function LocationInfo(locInfo) {
|
||||
}
|
||||
|
||||
var AST = {
|
||||
ProgramNode: function(statements, strip, locInfo) {
|
||||
ProgramNode: function(statements, blockParams, strip, locInfo) {
|
||||
LocationInfo.call(this, locInfo);
|
||||
this.type = "program";
|
||||
this.statements = statements;
|
||||
this.blockParams = blockParams;
|
||||
this.strip = strip;
|
||||
},
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export function prepareRawBlock(openRawBlock, content, close, locInfo) {
|
||||
throw new Exception(openRawBlock.sexpr.id.original + " doesn't match " + close, errorNode);
|
||||
}
|
||||
|
||||
var program = new this.ProgramNode([content], {}, locInfo);
|
||||
var program = new this.ProgramNode([content], null, {}, locInfo);
|
||||
|
||||
return new this.BlockNode(openRawBlock.sexpr, program, undefined, undefined, locInfo);
|
||||
}
|
||||
@@ -40,6 +40,8 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
|
||||
throw new Exception(openBlock.sexpr.id.original + ' doesn\'t match ' + close.path.original, errorNode);
|
||||
}
|
||||
|
||||
program.blockParams = openBlock.blockParams;
|
||||
|
||||
// Safely handle a chained inverse that does not have a non-conditional inverse
|
||||
// (i.e. both inverseAndProgram AND close are undefined)
|
||||
if (!close) {
|
||||
|
||||
@@ -26,6 +26,15 @@ PrintVisitor.prototype.program = function(program) {
|
||||
statements = program.statements,
|
||||
i, l;
|
||||
|
||||
if (program.blockParams) {
|
||||
var blockParams = "BLOCK PARAMS: [";
|
||||
for(i=0, l=program.blockParams.length; i<l; i++) {
|
||||
blockParams += " " + program.blockParams[i];
|
||||
}
|
||||
blockParams += " ]";
|
||||
out += this.pad(blockParams);
|
||||
}
|
||||
|
||||
for(i=0, l=statements.length; i<l; i++) {
|
||||
out = out + this.accept(statements[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user