Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js SyntaxError:意外标识符';布尔值';在ANTLR4 JavaScript Lexer中_Javascript_Node.js_Antlr4_Lexical Analysis_Strong Typing - Fatal编程技术网

Node.js SyntaxError:意外标识符';布尔值';在ANTLR4 JavaScript Lexer中

Node.js SyntaxError:意外标识符';布尔值';在ANTLR4 JavaScript Lexer中,javascript,node.js,antlr4,lexical-analysis,strong-typing,Javascript,Node.js,Antlr4,Lexical Analysis,Strong Typing,Node.js版本: jj5@orac:~/test/antlr4-js$ node --version v5.10.1 Java版本: jj5@orac:~/test/antlr4-js$ java -version java version "1.7.0_91" OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-1~deb8u1) OpenJDK 64-Bit Server VM (build 24.91-b01, mixed

Node.js版本:

jj5@orac:~/test/antlr4-js$ node --version
v5.10.1
Java版本:

jj5@orac:~/test/antlr4-js$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
ANTLR4版本:

jj5@orac:~/test/antlr4-js$ java -jar ./antlr-4.5.3-complete.jar | head -n 1
ANTLR Parser Generator  Version 4.5.3
我的测试脚本:

jj5@orac:~/test/antlr4-js$ cat run.sh 
#!/bin/bash
cd "`dirname $0`"
rm ECMAScript????* 2>/dev/null
export CLASSPATH=".:`pwd`/antlr-4.5.3-complete.jar"
java -jar ./antlr-4.5.3-complete.jar -Dlanguage=JavaScript -visitor ECMAScript.g4
node antlr4/run.js
错误发生在node.js运行的最后一行
节点antlr4/run.js


问题是因为我使用的ECMAScript.g4语法是为在Java中使用而设计的,而不是JavaScript。我创建了一个支持JavaScript的新文件,您可以获得详细信息

jj5@orac:~/test/antlr4-js$ ./run.sh
[irrelevant warnings elided]
/home/jj5/repo/svn/pcrepo/jj5-test/antlr4-js/ECMAScriptLexer.js:881
    private boolean strictMode = true;
            ^^^^^^^

SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/home/jj5/repo/svn/pcrepo/jj5-test/antlr4-js/antlr4/run.js:2:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
cd /tmp
svn co https://www.progclub.org/svn/pcrepo/jj5-test/trunk/antlr4-js/
antlr4-js/run.sh