kaby76 / Trash

Toolkit for grammars
MIT License
72 stars 5 forks source link

trparse -input isn't working #64

Open kaby76 opened 2 years ago

kaby76 commented 2 years ago

For this grammar:

grammar A;
all: e* EOF;
e: 
  e D e
  | e S  e
  | e M e
  | e P e
  | OP e CP
  | e (LT | LE | GT | GE | EQ | NE) e
  | e A e
  | e O e
  | NUMBER
  | STRING
  | IDENTIFIER
  ;    
OP: '(';
CP: ')';
D : '/';
S : '*';
M : '-';
P : '+';
LT: '<';
LE: '<=';
GT: '>';
GE: '>=';
EQ: '==';
NE: '!=';
A: '&&';
O: '||';
NUMBER: [0-9]+;
STRING: '"' ~'"'*? '"';
IDENTIFIER: [a-zA-Z]+;
WS: [ \t\n\r]+ -> channel(HIDDEN);

generate a CSharp target parser (trgen -t CSharp -s all) and test for input "84/2". Beyond the fact that the grammar doesn't define the multiplicative operators correctly (they are ordered in different alts!), "trparse -input '8\4/2' | trtree" is a truncated tree. If the input is in a file, "trparse file | trtree" works fine.

0.13.8.

kaby76 commented 2 years ago

Apparently CommandLineParser accepts "-input". It SHOULD NOT! In fact, the space between the "-i" and the value is optional https://github.com/commandlineparser/commandline/wiki/CommandLine-Grammar. IT SHOULD NOT!

I really, really hate having to write a command-line argument parser, but this is ridiculous and completely unacceptable.