[il-antlr-interest: 27220] Re: [antlr-interest] a grammar problem

2009-12-13 Thread John B. Brodie
Greetings! On Sun, 2009-12-13 at 14:20 +0100, Hans-Martin Adorf wrote: here is an excerpt on a SchemeNumber grammar which is part of a Scheme grammar that I am toying with. grammar SchemeNumber; tokens { HASH = '#' ; } prefix2: RADIX2 EXACTNESS? | EXACTNESS? RADIX2

[il-antlr-interest: 27293] Re: [antlr-interest] simple lexical analysis question

2009-12-16 Thread John B. Brodie
='\n',7,channel=99,2:5] Jean-Claude Durand LIG, équipe GETALP 385, rue de la Bibliothèque BP 53 38041 Grenoble cedex 9 France jean-claude.dur...@imag.fr tél: +33 (0)4 76 51 43 81 fax: +33 (0)4 76 63 56 86 Le 14 déc. 09 à 19:35, John B. Brodie a écrit : Greetings! On Mon

[il-antlr-interest: 27344] Re: [antlr-interest] Problems with first example

2009-12-21 Thread John B. Brodie
Greetings! On Mon, 2009-12-21 at 09:08 -0500, Bill Ramsay wrote: Hello, I'm new to Antlr and am trying to work through the Definitive Guide. I can't seem to get the first example to work. I create the .g file and lexer and parser classes fine. I compile my example test program fine.

[il-antlr-interest: 27511] Re: [antlr-interest] Using own ASTLabelType and quantification

2010-01-12 Thread John B. Brodie
Greetings! On Tue, 2010-01-12 at 17:06 +0100, Olaf Keijsers wrote: Greetings, I am trying to make a treewalker for my grammar in order to check if it contains nondeterminism. I would like to be able to set some properties for every node I encounter, so I figured it would be a good idea to

[il-antlr-interest: 27516] Re: [antlr-interest] Noob Question

2010-01-12 Thread John B. Brodie
Greetings! Your WS lexer rule can recognize the empty string, this is VERY bad. Because WS can recognize the empty string your lexer will enter an infinite loop when encountering a character it can not deal with - like the '_' in your example - you have no lexer rule that can handle a '_'. More

[il-antlr-interest: 27629] Re: [antlr-interest] newbie needs help

2010-01-21 Thread John B. Brodie
Greetings! On Thu, 2010-01-21 at 20:20 +0100, Hugo wrote: I started using antlr to parse a specific file format. The problem is that i don't know how to write correctly my grammar. The file have the following format. It contains multiple lines and each can have the following format: Only

[il-antlr-interest: 27827] Re: [antlr-interest] Creating AST with third party grammar

2010-02-08 Thread John B. Brodie
Greetings! On Mon, 2010-02-08 at 14:58 -0800, tahiti wrote: Please, repply on the simple question: how access to generated ast? The documantation for 3.0 a thery uggly and don't contains necessary information. I know how to do it in the version 2.0 (there are method getAST() in Parser class),

[il-antlr-interest: 27833] Re: [antlr-interest] Creating AST with third party grammar

2010-02-09 Thread John B. Brodie
On Tue, 2010-02-09 at 10:17 -0800, tahiti wrote: No, I confused right for lack of return type of this methods. The method query() that parse entire query has return type boid. It is only modify the state of the parser class state._fsp located in base class of Parser: RecognizerSharedState. I

[il-antlr-interest: 27877] Re: [antlr-interest] Newbie, rapidly losing mind

2010-02-10 Thread John B. Brodie
Greetings! On Wed, 2010-02-10 at 23:05 -0500, cdell...@paragenic.org wrote: Hi, I am relatively new to ANTLR but I have to make a custom-built grammar file for the Java language. I am having trouble with a rule for which I get a rule arrayInstantiation has non-LL(*) decision due to

[il-antlr-interest: 27943] Re: [antlr-interest] Logical Expression parser

2010-02-15 Thread John B. Brodie
Greetings! On Mon, 2010-02-15 at 22:57 +, Nazim Oztahtaci wrote: Hi, I want to write a parser using ANTLR grammar. I would like to translate the logical expression to Sum of Product form. I give you the example below. I am not sure that the following will be of any help. Having the

[il-antlr-interest: 28066] Re: [antlr-interest] Left-Recursion Removal Help

2010-02-23 Thread John B. Brodie
Greetings! It is really hard to know for sure how to truly answer your question without seeing a complete example of your problem (e.g. please always try to post a *smallest* yet *complete* example of your issue when asking a question). With that mealy worded excuse for my incompetence, I will

[il-antlr-interest: 28230] Re: [antlr-interest] Cannot explain no viable alternative at input - antlr 3.0.1

2010-03-10 Thread John B. Brodie
Greetings! On Thu, 2010-03-11 at 14:01 +1100, J. Matthew Pryor wrote: I am a total ANTLR newbie, Welcome to the crowd! ...stuff snipped... so when I give it the input true true despite the fact that I get the following consle messages line 1:5 no viable alternative at input ''

[il-antlr-interest: 28331] Re: [antlr-interest] THelp w/ Tree Grammer - Rule Action Error

2010-03-19 Thread John B. Brodie
Greetings! On Fri, 2010-03-19 at 15:26 -0400, William Koscho wrote: Hi All, I have a tree grammar, and am trying to just print out some information from the tree. This works fine for matching tokens, but not when matching the rules. I'm hoping someone can help explain why this is giving

