Questions tagged [antlr4cs]
39 questions
0
votes
0 answers
Using ANTLR to walk a C# project
I have some ANTLR/C# classes capable of parsing a T-SQL stored procedure, walking its dependencies and identifying the required permissions to execute said stored procedure.
I now need to analyse a couple of relatively large C# .NET projects to…

Hugh Jones
- 2,706
- 19
- 30
0
votes
1 answer
ANTLR 4.5.3 C# lexer fails to initialize (ATN UUID error)
I'm trying to create my first antlr4 grammar for C# and I'm getting the following exception:
System.NotSupportedException: Could not deserialize ATN with UUID
aadb8d7e-aeef-4415-ad2b-8204d6cf042e (expected
ab35191a-1603-487e-b75a-479b831eaf6d…

Jovan MSFT
- 13,232
- 4
- 40
- 55
0
votes
1 answer
antlr grammar avoiding angle brackets
In this question I asked about extracting tags from arbitrary text. The solution provided worked well, but there's one edge case I'd like to handle. To recap, I'm parsing arbitrary user-entered text and would like to have any occurrence of < or > to…

Nick B.
- 79
- 6
0
votes
0 answers
ANTLR won't backtrack on .net?
I have this grammar:
grammar PrimeGrammar;
options
{
backtrack=true;
language = CSharp3;
memoize=true;
}
@parser::header
{
using System;
}
@parser::members
{
public int[] ObjInput = new int[]{1,2,3,4,5,6,7,8,9,10,11,12,13};
…

eocron
- 6,885
- 1
- 21
- 50
0
votes
1 answer
Antlr4: Generating a Lisp s-expression style output from an expression
Referring to this link. It shows how to create a lisp style s-expression
from any infix expression on Antlr3.
I am using Antlr4 and it doesn't seem to work on it.
Can someone please suggest me some way to achieve it ?
2x+3x^5 to (+ (* 2 x) (* 3 (^ x…

Pankaj Sejwal
- 1,605
- 1
- 18
- 27
0
votes
1 answer
ANTLR4 in C# catches only one token
g4 file:
grammar TestFlow;
options
{
language=CSharp4;
output=AST;
}
/*
* Parser Rules
*/
compileUnit : LC | BC ;
/*
* Lexer Rules
*/
BC : '/*' .*? '*/' ;
LC : '//' .*? [\r\n] ;
Code:
var input = " /*aaa*/ /// \n ";
var…

Tar
- 8,529
- 9
- 56
- 127
-1
votes
2 answers
What's the best way to translate ANTLR errors sentences from english to another language?
The application I'm building targets portuguese speaking users. The users can input a sentence which will be interpreted by ANTLR. To provide the users the best feedback from their input I will need to have errors displayed in portuguese.
I didn't…

Jean Carlos Sanson
- 39
- 5
-1
votes
1 answer
Token does not recognize '&' and single quote
I was trying to match everything between parentheses. I met an error that it won't recognize '&' and '''. However, in IntelliJ antlr preview, it works fine. Please help me with the error. Thank you so much.
line 1:0 token recognition error at:…

Yuqing Fan
- 1
- 1
-1
votes
1 answer
Problems matching text and containing syntax elements
I've written a small portion of a combined ANTLR4 grammar:
grammar TestCombined;
NL
: [\r\n]
;
SUBHEADLINE
: '##' .*? '##'
;
HEADLINE
: '#' .*? '#'
;
LEAD
: '###' .*? '###'
;
SUBHEADING
: '####' .*? '####'
…

Fabian Deitelhoff
- 712
- 1
- 7
- 23