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); console.log('SelectElements', selectElements);
return ''; return '';
} }
visitProgram(ctx) { visitProgram(ctx) { // program 是根规则
return 'Return by program node' this.visitChildren(ctx);
return 'Return by program context'
} }
} }
const visitor = new MyVisitor(); const visitor = new MyVisitor();

View File

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