Questions tagged [tree-grammar]
18 questions
32
votes
5 answers
How to parse Markdown in PHP?
First, I know, there already is a Markdown parser for PHP.
I also took a look to this question but it doesn't answer to my question.
Obviously, even if the title mention PHP, if it's language agnostic, because I'd like to know what are the step I've…

Jérémy
- 379
- 1
- 3
- 7
7
votes
1 answer
Systematic way to generate ANTLR tree grammar?
I have a little bit large ANTLR parser grammar file and want to make a tree grammar for it. But, as far as I know this work of tree grammar generation can't be done automatically, i.e., I should generate it manually by copying parser grammar,…

David Johns
- 1,201
- 5
- 15
- 34
4
votes
1 answer
ANTLR's AST tree grammar + lists
I've have read a lot trying to find a way to cleanly consume lists in ANTLR's tree grammar. Here is what I have tried and their results (I really hope I'm missing something trivial)...
Using += Syntax
program returns [someInterface result]
:…

Andrew White
- 52,720
- 19
- 113
- 137
3
votes
1 answer
ANTLR 3.x - How to format rewrite rules
I'm finding myself challenged on how to properly format rewrite rules when certain conditions occur in the original rule.
What is the appropriate way to rewrite this:
unaryExpression: op=('!' | '-') t=term
-> ^(UNARY_EXPR $op $t)
Antlr doesn't…

Jesse Hallam
- 6,794
- 8
- 48
- 70
3
votes
2 answers
ANTLR - Writing a tree grammar for an AST
I have an AST outputted for some Lua code by my grammar file, which currently does parsing and lexing for me. I want to add a tree grammar to this, but since i'm using C# i'm not sure how to do it. What's the basic process for generating tree…

RCIX
- 38,647
- 50
- 150
- 207
2
votes
1 answer
ANTLR Parse Grammar -> Tree Grammar
Our last assignment for our compiler theory class has us creating a compiler for a small subset of Java (not MiniJava). Our prof gave us the option of using whatever tools we wish, and after a lot of poking around, I settled on ANTLR. I've managed…

Eric
- 601
- 7
- 22
1
vote
1 answer
Rascal: TrafoFields Syntax error: concrete syntax fragment
I'm trying to re-create Tijs' CurryOn16 example "TrafoFields" scraping the code from the video, but using the Java18.rsc grammar instead of his Java15.rsc. I've parsed the Example.java successfully in the repl, like he did in the video, yielding a…

ThomasH
- 22,276
- 13
- 61
- 62
1
vote
0 answers
ANTLR, lack of method in C# target
I generated the C# code from tree grammar using ANTLR and I cannot find the method downup(). Is the sequence of calls:
topdown();
bottomup();
equivalent to downup() method? Why the method does exist in Java but not in C#? And why do they (the…

Marc Andreson
- 3,405
- 5
- 35
- 51
1
vote
1 answer
Dependency parsing
I particularly like the transduce feature offered by agfl in their EP4IR
http://www.agfl.cs.ru.nl/EP4IR/english.html
The download page is here:
http://www.agfl.cs.ru.nl/download.html
Is there any way i can make use of this in a c# program? Do I…

C..
- 6,897
- 10
- 30
- 37
1
vote
1 answer
ANTLR - Linking nodes of an AST
I want to know how can I define, in a grammar file, that a Node of an AST has "two parents". If for example, the node 'D' of the first tree is also child of the node 'A', what syntax should I use so that node 'D' not appear repeated (I want…

user2144555
- 1,315
- 11
- 34
- 55
1
vote
1 answer
Regular Expressions - tree grammar Antlr Java
I'm trying to write a program in ANTLR (Java) concerning simplifying regular expression. I have already written some code (grammar file contents below)
grammar Regexp_v7;
options{
language = Java;
output = AST;
ASTLabelType =…

szefu
- 13
- 3
0
votes
1 answer
ANTLR's tree-grammar AST graphical view
Im currently building a Javascript compiler in ANTLR and JAVA.
I use ANTLR's tree-grammar for generating ASTs. (Still in doubt whether this is smarter than a heterogeneous approach with a manually defined Abstract class for generating nodes, but…

Sune1987
- 155
- 2
- 10
0
votes
1 answer
Weird "NoViableAltException" in Tree grammar with imaginary token
I can not understand a "NoViableAltException"exception when I compile my Tree grammar.
Here's a little piece of my grammar with the rule that gives me problems:
keyword_controls_sub
: expression (MB_COMA expression)* -> ^(MATCH_STATEMENT…

Patxi
- 43
- 7
0
votes
1 answer
Build POJO object from this Production Rule
I have rules of this format:
Condition -> Condition OPERATOR Condition | Condition
Condition -> attribute OPERATOR
value OPERATOR -> EQUALS | STARTS WITH | ENDS WITH | AND | OR | NOT EQUALS | CONTAINS
I need to create a JAVA POJO…
0
votes
1 answer
copy nodes of trees using ANTLR tree grammars
I need some guidance on trying to solve a problem I ran across using tree grammars. Basically, I want to be able to do is replace/copy statements around that may be found in the tree. It is probably best to explain through an example.
Here is a…

Andy M
- 119
- 9