I'd like to find a tree parser generator to help me transform ASTs for a compiler written in C++.
After some quick research I found out about ANTLR (which can be targeted to work with C but not C++). I also found a website that warns against using ANTLR with C++: http://www.bearcave.com/software/antlr/antlr_treeparse.html. The article...
I have an ANTLR grammar and am defining a function in my language that allows an optional parameter. How can I check whether the optional parameter is passed in or not within the code generation block?
I'm basically looking for the syntax to do something like this hypothetical tree grammar statement:
myFunc returns [int retval] : 'myFu...
I'm a total lexer and parser newbie, so please have some patience. Eventually I want to be able to express LDAP style Query strings, e.g. '(foo=bar)', '(!foo=bar)', '(&(foo=bar)(!zip=zap))' and have a tree in the end which I could use to create the actual database query (or whatever)
So I thought to start with the simplest form, to pars...
Out of curiosity, I wonder what can people do with parsers, how they are applied, and what do people usually create with it?
I know it's widely used in programming language industry, however I think this is just a tiny portion of it, right?
...
What's the difference between defining a token in the tokens block and defining a token as a lexer index?
...
I am attempting to parse (in Java) Wikimedia markup as found on Wikipedia. There are a number of existing packages out there for this task, but I have not found any to fit my needs particularly well. The best package I have worked with is the Mathclipse Bliki parser, which does a decent job on most pages.
This parser is incomplete, how...
Hello
I am about to start a new personal project. It aims to be a pretty big one so I thought it would be a good idea to keep some sort of CVS. I have also read lot of interesting stuff about unit testing and I would like to include some system that automatically builds the project and runs a series of test after each check in.
The cha...
Hello, I have the following Antlr grammar:
grammar MyGrammar;
doc : intro planet;
intro : 'hi';
planet : 'world';
MLCOMMENT
: '/*' ( options {greedy=false;} : . )* '*/' { $channel = HIDDEN; };
WHITESPACE : (
(' ' | '\t' | '\f')+
|
// handle newlines
( '\r\n' // DOS/Windows
| '\r' // Macintosh
| '\...
I'm using ANTLR 3 to create an AST. I want to have two AST analysers, one to use in production code and one to use in the Eclipse plugin we already have. However, the plugin doesn't require all information in the tree. What I'm looking for is a way to parse the tree without specifying all branches in the grammar. Is there a way to do so?...
G'day!
How can I construct a simple ANTLR grammar handling multi-line expressions without the need for either semicolons or backslashes?
I'm trying to write a simple DSLs for expressions:
# sh style comments
ThisValue = 1
ThatValue = ThisValue * 2
ThisOtherValue = (1 + 2 + ThisValue * ThatValue)
YetAnotherValue = MAX(ThisOtherValue, ...
I'm looking to create my own custom domain specific language that outputs HTML.
Basically, I want to be able to create quizzes using my own markup, but have that compiled / generated into HTML. For example:
> What is your favorite color?
* Blue
* Green
* Red
should output
<form action="" method="post">
<ul>
<li>What is your favori...
I need to parse a boolean search string of keywords and operators into a SQL query to be executed from C# code. I think something like ANTLR is what I need for this task, but I'm not sure how to do it.
Are there any good tutorials on how to do this? Or maybe I need a different tool?
An example of what I mean is below. The only operator...
Hello,
I have a simple rule in ANTLR:
title returns [ElementVector<Element> v]
@init{
$v = new ElementVector<Element>() ;
}
: '[]'
| '[' title_args {$v.add($title_args.ele);} (',' title_args {$v = $title_args.ele ;})* ']'
;
with title_args being:
title_args returns [Element ele]
: author {$ele = new Element(...
I am working on a Reverse Engineering school project, which requires to translate manipulate AST of compiled C# project.
I have seen the post on "Translate C# code into AST?" in this website, but it doesn't look like the one I am looking for.
According to what I knew, currently C# doesn't provide a library class that does sth like that f...
I'm using ANTLRWorks, and have specified my java package using the @header action:
@header {package com.xxx.xxx.xxx.compiler}
However, when I generate the java code, it is generated to the root src directory rather than src/com/xxx/xxx/xxx/compiler. Consequently, it does not compile cleanly.
How do I specify the correct directory to ...
Is there a good parser generator (think lex/yacc or antlr) for .NET? Any that have a license that would not scare lawyers? Lot’s of LGPL but I am working on embedded components and some organizations are not comfortable with me taking an LGPL dependency.
I've heard that Oslo may provide this functionality but I'm not sure if it's a bui...
I'm trying to parse an expression like a IN [3 .. 5[, where the direction of the angle brackets determine whether the interval is inclusive or exclusive. I want this to be rewritten to an AST like
NODE-TYPE
|
+------------+-----------+
| | |
variable lower-bound upper-bound
...
Hi,
// Create a scanner that reads from the input stream passed to us
CSLexer lexer = new CSLexer(new ANTLRFileStream(f));
tokens.TokenSource = lexer;
// Create a parser that reads from the scanner
CSParser parser = new CSParser(tokens);
// start parsing at the compilationUnit rule
CSParser.compilation_unit_return x = parser.compilat...
I'm trying to use ANTLR to create a simple math parser targetting AS3 (Flash). I am using the latest version of AntlrWorks (1.2.3) on a Mac and have downloaded the runtime SWC from http://antlr.org/download/ActionScript/antlr3.swc.
The generated code looks fine, but seems to be incompatible with the runtime. There are many compile-time ...
I'm trying to parse CSS, or at least the basics, using ANTLR. I'm running into a few problems with my lexer rules though. The problem lies in the ambiguity between an ID selectors and hexadecimal color values. Using a simplified grammar for clarity, consider the following input:
#bbb {
color: #fff;
}
and the following parser rules:
...