Antlr4: C# 3 Errors in Lexer

Created on 2 Jan 2019  路  2Comments  路  Source: antlr/antlr4

  • [x] I am not submitting a question on how to use ANTLR
  • [x] I have done a search of the existing issues to make sure I'm not sending in a duplicate

    Expected Behaviour: ANTLR lexer file should transpile to C# source code without errors in C# source code.
    Actual Behaviour: ANTLR lexer file transpiles to C# source code, but there is 3 errors in C# source code file.

Code:

lexer grammar RedTeaLexer;

//=> Operators
LSHIFT           : '<<';
RSHIFT           : '>>';
TERNTHEN         : '~?';
TERNELSE         : '~:';
DOR              : '||';
DAND             : '&&';
INCR             : '++';
DECR             : '--';
MPOW             : '**';
FLDEV            : '//';
DEXCL            : '!!';
EQUAL            : '==';
DEQUAL           : '!=';
GEQUAL           : '>=';
LEQUAL           : '<=';
LAMBDA           : '=>';

DOT              : '.';
COMMA            : ',';
SEMICOLON        : ';';
COLON            : ':';
EQUALS           : '=';
ADD              : '+';
SUBTRACT         : '-';
MULTIPLY         : '*';
DEVIDE           : '/';
HASH             : '#';
PR               : '%';
ETA              : '@';
EXCL             : '!';
CARET            : '^';
AND              : '&';
OR               : '|';
GTHAN            : '>';
LTHAN            : '<';
QUES             : '?';
TIDLE            : '~';

LPR              : '(';
RPR              : ')';
LBRT             : '[';
RBRT             : ']';
LBRC             : '{';
RBRC             : '}';
//=> Types and Common stuff
fragment ESC     : '\\' .;
STRING           : '"' ( ESC | ~[\\"\r\n] )* '"' | '\'' ( ESC | ~[\\'\r\n] )* '\'';
SYMBOL           : '`' ( ESC | ~[\\`\r\n] )* '`';
NUMBER           : [0-9]+;
HEX              : '0x' [0-9]+;
//=> Keywords
BOOLEAN          : 'true' | 'false';
DECL             : 'var' | 'let' | 'const';
ACCESS           : 'public' | 'private' | 'protected';
BUILTIN          : 'Int' | 'String' | 'Symbol' | 'Boolean' | 'Float';
//=> Other
INDENTIFIER      : [A-Za-z_][A-Za-z0-9_]*;
NEWLINE          : '\r\n' | 'r' | '\n' ;
WHITESPACE       : [\t ] -> skip;
COMMENT          : '#-' .*;
BIGCOMS          : '#(';
BIGCOME          : ')#';

Errors in C# source code:

CS0115  'RedTeaLexer.ChannelNames': no suitable method found to override
Line: 106

CS1729  'Lexer' does not contain a constructor that takes 3 arguments
Line: 68

CS1729  'LexerATNSimulator' does not contain a constructor that takes 4 arguments
Line: 70

Most helpful comment

@CreatorVilius It appears that you are using the command line code generator from antlr.org with the Antlr4.Runtime NuGet package. This is not supported; you need to use a matching pair for generating and executing code:

All 2 comments

@CreatorVilius It appears that you are using the command line code generator from antlr.org with the Antlr4.Runtime NuGet package. This is not supported; you need to use a matching pair for generating and executing code:

Oh, thanks.

Was this page helpful?
0 / 5 - 0 ratings