docs: update visitor demo

This commit is contained in:
hayden 2023-12-20 11:12:18 +08:00
parent 24dee75dfe
commit f6bc7594e1
2 changed files with 6 additions and 4 deletions

View File

@ -180,8 +180,9 @@ class MyVisitor extends AbstractParseTreeVisitor<Result> implements MySqlParserV
console.log('SelectElements', selectElements);
return '';
}
visitProgram(ctx) {
return 'Return by program node'
visitProgram(ctx) { // program 是根规则
this.visitChildren(ctx);
return 'Return by program context'
}
}
const visitor = new MyVisitor();

View File

@ -187,8 +187,9 @@ class MyVisitor extends AbstractParseTreeVisitor<Result> implements MySqlParserV
console.log('SelectElements:', selectElements);
return '';
}
visitProgram(ctx) {
return 'Return by program node'
visitProgram(ctx) { // program is root rule
this.visitChildren(ctx);
return 'Return by program context'
}
}
const visitor = new MyVisitor();