ANTLRWorks 1.4.3 不显示某些字符,例如竖线和左括号
如果此问题已在本网站的其他地方提出并解决,请原谅我。当我在 ANTLRWorks 1.4.3 中输入示例语法时,编辑器不显示某些字符,例如竖线 ('|') 或左括号 '('。我注意到在本网站的某处 Maya Posch 提出了一个问题扩展 ASCII 字符没有得到正确处理,但我似乎遇到了不同的情况,当我输入教程中的示例语法时,我在编辑器屏幕中看不到这些字符,但是,编辑器窗格下方的语法图表似乎出现了。认识到的存在以下是语法(奇怪的是,当我复制并粘贴到此处时,它们显示如下!):
grammar Expr;
// START:stat
prog: stat+ ;
stat: expr NEWLINE
| ID '=' expr NEWLINE
| NEWLINE
;
// END:stat
// START:expr
expr: multExpr (('+'|'-') multExpr)*
;
multExpr
: atom ('*' atom)*
;
atom: INT
| ID
| '(' expr ')'
;
// END:expr
// START:tokens
ID : ('a'..'z'|'A'..'Z')+ ;
INT : '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS : (' '|'\t')+ {skip();} ;
// END:tokens
这是我在编辑器中看到的内容:
grammar Expr;
// START:stat
prog: stat+ ;
stat: expr NEWLINE
ID '=' expr NEWLINE
NEWLINE
;
// END:stat
// START:expr
expr: multExpr '+' '-') multExpr)*
;
multExpr
: atom '*' atom)*
;
atom: INT
ID
'(' expr ')'
;
// END:expr
// START:tokens
ID : 'a'..'z' 'A'..'Z')+ ;
INT : '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS : ' ' '\t')+ {skip);} ;
// END:tokens
代码看起来很混乱,因为竖线和左括号但是,当我将文本从编辑器复制到此帖子上的代码段时,这些丢失的字符确实会像我上面最初发布的那样显示出来,但是,文字左括号('(')却显示出来了。这可能是可见的。编辑器的配置问题?
当我生成代码时,一切正常。此外,语法图正确显示了规则。只是语法规则中丢失/不可见的字符令人不安。我在 MacBook Pro 上运行 ANTLRWorks。
编辑:按照巴特的建议,我尝试了不同的字体,那些不可见的字符确实显示在编辑器窗格中。我进入首选项页面,将字体更改为默认 Courier New 以外的其他字体。我的电脑是 MacBook Pro,因此这可能特定于 Mac 环境。希望这可以帮助遇到同样问题的其他人。谢谢,巴特!
Forgive me if this question has been asked and addressed elsewhere on this site. When I type in a sample grammar in ANTLRWorks 1.4.3, the editor does not display some characters such as the vertical bar ('|') or the open parenthesis '('. I noticed that somewhere in this site Maya Posch asked a question on extended ASCII characters not being handled properly but I seem to have a different situation. When I type in a sample grammar from the tutorial, I can't see those characters in the editor screen. However, the syntax chart below the editor pane seems to recognize the existence of those 'missing' characters. The following is the grammar (strangely, when I copy and paste here, they show up as in the following!):
grammar Expr;
// START:stat
prog: stat+ ;
stat: expr NEWLINE
| ID '=' expr NEWLINE
| NEWLINE
;
// END:stat
// START:expr
expr: multExpr (('+'|'-') multExpr)*
;
multExpr
: atom ('*' atom)*
;
atom: INT
| ID
| '(' expr ')'
;
// END:expr
// START:tokens
ID : ('a'..'z'|'A'..'Z')+ ;
INT : '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS : (' '|'\t')+ {skip();} ;
// END:tokens
Here's what I see in the editor:
grammar Expr;
// START:stat
prog: stat+ ;
stat: expr NEWLINE
ID '=' expr NEWLINE
NEWLINE
;
// END:stat
// START:expr
expr: multExpr '+' '-') multExpr)*
;
multExpr
: atom '*' atom)*
;
atom: INT
ID
'(' expr ')'
;
// END:expr
// START:tokens
ID : 'a'..'z' 'A'..'Z')+ ;
INT : '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS : ' ' '\t')+ {skip);} ;
// END:tokens
The code looks jumbled because the vertical bar and open parenthesis characters are not visible in the editor pane. But when I copy the text from the editor to a code segment on this posting, those missing characters do show up as I posted above originally. However, the literal open parenthesis ('(') does remain visible. Could this be a configuration issue for the editor?
When I generate the code, everything works just fine. Also, the syntax diagram correctly displays the rule. It's just the missing/invisible characters in the grammar rule that is troubling. I am running ANTLRWorks on a MacBook Pro.
Edit: As suggested by Bart, I tried a different font and those invisible characters do show in the editor pane. I went into the preferences page, and changed the font to something else other than the default Courier New. My computer is a MacBook Pro so this could be specific to the Mac environment. Hope this helps others experiencing the same problem. Thanks, Bart!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了这个问题,在配置菜单中更改 ANTLR-works 字体后,现在所有字符都显示正确。我已将字体更改为等宽 14 磅。
I have also suffered this problem and after change ANTLR-works font in configuration menu, now all characters show correctly. I have changed font to monospaced 14 points.