[il-antlr-interest: 28334] Re: [antlr-interest] semantic analysis

2010-03-19 Thread John B. Brodie
Greetings! On Fri, 2010-03-19 at 17:01 -0400, venkat medhaj wrote: Hi, I have a simple grammar for which I was able to walk through the AST and printout the input text to the console. I learned that we need to put the information in the symbol table and do the semantic analysis from there

[il-antlr-interest: 28360] Re: [antlr-interest] TreeRewrite bug or misuse?

2010-03-24 Thread John B. Brodie
Greetings! On Wed, 2010-03-24 at 13:26 -0700, Kaleb Pederson wrote: I'm rewriting a tree in a way that I think follows the rules. Here's a sample input fragment: one == two three == four five == six The following rewrite works correctly, but then I have to iterate over the list and

[il-antlr-interest: 28374] Re: [antlr-interest] Lexer rule for strings with quoted strings within

2010-03-25 Thread John B. Brodie
On Thu, 2010-03-25 at 14:52 +0100, Bart Kiers wrote: On Thu, Mar 25, 2010 at 2:01 PM, Anders Sollander anders.sollan...@mathworks.de wrote: Hi, I've been trying to write a lexer rule for strings with strings in them, like This has a quoted string within Is there a

[il-antlr-interest: 28563] Re: [antlr-interest] Ambiguity caused by recursion (I think)

2010-04-08 Thread John B. Brodie
Greetings! On Thu, 2010-04-08 at 20:29 -0400, Cameron Ross wrote: Hi, I have a grammar that calls a rule from two different levels. This leads to an ambiguity being reported from the two different calls to the rule. Oddly, the ambiguity points to the same place, so I'm not sure why its

[il-antlr-interest: 28538] Re: [antlr-interest] help please

2010-04-20 Thread John B. Brodie
Greetings! On Tue, 2010-04-20 at 14:37 +, Molka Tounsi wrote: I tried this example on ANTLRWORK but it shows me errors. This is the code: class CalcParser extends Parser; options { buildAST = true;// uses CommonAST by default } expr : mexpr (PLUS^ mexpr)*

[il-antlr-interest: 28574] Re: [antlr-interest] token not recognized

2010-04-22 Thread John B. Brodie
Greetings! On Thu, 2010-04-22 at 12:04 -0800, kumarr wrote: Hi all, I have defined a token called GEN that can take on various string values. The grammar is below. The token is question is GEN. I'm trying to parse a very simple string conforming to this grammar: Unavailable(LEP). When it

[il-antlr-interest: 28612] Re: [antlr-interest] Matching Substring In Lexer

2010-04-26 Thread John B. Brodie
Greetings! On Mon, 2010-04-26 at 19:02 -0400, Kunal Sawlani wrote: Hi, Thanks to both of you, I have something which works now. However, I am running into a slight issue, where the parser complaints that ANYTHING is not defined, in case of the grammar Jim suggested, and for John's grammar,

[il-antlr-interest: 28871] Re: [antlr-interest] Find X :-)

2010-05-18 Thread John B. Brodie
On Tue, 2010-05-18 at 17:10 +0200, Sameh W. Zaky wrote: OK, Sorry for that! Just after I have sent this message I realized that the problem is that ANTLR cannot find my method myLookUpMethod.. I have defined it in @members{} part of the grammar file.. But ANTLR still cannot find it.. Any

[il-antlr-interest: 28915] Re: [antlr-interest] null pointer to ADAPTOR-setTokenBoundaries

2010-05-19 Thread John B. Brodie
Pardon me for butting in. And I have never used the C code generator, but. On Wed, 2010-05-19 at 14:06 -0700, Alan Condit wrote: which I assume, based on the comment, is generated from this rule: line : line_number? segment+ K_NEWLINE - ^(STMT segment+) |

[il-antlr-interest: 28985] Re: [antlr-interest] Please, help to write a tree walker

