Questions tagged [antlr4cs]
39 questions
1
vote
1 answer
How to compile .g4 to .cs?
I reread all documentations but still didn't get what exactly do I need to do. Please explain step by step what do I need to do to set up work with Antlr in VS2019 (for C#) and how can I compile .g4 to .cs after. Do I need to install Antlr4 or…

anonymous
- 13
- 2
1
vote
1 answer
How to make antlr find invalid input throw exception
I have the following grammar:
grammar Expr;
expr : '-' expr # unaryOpExpr
| expr ('*'|'/'|'%') expr # mulDivModuloExpr
| expr ('+'|'-') expr #…

BeaNan
- 13
- 3
1
vote
1 answer
Antlr4: How to pass current token's value to lexer's predicate?
Is there a way to provide a lexer's predicate with the current token's value? for instance, in my lexer grammar FlowLexer, I dynamically load tokens:
Before I parse, I load the tokens dynamically:
var lexer = new FlowLexer(new…

Tar
- 8,529
- 9
- 56
- 127
1
vote
0 answers
Token collision (??) writing ANTLR4 grammar
I have what I thought a very simple grammar to write:
I want it to allow token called fact. These token can start with a letter and then allow a any kind of these: letter, digit, % or _
I want to concat two facts with a . but the the second fact…

fharreau
- 2,105
- 1
- 23
- 46
1
vote
0 answers
Visual Studio 2015 C# ANTLR
To convince my employers of the benefits of ANTLR and StringTemplate, I constructed a small demonstration first in Java. But Java is not one of our preferred languages, so I translated it to C#. Using VS2015 (Community Edition) and various…

user1964815
- 41
- 2
1
vote
1 answer
ANTLR4 Hexadecimal Parsing
I'm having issues debugging an ANTLR grammar I'm working on for Gameboy Assembly.
It seems to work normally, but for some reason it cannot handle 0x notation for Hexadecimal in certain edge cases.
If my input string is "JR 0x10" antlr fails with a…

plasmarobo
- 33
- 3
1
vote
0 answers
Antlr4: The type or namespace name 'XPathLexer' could not be found
I am trying to understand Antlr CS code on VS 2010 with Antlr4.Runtime.net40-client and Antlr4BuildTasks.net40 projects out of all .net framework versions.
The later is building fine but in case of first one I get The type or namespace name…

Pankaj Sejwal
- 1,605
- 1
- 18
- 27
1
vote
1 answer
Ignoring leading and tailing quotes in a string literal match
I want to match 'Foo' as Foo, not 'Foo'.
I have the following lexer rule:
STRING_LITERAL
: '\'' ( ~'\'' | '\'\'' )* '\''
;
But it seems to match the quotes.
My visitor looks like this:
public override IFilterExpression…

Kir
- 2,905
- 2
- 27
- 44
1
vote
1 answer
Java Grammar from Github for ANTLR4 and C# target
I have given up fixing C# grammar from version for ANTLR3.2 to version for ANTLR4, now I want to make Java Parser and Visitor.
The Java grammar for ANTLR4 downloaded from Github: https://github.com/antlr/grammars-v4/blob/master/java/Java.g4 is…

Petr Kloza
- 43
- 7
0
votes
1 answer
Antlr parser choose incorrect rule before reaching end of the line
I'm trying to write grammar to some kind of assembler language but not using mnemonics.
I have some kind of registers, lets say:
a, b, c, d
And one special register, which keeps address in memory:
&e
Now I want to allow to assign values to them:
a…

Sousuke
- 1,203
- 1
- 15
- 25
0
votes
0 answers
monaco web editor, language functionality don't working
I try to recreate an existing monaco+react+typescript project to my own goals. And it's not working, unfortunately. Language functionalities don't work. When I tried to throw alerts from the setupLanguage function it's working on getWorkerUrl…

Vladimir Kozhaev
- 77
- 8
0
votes
0 answers
Antlr: getting the class context from a CSharp source file
I'm trying to use Antlr to parse C# source files. Started with the grammar files that I got from https://github.com/antlr/grammars-v4/tree/master/csharp, and was able to get the auto-generate CS files. I'm trying to parse a simple class definition,…

samsu
- 63
- 8
0
votes
1 answer
Is there a way to verify an Antlr input file without running it?
I have the following code taking the input of my input file:
var inputStream = new AntlrInputStream(File.ReadAllText(fileName));
var lexer = new LegitusLexer(inputStream);
var commonTokenStream = new CommonTokenStream(lexer);
var parser = new…

Tylor Pater
- 95
- 1
- 7
0
votes
1 answer
ANTLR grammar issues with negative numbers
My ANTLR Grammar for simple expressions is as below:
This grammar works for most of the scenarios except when I try to use negative numbers.
abs(1.324) is valid
abs(-1.324) is being thrown as an error.
Or if the expression is just a negative…

Veryon890
- 330
- 1
- 4
- 15
0
votes
0 answers
Can't find corresponding options in right-click menu and File Properties dialog box in Visual studio 2019 after install AntlrVSIX
I install AntlrVSIX by nuget. I can find AntlrVSIX in “Extensions” menu. Highlight is also working properly in .g and.g4 file.
But I can't find “AntlrVSIX” in right-click menu and can't set the Build Action under the File Properties dialog box to…

typeryougishiki
- 5
- 2