ANTLRWorks 1.4.3 not displaying some characters such as vertical bar and open parenthesis

361 Views Asked by At

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!

1

There are 1 best solutions below

0
On

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.