2010-05-24 Thread John B. Brodie
Greetings! I am unable to compile your combined grammar. On Mon, 2010-05-24 at 12:55 +0400, Ламер wrote: STRING_LITERAL : '' { StringBuilder b = new StringBuilder(); } ( c=~('' | '\r' | '\n'/* | VARIABLE*/) { b.appendCodePoint(c); }

[il-antlr-interest: 28993] Re: [antlr-interest] ClassCastException in TreeParser grammar

2010-05-25 Thread John B. Brodie
Hello :- This grammar still has the same compilation problem as the one that you posted yesterday. did you change anything? I fixed the STRING_LITERAL rule as you suggested in a private e-mail to me (please keep all messages on this list). I then did not get any ClassCastException. But got

[il-antlr-interest: 28997] Re: [antlr-interest] What's wrong with org.antlr.Tool.main(String[] args)?

2010-05-25 Thread John B. Brodie
On Tue, 2010-05-25 at 21:12 +0200, Sameh W. Zaky wrote: Hi all, Using ANTLR v3.2, in the runtime I generate the lexer and parser Java files using this code: org.antlr.Tool.main(new String[]{projectPath+GrammarFile.g}); The problem is that, after this line of code, no other code gets

[il-antlr-interest: 29091] Re: [antlr-interest] Advice with backtracking/ambiguity

2010-06-02 Thread John B. Brodie
On Wed, 2010-06-02 at 17:03 -0500, Ken Williams wrote: Yeah, probably I should be using parser rules. I was trying to keep things simple by making everything a linear stream of tokens from the point of view of the Java caller, while still having high-level constructs like DATE. Perhaps what

[il-antlr-interest: 29225] Re: [antlr-interest] Help me get started

2010-06-22 Thread John B. Brodie
Greetings! On Tue, 2010-06-22 at 04:22 -0400, Pavel Grinfeld wrote: Hi, Here's my first attempt at an ANTLR project. For practice, I just want to read a file with lowercase words and print them. I feed it hi there how are you All that the program prints is hi. Many thanks in advance,

[il-antlr-interest: 29228] Re: [antlr-interest] Multiple alternatives warning

2010-06-22 Thread John B. Brodie
Greetings! On Tue, 2010-06-22 at 11:08 -0400, Pavel Grinfeld wrote: Hi, I'm begging to get my bearings on this But the following gives two multiple alternatives warnings. How come? Many thanks in advance, Pavel grammar PGTeX; doc :

[il-antlr-interest: 29245] Re: [antlr-interest] unexpected behavior in splitter grammar

2010-06-24 Thread John B. Brodie
Greetings! On Thu, 2010-06-24 at 16:23 +0200, Scherer Markus wrote: I am currently working on a grammar, that converts SQL*PLUS scripts in JDBC compatible statements. Basically I am separating the different statements in * normal SQL statements (to be JDBC compatible, the trailing

[il-antlr-interest: 29251] Re: [antlr-interest] [SPAM] [SPAM] non-LL(*) error with nested arrays

2010-06-24 Thread John B. Brodie
Greetings! On Fri, 2010-06-25 at 03:00 +0200, Olivier Lefevre wrote: Greetings ANTLR experts, I have the attached toy grammar for integer arrays of arbitrary depth but the stat rule has non-LL(*) decision due to recursive rule invocation. It is recommended to left-factor or to use a

[il-antlr-interest: 29326] Re: [antlr-interest] Antlr first time user, help requested

2010-07-06 Thread John B. Brodie
Greetings! On Mon, 2010-07-05 at 22:18 -0600, Andrew Robinson wrote: Sorry to say that ANTLR is driving me nuts, starting to really hate the tool, so I'd really appreciate some help on it before I give up on it. Sorry for your frustration. I hope you hang in there. I think ANTLR is worth its

[il-antlr-interest: 29327] Re: [antlr-interest] Antlr first time user, help requested

2010-07-06 Thread John B. Brodie
On Tue, 2010-07-06 at 09:47 -0400, John B. Brodie wrote: snipped change all references to TEXT to be text sorry, should be: change all references to TEXT to be text+ I thought that maybe i should test what I am recommending so attached please find a grammar that parses your example

[il-antlr-interest: 29382] Re: [antlr-interest] Python target for nested braces handling (multiple alternatives)

2010-07-12 Thread John B. Brodie
On Mon, 2010-07-12 at 22:11 -0400, Reynold Xin wrote: I have the following grammar file. When I was running it in Java using ANTLR works, it compiles without any problem. However, when I was using the Python target: # java -cp antlr-3.1.2.jar org.antlr.Tool bibtex.g It prompts the error:

[il-antlr-interest: 29453] Re: [antlr-interest] Custom AST node type - guidance needed

2010-07-19 Thread John B. Brodie
On Mon, 2010-07-19 at 14:29 -0400, Bill Andersen wrote: Hi folks Greetings! Having some trouble making ASTs using a custom node type. Before I ask any stupid questions, what is the best place to look on how to do this ( I'm using 3.2 )? I'm finding bits and pieces, some of them

[il-antlr-interest: 29704] Re: [antlr-interest] Mismatched Character, expecting set null

2010-08-06 Thread John B. Brodie
Greetings! On Fri, 2010-08-06 at 02:16 -0400, Ken Klose wrote: Hello, I'm writing my first grammar and have started with something painfully simple but yet cannot figure out why I am receiving errors. At this point I expect my grammar to recognize a whitespace delimited list of integers.

[il-antlr-interest: 29705] Re: [antlr-interest] grammar problem with recursion?

2010-08-06 Thread John B. Brodie
Greetings! you really need to left factor your rules. also lex_entry and rule_entry are identical rules! ambiguous. even with backtracking turned on how are we to know which to recognize. and perhaps worse, we can not know that we have a type_def (as opposed to lex_entry or rule_entry) until the

[il-antlr-interest: 29714] Re: [antlr-interest] Mismatched Character, expecting set null

2010-08-06 Thread John B. Brodie
On Fri, 2010-08-06 at 12:07 -0400, Kevin J. Cummings wrote: On 08/06/2010 07:33 AM, John B. Brodie wrote: stuff snipped WS: (' ' | '\t' | '\n' | '\r' | '\f') {$channel = HIDDEN;}; this rule recognizes (and then ignores) just a single white-space character. would be more efficient

[il-antlr-interest: 29716] Re: [antlr-interest] Need some help with AST creation

2010-08-06 Thread John B. Brodie
Greetings! On Fri, 2010-08-06 at 16:41 +0100, Luis Pureza wrote: Hi, I need some help from the ANTLR wizards :) I am not sure I qualify as an ANTLR wizard, but I try to answer your question anyway I'm trying to match expressions with field accesses and array indexes. For example:

[il-antlr-interest: 29723] Re: [antlr-interest] Mismatched Character, expecting set null

2010-08-07 Thread John B. Brodie
On Sat, 2010-08-07 at 04:31 -0400, Ken Klose wrote: I have arrived at a new problem that I can't resolve. I am parsing a rather simple data file and have to read a field that can be a number of the forms 55, +55, -55, or .. in case where no number has been assigned. I've tried the following

[il-antlr-interest: 29734] Re: [antlr-interest] Building a tree grammar expression to recognize arithmetic expressions

2010-08-08 Thread John B. Brodie
Greetings! the ^ meta-operator in the suffix position is a tree construction operation and is NOT valid for tree recognition. you should be getting a warning similar to: warning(149): treeTest.g:0:0: rewrite syntax or operator with no output option; setting output=AST or if you have already set

[il-antlr-interest: 29741] Re: [antlr-interest] Right recursive rule and creating the AST in reverse order

2010-08-08 Thread John B. Brodie
Greetings! passing the FROM tree down the rule set doesn't seem too bad to me. DISCLAIMER: i can barely spell C# and certainly know nothing whatsoever about LINQ --- so i probably have mis-understood something crucial. On Sun, 2010-08-08 at 19:10 +0100, Luis Pureza wrote: Hi, I'm writing a

[il-antlr-interest: 29746] Re: [antlr-interest] How does INTEGER+ '.' INTEGER+ match 2.?

2010-08-08 Thread John B. Brodie
On Sun, 2010-08-08 at 20:50 -0400, Kevin J. Cummings wrote: On 08/08/2010 08:35 PM, Ken Klose wrote: Thanks for replying. 2. is not a valid PRICE. PRICE should have at least 1 digit following the '.'. In the context of the string that I am trying to match 2. doesn't have any

[il-antlr-interest: 29810] Re: [antlr-interest] Diference bettew Tokens and Lexical Rules

2010-08-11 Thread John B. Brodie
Greetings! On Wed, 2010-08-11 at 22:57 -0300, Victor Giordano wrote: Hi there!!. How you doing guys? Hope good!. I am fine, I hope you are too! A have another question about tokens and lexical rules, i really don't get the idea... For example, assume we have this: 1) tokens {

[il-antlr-interest: 30046] Re: [antlr-interest] Viable Alternative Rule?

2010-08-29 Thread John B. Brodie
Greetings! On Sun, 2010-08-29 at 07:40 -0700, Ted Hoise wrote: VERY simple example rule : 'H' ; When I test this very simple rule, it works (in Antlrworks and Eclipse) of course for input 'H', but it also works for input 'fH', resulting in a token 'fH'. I do I suppress this behavior:

[il-antlr-interest: 30055] Re: [antlr-interest] Subrule alternatives - MismatchedTokenException cannot be explained

2010-08-30 Thread John B. Brodie
Greetings! On Mon, 2010-08-30 at 13:01 -0700, st3 wrote: Hi, I have a simple grammar - which includes a '+' or '-' operation on a variable (ID) or constant (INT). The add rule is obviously: mult (+/- mult). However, the way I need the add rule defined throws the

[il-antlr-interest: 30060] Re: [antlr-interest] White space

2010-09-01 Thread John B. Brodie
Greetings! On Wed, 2010-09-01 at 11:30 -0700, Alex Rodriguez wrote: Greetings, Given a very simple grammar for a language that only has an 'if' statement, I would like to be able to parse white space within literal values. So far, this works (case 1): if(value=='white

[il-antlr-interest: 30336] Re: [antlr-interest] very simple doubt about EXPR grammar

2010-10-14 Thread John B. Brodie
Greetings! On Thu, 2010-10-14 at 09:31 -0300, Leonardo K. Shikida wrote: Hi Kevin You´re right. So I´ve changed the grammar to include a stopword (semicolon). Still the same problem. 1-1+1; generates a NoViableAltException very strange... while 1+1-1; does not This is very

[il-antlr-interest: 30405] Re: [antlr-interest] rewrite rule like AST construction operator '^'

2010-10-24 Thread John B. Brodie
Greetings! On Sun, 2010-10-24 at 02:35 -0700, Trevor John Thompson wrote: I have a language in which one expression may immediately follow another. I am trying to construct an AST with an imaginary node representing the concatenation operator. I want the moral equivalent of expr: term (SP^

[il-antlr-interest: 30428] Re: [antlr-interest] rewrite rules cont.

2010-10-27 Thread John B. Brodie
On Tue, 2010-10-26 at 20:07 -0700, Trevor John Thompson wrote: Greetings. I continue to wrestle with rewrite rules for AST construction. I am trying to treat semicolon and newline as equivalent separators, and gather a sequence of expressions as children of a single AST node. The grammar

[il-antlr-interest: 30468] Re: [antlr-interest] Matching multiple occurrences of quoted text joined by 'and' (i.e. a and b and c)

2010-11-03 Thread John B. Brodie
Greetings! On Wed, 2010-11-03 at 22:40 +, Colin Yates wrote: Hmmm - I think I might be running into a bug - either in the code or my understanding (almost certainly my understanding!). unfortunately i do believe you have mis-understood ANTLR Lexers... I have created a simple grammar

[il-antlr-interest: 30508] Re: [antlr-interest] Very simple grammar confusing me

2010-11-09 Thread John B. Brodie
Greetings! On Tue, 2010-11-09 at 15:26 +0100, Oliver Zeigermann wrote: Folks! This is my grammar -- SHRASS : '=' ; SEMI : ';' ; GT : ''; rule : (GT | SEMI | SHRASS)+ ; -- I though it should parse ; into a token stream of GT GT SEMI but

[il-antlr-interest: 30666] Re: [antlr-interest] Identifiers with Spaces

2010-11-26 Thread John B. Brodie
Greetings! On Fri, 2010-11-26 at 23:31 +0100, Michael Bosch wrote: Hi, I am trying to parse a language where identifiers can contain spaces but otherwise spaces need to be ignored. I have a problem getting the ANTLR tokenizer to do this. My problem can be reproduced with the following

[il-antlr-interest: 30684] Re: [antlr-interest] Identifiers with Spaces

2010-11-29 Thread John B. Brodie
sometimes, when the necessary look ahead is small and is bounded, syntactic predicates can be your friend. see attached. grammar LexerOnly; @members { private static final String [] x = new String[]{ a8 b c = d e23 f, a1b2c3 = xyz, a1 2 b }; public static

[il-antlr-interest: 30738] Re: [antlr-interest] Antlr lexer does not try other possible matches when it fails to match a token

2010-12-01 Thread John B. Brodie
Greetings! On Wed, 2010-12-01 at 16:09 +0100, COUJOULOU, Philippe wrote: Sorry, the code I posted was not correct. Here is the correct code I wanted to copy in my previous message (with xxxParameter parser rules referring to correct parameter value rule): grammar test; listOfParameters

[il-antlr-interest: 30770] Re: [antlr-interest] Newby Lexer Question

2010-12-03 Thread John B. Brodie
Greetings! On Fri, 2010-12-03 at 07:05 -0800, Daniel Rippel wrote: I am fairly new to antlr and am running into a basic issue that I can't quite find the answer for on the wiki and in Parr's book. Here is my lexer. Greatly simplified of course. ... CREATE : 'create' ; ...

[il-antlr-interest: 30790] Re: [antlr-interest] Problem with EBNF

2010-12-05 Thread John B. Brodie
Greetings! On Sun, 2010-12-05 at 21:44 +0100, Morten Olav Hansen wrote: Hi, thanks for your reply. Sorry if it wasn't clear, but the ordering does not matter. The rule you proposed is basically what I had before, and as you say, it allows any number of ps* keywords. What I meant by

[il-antlr-interest: 30911] Re: [antlr-interest] Lexer and Parser using CSharp3

2010-12-19 Thread John B. Brodie
Greetings! On Sun, 2010-12-19 at 13:43 +0100, Gian Maria wrote: program: start+; start : (let | num); let: LET; num: NUM; LET: ('a'..'z')+; NUM: ('0'..'9')+; WHITESPACE : ( '\t' | ' ' | '\r' | '\n' )+ {

[il-antlr-interest: 31275] Re: [antlr-interest] Need help with generating a nested tree

2011-01-29 Thread John B. Brodie
On Sat, 2011-01-29 at 09:34 -0800, Alan D. Cabrera wrote: functioncall : varOrExp nameAndArgs+ - ^(FUNCALL varOrExp nameAndArgs+) ; generates (FUNCALL varOrExp nameAndArgs1 nameAndArgs2 nameAndArgs3 ) What I need it to do is generate (FUNCALL

[il-antlr-interest: 31321] Re: [antlr-interest] Question of Repetead tokens and early termination

2011-02-02 Thread John B. Brodie
Your grammar does not mention the EOF token. (more below...) On Wed, 2011-02-02 at 16:18 -0300, Victor Giordano wrote: Hi there. I am having trouble with the error handling. I have a grammar for recoignize linear expression. And it works great!. The grammar for a linear expresion is the

[il-antlr-interest: 31585] Re: [antlr-interest] ast rewrites in left-recursive rules

2011-02-23 Thread John B. Brodie
On Wed, 2011-02-23 at 16:37 -0800, Terence Parr wrote: So I have it working with rewrite rules now: e : e '.' ID - ^('.' e ID) | e '.' 'this' - ^('.' e 'this') | '-' e - ^('-' e) | e '*' b=e - ^('*' e $b) | e

[il-antlr-interest: 31869] Re: [antlr-interest] How to ignore TOKEN in a String

2011-03-21 Thread John B. Brodie
Greetings! On Mon, 2011-03-21 at 10:00 -0700, Hiten R wrote: Hi All, ANTLR grammar acts funny when it encounters a TOKEN in a String. How should I make the ANTLR escape the letter found in the String is not a TOKEN. Help will be appreciated. Thanks Hiten Example text_content.txt

[il-antlr-interest: 31887] Re: [antlr-interest] Imaginary Node Constructor T[token-ref, text] throws error: missing attribute access on rule scope: token-ref

2011-03-22 Thread John B. Brodie
On Tue, 2011-03-22 at 16:46 -0400, The Researcher wrote: FYI In using Imaginary Node Constructor T[token-ref,text] as documented in The Definitive ANTLR Reference pg. 176, the error missing attribute access on rule scope: token-ref was given. I was able to use T[text] as documented

[il-antlr-interest: 31897] Re: [antlr-interest] Imaginary Node Constructor T[token-ref, text] throws error: missing attribute access on rule scope: token-ref

2011-03-22 Thread John B. Brodie
On Tue, 2011-03-22 at 17:21 -0400, The Researcher wrote: On Tue, Mar 22, 2011 at 5:14 PM, John B. Brodie j...@acm.org wrote: On Tue, 2011-03-22 at 16:46 -0400, The Researcher wrote: FYI In using Imaginary Node Constructor T[token-ref,text] as documented in The Definitive

[il-antlr-interest: 31898] Re: [antlr-interest] How to ignore TOKEN in a String

2011-03-22 Thread John B. Brodie
On Tue, 2011-03-22 at 14:40 -0700, Hiten R wrote: John/All I followed 'antlr wiki' example but then it stopped working completely. Previous way it was complaining about the second line but after the change it could not get past the first line 'funny boys are Tom Hardy Donald '.

[il-antlr-interest: 31951] Re: [antlr-interest] Help please

2011-03-24 Thread John B. Brodie
Greetings! On Thu, 2011-03-24 at 17:22 +0100, wael sellami wrote: Hello, ...stuff snipped... book : ^(BOOKDEF name (xmltag)+) { System.out.println(Begin book tag); System.out.println(END book tag); }; ...snipped... short answer, place actions properly: book : ^(BOOKDEF name {

[il-antlr-interest: 31999] Re: [antlr-interest] Spaces issues

2011-03-29 Thread John B. Brodie
Greetings! On Tue, 2011-03-29 at 00:47 -0600, Fabien Hermenier wrote: Hi I starting to use ANTLR3 with AntlrWorks 3.4.1 on OS X and I have some issues with spaces. I've attached a sample antlr file describing my grammar (see 1st grammar) I'm trying to test 'litteralRange'. So using the

[il-antlr-interest: 32013] Re: [antlr-interest] How to handle rewrite of multiple nodes

2011-03-29 Thread John B. Brodie
Greetings! On Wed, 2011-03-30 at 12:43 +1100, Simon wrote: Hello all, I have a grammar that does a rewrite like so: bracketedBlock : '{' stmts=statement* '}' - ^(Block $stmts) ; you are not properly handling the cardinality of the * meta-operator. try: bracketedBlock :

[il-antlr-interest: 32377] Re: [antlr-interest] Function Expressions

2011-05-04 Thread John B. Brodie
Greetings! On Wed, 2011-05-04 at 12:27 -0400, Jeff Hair wrote: Hello all, I have a simple C/JavaScript-style grammar for my interpreter project. Right now, functions can be called via identifier(), or identifier(param1, param2). This works fine for simple cases, but in my language functions

[il-antlr-interest: 32404] Re: [antlr-interest] Doesn't the lexer try rules in order?

2011-05-07 Thread John B. Brodie
Greetings! On Sat, 2011-05-07 at 10:06 -0400, Todd O'Bryan wrote: Can anyone explain to me why tabs, spaces, and greater-thans at the beginning of lines are ending up in TEXT tokens, rather than in INDENT or QUOTE tokens, as I think they should? fragment SPECIAL_CHARS : ('\n' | '[' |

[il-antlr-interest: 32425] Re: [antlr-interest] C Target - Assigning rule info to imaginary tokens

2011-05-10 Thread John B. Brodie
Greetings! On Tue, 2011-05-10 at 09:14 -0500, A Z wrote: Hello all, I have a case where I need to assign an imaginary token the attributes of a token inside a rule. I tried the below but as expected it does not have the desired effect. var_or_function : identifier ( LPARAN

[il-antlr-interest: 32453] Re: [antlr-interest] Problem while compiling/debugging: int cannot be dereferenced

2011-05-14 Thread John B. Brodie
You have chosen a rule name that clashes with a Java class name, e.g. Integer. Select another name for your current Integer lexer rule. In my opinion this is not an ANTLR problem, rather it is a user error. On Sat, 2011-05-14 at 23:45 +0200, Dominik Halfkann wrote: Here are the generated java

[il-antlr-interest: 32457] Re: [antlr-interest] Return Values

2011-05-15 Thread John B. Brodie
Greetings! On Sun, 2011-05-15 at 16:11 +0200, Bart Kiers wrote: Hi Philip, You can't since aParserToken will be initialized as a org.antlr.runtime.Token type. You will have to do it (the hard way) like this: parserRule0 : ( parserRule1

[il-antlr-interest: 32464] Re: [antlr-interest] Fragments for rewrite rules

2011-05-16 Thread John B. Brodie
Greetings! On Mon, 2011-05-16 at 09:43 +0200, Ben Corne wrote: Hi Below an example of me trying to use fragment lexer rules to use in rewrite rules. But when I try this out in the interpreter: - 'test bar', with a fragment rule AGTEST conflicting with reading 'test', doesn't parse -

[il-antlr-interest: 32469] Re: [antlr-interest] Automatic lists

2011-05-17 Thread John B. Brodie
Greetings! On Tue, 2011-05-17 at 15:44 +0200, Ben Corne wrote: Found it in the definitive antlr guide: adding a ? behind $docs did the trick. actually i think you want a * in the rewrite expression. test with 2 or more documentation constructs 2011/5/17 Ben Corne ben.co...@gmail.com

[il-antlr-interest: 32640] Re: [antlr-interest] help

2011-06-01 Thread John B. Brodie
Greetings! On Wed, 2011-06-01 at 18:20 -0700, Omar Mohssen wrote: hello i have a problem using the grammar ANSI C ANTLR v3 grammar (on the link http://www.antlr.org/grammar/1153358328744/C.g) the problem is that i couldn't find the start state from which i start the interpreter to test

[il-antlr-interest: 32684] Re: [antlr-interest] AST with optional parameters

2011-06-07 Thread John B. Brodie
Greetings! On Tue, 2011-06-07 at 07:41 -0400, David Smith wrote: I'm parsing a grammar in which the semicolon on the end of a line is optional. So two of the statement rules might be: | (ID GETS expr SEMI) = ID GETS expr SEMI - ^(GETS ID expr SEMI) | (ID GETS) = ID GETS expr -

[il-antlr-interest: 32692] Re: [antlr-interest] AST with optional parameters

2011-06-07 Thread John B. Brodie
On Tue, 2011-06-07 at 10:33 -0400, David Smith wrote: Yes, the language is Matlab and a semicolon on the end of an assignment expression suppresses display of the result of the assignment. Bart, I appreciate the suggestion; I haven't tried that (much simpler) solution - I'll let you know.

[il-antlr-interest: 33058] Re: [antlr-interest] left recursion removal

2011-07-06 Thread John B. Brodie
Greetings! On Wed, 2011-07-06 at 21:19 +0200, Sébastien Kirche wrote: Hi, the language for which I am trying to build the grammar has 2 flavors of if-then-else constructs - a single line : if condition then statement [else statement] - a multi line : if condition then statements [else

[il-antlr-interest: 33066] Re: [antlr-interest] left recursion removal

2011-07-06 Thread John B. Brodie
see attached. I, also, am available for hire, if you should opt for that... -jbb On Thu, 2011-07-07 at 01:27 +0200, Sébastien Kirche wrote: Le 7 juillet 2011 00:14, John B. Brodie j...@acm.org a écrit : Greetings! [...] unable to reproduce. given your admittedly partial

[il-antlr-interest: 33077] Re: [antlr-interest] left recursion removal

2011-07-07 Thread John B. Brodie
Greetings! On Thu, 2011-07-07 at 17:04 +0200, Sébastien Kirche wrote: Le 7 juillet 2011 05:08, John B. Brodie j...@acm.org a écrit : see attached. Many, many thanks, as your corrections on my example helped me considerably and the initial recursion is gone. you are welcome. i actually

[il-antlr-interest: 33180] Re: [antlr-interest] turning rules on/off?

2011-07-14 Thread John B. Brodie
Greetings! On Thu, 2011-07-14 at 16:11 -0700, Roy Metzger wrote: Hi all, Let's say I have something like this: rule: ( 'stuff' e1=expression)? statement ('stuff' e2=expression)? ; Now, I would like to know is there a way to dynamically flip rules on/off. For example, when e1 is

[il-antlr-interest: 33193] Re: [antlr-interest] Cannot display rule X because start state not found

2011-07-15 Thread John B. Brodie
Greetings! On Sat, 2011-07-16 at 05:03 +1100, Minhaz Zibran wrote: I am trying to learn ANTLR. I tried to invoke ANTLR v3.3 from command line (java -cp antlr-3.3-complete.jar org.antlr.Tool T.g) on the T.g, and found the following error message: error(10): internal

[il-antlr-interest: 33221] Re: [antlr-interest] Concatenating variable number of tokens into a single string in an action?

2011-07-18 Thread John B. Brodie
Greetings! On Mon, 2011-07-18 at 15:35 -0500, Dejas Ninethousand wrote: Hello, If I have the rule: text : t=(UNQUOTED_ALPHA_TEXT | DECIMAL_NUMBER)+ { stack.pushUnquotedText(...); }; Is there any way for me to gather the text of all the ALPHA_TEXT and DECIMAL_NUMBER tokens in

[il-antlr-interest: 33281] Re: [antlr-interest] (no subject)

2011-07-21 Thread John B. Brodie
Greetings! On Thu, 2011-07-21 at 14:53 +0200, Roland Sako wrote: Hello, I am Roland Sako from Geneva in Switzerland. I am currently working on a project which I need to generate an expression tree of an Objective-C source code, then I will visit that tree to add extra instruction in it.

[il-antlr-interest: 33468] Re: [antlr-interest] Help with a parser

2011-08-02 Thread John B. Brodie
Greetings! On Tue, 2011-08-02 at 23:11 +, Scott Smith wrote: I assume this is the proper place to put this. I'm trying to build a parser for filters generated by SOLR (lucene.apache.org). i think this is exactly the correct place to post questions of this kind. Examples of valid

[il-antlr-interest: 33500] Re: [antlr-interest] Another (hopefully easy) newby question

2011-08-04 Thread John B. Brodie
On Fri, 2011-08-05 at 01:15 +, Scott Smith wrote: I have created a parser/lexer. When I run it as a standard parser (no ASTs), it runs fine. I've verified with the debugger, that it generates a reasonable tree. But, I want to run it to generate ASTs. So, I modified the code to do

[il-antlr-interest: 33533] Re: [antlr-interest] Can't generate the AST I want

2011-08-08 Thread John B. Brodie
On Mon, 2011-08-08 at 19:41 +, Scott Smith wrote: I am writing a grammar to generate ASTs. There are operators called AND and OR (defined in the lexer) in the language. I want my parser to produce ASTs that group together all of the terms which are using the same operator. Also,

[il-antlr-interest: 33544] Re: [antlr-interest] Fedora antlr3-tool command line antlr returns version 2.7.7

2011-08-09 Thread John B. Brodie
I do not use Fedora; rather I use the jar file downloaded from antlr.org on Ubunto 11.04 with proper CLASSPATH setting. So my suggestion may be way off base... On Tue, 2011-08-09 at 11:41 -0400, The Researcher wrote: I am test building ANTLR on Fedora 15 and installed package antlr3-tool using

[il-antlr-interest: 33582] Re: [antlr-interest] Follow-up on line numbers

2011-08-10 Thread John B. Brodie
Sorry for jumping in where i may not belong On Wed, 2011-08-10 at 16:09 -0400, David Smith wrote: Sam, I understood the answer, but we're talking novice here - if the front end of my grammar looks like this: prog: body EOF! ; body: parts - ^(BODY parts)

[il-antlr-interest: 33766] Re: [antlr-interest] formulaGrammar without backtracking

2011-08-25 Thread John B. Brodie
Greetings! On Thu, 2011-08-25 at 16:00 +0400, Романов Артем wrote: grammar formulaGrammar; options{ backtrack=true; } formula : expr ; expr : atom ( OPERATOR expr )* | '(' expr ( OPERATOR expr )* ')' ; atom : ( NUMBER | ID | function ) ; function:

[il-antlr-interest: 33883] Re: [antlr-interest] Does overriding display not turn off messages sent to std error?

2011-09-01 Thread John B. Brodie
Greetings! This is just off the top of my head, so is probably a bogus answer. On Thu, 2011-09-01 at 19:26 -0500, Dejas Ninethousand wrote: I have this entry in my grammar file: @members { @Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) {

[il-antlr-interest: 33968] Re: [antlr-interest] Allowing and maintaining space characters in string literals

2011-09-08 Thread John B. Brodie
Greetings! Have you looked at the Java grammar in the v3 example suite? also On Thu, 2011-09-08 at 18:08 +, janet.hurw...@usc-bt.com wrote: Hello- I'm working on a grammar that needs to support embedded blanks in strings: identifier=two words The interpreter keeps breaking at 'two'

[il-antlr-interest: 34308] Re: [antlr-interest] warning(200), error(201), error(211) and error(208). Help!

2011-10-07 Thread John B. Brodie
Greetings! On Fri, 2011-10-07 at 11:45 -0700, mglyons wrote: I am trying to build the grammar for a small language, C-. I am getting a long list of errors and am unable to resolve them with google and my textbook after almost a day of trying. Here is my grammar: Here is the list of

[il-antlr-interest: 34314] Re: [antlr-interest] warning(200), error(201), error(211) and error(208). Help!

2011-10-07 Thread John B. Brodie
On Fri, 2011-10-07 at 13:16 -0700, mglyons wrote: Thanks for the quick response John B. In the pdf I have that is instructing how to write this grammar it says this: /The keywords of the language are the following:/ *else if int return void while* /All keywrods are reserved, and must

[il-antlr-interest: 34318] Re: [antlr-interest] warning(200), error(201), error(211) and error(208). Help!

2011-10-07 Thread John B. Brodie
On Fri, 2011-10-07 at 16:22 -0700, mglyons wrote: Thanks again! I did what you said and also figured out how to do some left-factoring. I had to fix 3 left-factoring issues and resolved two of them. This one I cannot seem to figure out: *expr : var '=' expr | simple_expr;* I do

[il-antlr-interest: 34794] Re: [antlr-interest] missing MATCHRANGE macro

2011-11-07 Thread John B. Brodie
On 11/07/2011 12:32 PM, Jim Idle wrote: Better to do this: fragment FLOAT; INT : '0'..'9'+ ( '.' '0'..'9'+ { $type = FLOAT; } | ) ; and of course the above REQUIRES at least one digit to the left of the decimal place on FLOAT. which is not what the OP had. but is easily fixed, i believe, as:

[il-antlr-interest: 34848] Re: [antlr-interest] grammar works in antlrworks debug mode but not eclipse

2011-11-11 Thread John B. Brodie
Greetings! On 11/11/2011 03:00 AM, D. Frej wrote: The grammar is rather stupid and simple ... snipped ... It is executed with the following Java code ANTLRStringStream input = new ANTLRStringStream(15 / 7.25 +4); ExpressionLexer lex = new ExpressionLexer(input); CommonTokenStream tokens =

[il-antlr-interest: 34910] Re: [antlr-interest] Having trouble with creating a parser for my desired grammar. Running afoul of multiple alternatives warnings

2011-11-15 Thread John B. Brodie
Greetings! I think you have issues with your function, number, and ATOM rules. see below... I have attached my complete, modified, grammar that successfully parses your input sample. On 11/14/2011 11:47 PM, Jarrod Roberson wrote: I am trying to write a parser for the following syntax

[il-antlr-interest: 34914] Re: [antlr-interest] This should be easy - but I can't figure it out

2011-11-15 Thread John B. Brodie
Greetings! First 2 caveats then see discussion below: 1) I do not know C#. all of my suggestions are based on the Java target. 2) My suggestions are from memory. I have not actually tested them (or rather I have tested them in the past on other problems and hope memory works). On 11/15/2011

[il-antlr-interest: 34934] Re: [antlr-interest] This should be easy - but I can't figure it out

2011-11-16 Thread John B. Brodie
On 11/16/2011 12:02 AM, Voelkel, Andy wrote: array: '[' FLOAT+ | STRING+ ']' - ^(ARRAY FLOAT+ STRING+) ; the separate lists on the right of the - work because your syntax specifies separate lists. [Andy - this approach doesn't work - I get exceptions thrown. I haven't debugged that

  1   2   >