尽管在文档和论坛中进行了长时间的搜索,但仍然无法在node.js中使用JSON格式获得正确的Jison 启动条件语法
> ** Documentation at http://zaach.github.io/jison/docs/ says:
> // Using the JSON format, start conditions are defined with an array
> // before the rule’s
> matcher {rules:[
> [['expect'], '[0-9]+"."[0-9]+', 'console.log( "found a float, = " + yytext );'
> ]]}
Run Code Online (Sandbox Code Playgroud)
但遗憾的是,没有人不提供完整的工作样本.
我试图排除两个标签之间的任何文本.在lex中会使用开始条件.Jison文档说它应该有效.然而,由于Jison错误消息不是非常直观,我很乐意找到一个可行的样本来继续前进.
有人会有解决方案吗?
var jison = require("jison").Parser;
grammar = {
"lex": {
"rules" : [ [" +" , "/* skip whitespace */"]
,[['mode1'], '[0-z]+\\b' , "return 'INFO';"]
,[['mode1'], '<\\/extensions>' , "this.popState(); return 'EXTEND';"]
,['<extensions>' , "this.begin('mode1'); …Run Code Online (Sandbox Code Playgroud)