Questions tagged [antlr4cs]

39 questions
7
votes
0 answers

Using ANTLR with Visual Studio 2022

I can't find any documentation that shows how to get ANTLR support in Visual Studio 2022. It seems like the ANTLR extension developers haven't kept up with the changes made to the Visual Studio API object model: ANTLR VSIX is only compatible with…
MikeB
  • 1,452
  • 14
  • 28
6
votes
1 answer

How to detect beginning of line, or: "The name 'getCharPositionInLine' does not exist in the current context"

I'm trying to create a Beginning-Of-Line token: lexer grammar ScriptLexer; BOL : {getCharPositionInLine() == 0;}; // Beginning Of Line token But the above emits the error The name 'getCharPositionInLine' does not exist in the current context As…
Tar
  • 8,529
  • 9
  • 56
  • 127
3
votes
2 answers

ANTLR4 - VisitChildren returns null, even when child returns some object

I've been trying to implement the Visitor Pattern to parse some specific SQL Statements into an internal object structure consisting of TableDefinition and ColumnDefinition objects. This is a small (stripped down) portion from the…
Adrian
  • 91
  • 5
3
votes
0 answers

Antlr 4 creating Java Heap Size Out Of Memory issue

I am trying to create ParseTree objects for a huge set of (really huge) java files using the Java7 grammar, but in the middle, getting an out of memory issue with GC overhead. I am cleaning up the ParseTree and Parser/Lexer after completing each…
3
votes
1 answer

Antlr4 recover from error and continue parsing until EOF

I am writing a C# grammar in Java using Antlr 4.5. When I am dealing with a C# source code having Preprocessor Directives. sample code using System; using System.Collections.Generic; using System.Linq; using System.Text; using…
2
votes
1 answer

Is there a way to extract tokens in order with ANTLR?

Hi I'm currently trying to extract all tokens from ANTLR in C#, i'm using Antlr4.CodeGenerator and Antlr4.Runtime packages. I want them structured in a way i can manipulate them, change their content and so on. I've tried using listeners and…
2
votes
1 answer

Antlr semantic predicate failed to find viable alternative

I can't get even simpler semantic predicates to work with Antlr 4.6.6 for .net framework 4.8 the grammar below can't find viable alternative for input "received:last week" . grammar test; // Parser rules parse : expr (expr)* EOF ; expr :…
ekalchev
  • 762
  • 7
  • 24
2
votes
1 answer

'no suitable method found to override' in ANTLR4 generated classes

I have defined a ANTLR4 grammar where the lexer and parser are in two different files. It's a XML look-a-like grammar. In my parser I want too define a expression which can re-use itself for calculation purposes (like '(1+1)*2'). parser grammar…
Maikel
  • 71
  • 7
2
votes
2 answers

Adding PreProcessing layer to ANTLR4 without removing offsets of tokens

I currently try to implement a PreProcessor into ANTLR4 for c# and got quite a lot of trouble finding any info about this. My digging through the GitHub sources of the C# project did not really have been successfull sadly ... My goal is to retain…
X39
  • 789
  • 6
  • 22
2
votes
2 answers

Using Antlr to parse formulas with multiple locales

I'm very new to Antlr, so forgive what may be a very easy question. I am creating a grammar which parses Excel-like formulas and it needs to support multiple locales based on the list separator (, for en-US) and decimal separator (. for en-US). I…
Walter Williams
  • 944
  • 3
  • 11
  • 25
2
votes
1 answer

How to modify or insert a ParserRuleContext as I am walking it with a BaseListener

I have the following code which extends ProcessBaseListener: var myProcessListener = new MyProcessListener(); walker = new ParseTreeWalker(); walker.Walk(myProcessListener , tree); I've overridden one method: public override void…
tmakaro
  • 33
  • 5
2
votes
1 answer

Can ANTLR lexers/parsers be used for VS syntax highlighting and Error List?

I'm happily developing a language in ANTLR 4.4 / ANTLR4CS, and I'd like to start integrating my language into an IDE. The natural place for me feels like integrating it into Visual Studio. It occurs to me that someone might have figured out a…
Steve Cooper
  • 20,542
  • 15
  • 71
  • 88
1
vote
1 answer

How do you insert extra validation logic into an ANTLR4 parser rule?

I have an ANTLR4 grammar that has a parser rule line as below: | expression operator='=' expression #AssignmentExpression This rule is part of a large compound rule for defining an expression. However, the reality is that only a subset of…
WiredWiz
  • 646
  • 8
  • 18
1
vote
1 answer

Im just starting with ANTLR and I cant decipher where Im messing up with mismatched input error

I've just started using antlr so Id really appreciate the help! Im just trying to make a variable declaration declaration rule but its not working! Ive put the files Im working with below, please lmk if you need anything else! INPUT CODE: var…
1
vote
2 answers

C# and ANTLR4: Handling "include" directives when parsing a file

I’m in a situation that, using ANTLR, I’m trying to parse input files that contains references to other files inside them, just like #include "[insert file name]" of C language. One suggested approach is: Parse the root file, saving said references…
Andreas M.
  • 182
  • 1
  • 10
1
2 3