antlr

How do I put unicode characters in my Antlr grammar?

I'm trying to build a grammar with the following: NUMERIC: INTEGER | FLOAT | INFINITY | PI ... INFINITY: '∞' PI: 'π' But Antlr refuses to load the grammar. ...

Where do I get the Antlr Ant task?

I'm trying to call an Antlr task in my Ant build.xml as follows: <path id="classpath.build"> <fileset dir="${dir.lib.build}" includes="**/*.jar" /> </path> ... <target name="generate-lexer" depends="init"> <antlr target="${file.antlr.lexer}"> <classpath refid="classpath.build"/> </antlr> </target> But Ant can't find the ta...

Does anybody know how to correctly install ANTLR to work with .Net?

Can ANTLR output C# using StringTemplate or any text I want it to like Yacc/Bison or does it only output to java? From the examples I've looked at it appears to be a very java centric tool. ...

Antlr: Simplest way to recognize dates and numbers?

What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like: number: (MONTH|INT); It only gets more complex whe...

How do I find character positions in ANTLR 2?

I have a simple grammar, and have produced a pair of c# classes using antlr 2.7.7. When the parser finds an error with a token, it throws an exception; I want to find out how many characters into a parsed stream the token came. How do I do that? ...

Advantages of Antlr (versus say, lex/yacc/bison)

I've used lex and yacc (more usually bison) in the past for various projects, usually translators (such as a subset of EDIF streamed into an EDA app). Additionally, I've had to support code based on lex/yacc grammars dating back decades. So I know my way around the tools, though I'm no expert. I've seen positive comments about Antlr in ...

Can anyone help me convert this ANTLR 2.0 grammar file to ANTLR 3.0 syntax?

I've converted the 'easy' parts (fragment, @header and @member declerations etc.), but since I'm new to Antlr I have a really hard time converting the Tree statements etc. I use the following migration guide. The grammar file can be found here.... Below you can find some examples where I run into problems: For instance, I have prob...

ANTLR Tutorials

Are there any good tutorials for ANTLR, targeting v3.x? (The ANTLR website is not friendly to new users.) ...

Getting begin and end positions with AntLR

I'm currently using AntLR to parse some files with a proprietary language. I have a need of highlighting sections of it on an editor (think of highlighting a method in a Java class, for instance). Does anyone has a hint on how to get them? Say I have this code: function test(param1, param2) { } as function is a keyword, the first pos...

How to specify the exact number of occurance of a token in ANTLR?

I have to define the grammar of a file like the one shown below. //Sample file NameCount = 4 Name = a Name = b Name = c Name = d //End of file Now I am able to define tokens for NameCount and Name. But i have to define the file structure including the valid number of instances of token Name , which is the value after NameCount. I have ...

Compiling ANTLRWorks generated class files

I am using ANTLRWorks to create ANTLR grammars. I have a valid grammar and the parser and lexer source files are generated as well. I have also tried debugging the generated code and the output is as expected in the debugger output. But when I try to invoke the __Test__ class generated by the debugger nothing is coming up in the conso...

ANTLR v3 C# namespaces

Hopefully this is a really quick one ;) I have written a lexer / parser specification in ANTLR3, and am targeting the CSharp2 target. The generated code works correctly, but I can't get ANTLR to put the C# output into a namespace. The relevant section of the Grammar file is as follows: grammar MyGrammar; options { language = CSh...

What current tutorials exist for c/c++ for antrl 3.1?

I have written a parser in boost:spirit and now I wish to write the same stuff in antlr 3.1.1 to see if there are any performance gains or if it might be a better way to go about it as it also exports to many other languages besides c++ (The current 3.x branch actually does not export to c++). 3.1.1 is built using 2.7.x yet, it supports...

How do you specify the access specifier on an ANTLR v3 generated parser or lexer?

Using ANTLR v3 and the CSharp2 language specifier, is there any way to indicate that you want the generated lexer or parser to be internal versus the default of public? The namespace is specified with: @lexer::namespace {My.Namespace} and I would assume something similar exists for the access specifier, but I have been unable to find...

C# ANTLR grammar?

I'm looking for turn-key ANTLR grammar for C# that generates a usable Abstract Syntax Tree (AST) and is either back-end language agnostic or targets C#, C, C++ or D. It doesn't need to support error reporting. P.S. I'm not willing to do hardly any fix-up as the alternative is not very hard. ...

What's better, ANTLR or JavaCC?

Concerns are documentation/learnability, eclipse integration, tooling, community support and performance (in roughly that order). ...

is SFig language syntax efficient and clear (and better than Spring-Framework's XML DSL)?

ADDENDUM EDIT: Have not accepted an answer to this as there has not been any feedback from experienced Spring Framework developers. I've been working on a replacement DSL to use for Spring-Framework applicationContext.xml files (where bean initialization and dependency relationships are described for loading up into the Sprin...

Running/Interpreting C on top of the JVM?

Is there a way to run plain c code on top of the JVM? Not connect via JNI, running, like you can run ruby code via JRuby, or javascript via Rhino. If there is no current solution, what would you recommend I should do? Obviously I want to use as many partials solutions as I can to make it happen. ANTLR seems like a good place to start, ...

How do I resolve the lexical ambiguity between numbers and dates in ANTLR 2?

I have two token types in my lexer defined like this: NUMBERVALUE : ( '0' .. '9' )+ ( '.' ( '0' .. '9' )+ )? ; DATEVALUE : ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) '-' ( '0' .. '9' ) ( '0' .. '9' ) '-' ( '0' .. '9' ) ( '0' .. '9' ) | ( '0' .. '9' ) ( '0' .. '9' ) '-' ...

Chomsky Hierarchy and LL(*) parsers

Hey out there, I want to parse a programming language. I read a lot about formal languages and the Chomsky hierarchy and ANTLR. But I could not find information on how to relate the languages ANTLR v3 as an LL(*) recursive descent parser accepts to the chomsky hierarchy. How do the Chomsky types mix with LL(*)? Any information (online,...