[il-antlr-interest: 26805] Re: [antlr-interest] Equivalent of TOKEN{x,y}

2009-11-11 Thread Gavin Lambert
At 08:35 12/11/2009, Kaleb Pederson wrote: >Is there an easy way to enforce in the grammar that a lexical token >must be present a certain number of times? > >For example, with TOKEN{x,y} as you might see in an extended >regular expression, it would require that TOKEN be present at >minimum

[il-antlr-interest: 26788] Re: [antlr-interest] custom TokenLabelType and EOF/Error tokens

2009-11-10 Thread Gavin Lambert
At 17:34 11/11/2009, David-Sarah Hopwood wrote: >On closer investigation, it seems that this problem is due to >CommonTokenStream using Token.EOF_TOKEN, which is hardcoded to a >CommonToken. It's probably not too surprising that CommonTokenStream expects to have a stream of CommonTokens... :)

[il-antlr-interest: 26773] Re: [antlr-interest] Big grammar => static initializer/method size is exceeding the 65535 bytes limit

2009-11-10 Thread Gavin Lambert
At 04:20 6/11/2009, Jim Idle wrote: >At the moment though [...] I am rewriting all the grammars >in v3 to be self hosted. Didn't Sam Harwell already do that for the C# port? List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-int

[il-antlr-interest: 26462] Re: [antlr-interest] [Antlr3 grammar] how to specify alpha token, numeric token and mix of both

2009-10-23 Thread Gavin Lambert
At 16:45 23/10/2009, Hieu Phung wrote: >Alpha = %x41-5A; >Numeric = %x30-39; >Decimal = %x30-39 / "."; >Mixed = Alpha / Numeric; >Text= %x41-5A / %x30-39 / "." / "-" / " "; <--- this is my >MIX token > >This format can be written in ABNF easily... but in Antlr, once I >introduce the MI

[il-antlr-interest: 26327] Re: [antlr-interest] How to do "not" in a syntactic predicate?

2009-10-16 Thread Gavin Lambert
At 00:39 17/10/2009, Naveen Chawla wrote: >So, does anybody have a way of doing "Take *a* IF not followed by >*b* (both syntactic constructs)" ? > >i.e. >q: (a !b)=> a;//("!" or "not" doesn't >exist in ANTLR) Actually there is a negation operator, ~ -- but this operates

[il-antlr-interest: 26208] Re: [antlr-interest] [LEXER] Unwanted behaviour ?

2009-10-12 Thread Gavin Lambert
At 01:28 13/10/2009, Martin Potier wrote: >LO: '[['; // Link opening >LE: ']]'; // Link ending > >PURETEXT > : ( ESC_SEQ | >~('\\'|TM1|TM2|TM3|TM4|ULM|LO|LE|OLM|BM|IM|UM|'|'|'\n') )+ > ; ~ is a set operation; at the lexer level, you can only use single c

[il-antlr-interest: 26190] Re: [antlr-interest] Lexer for a grammar similar to a template engine

2009-10-11 Thread Gavin Lambert
At 23:43 11/10/2009, Graham Wideman wrote: >First off, your OTHER rule should contain OR not AND if you want to >accept '$' or '{' when they are not part of '${'. > >Other than that, it should be possible to write this without >resorting to an action (semantic predicate), which would allow

[il-antlr-interest: 26184] Re: [antlr-interest] MSBUILD/Vs2008

2009-10-10 Thread Gavin Lambert
At 11:01 10/10/2009, Jim Idle wrote: >Why does everyone think it is such a good idea to configure build >tools with XML? It's a bloody stupid idea. Better XML than something even more obscure and esoteric. XML is much more extensible than, say, a makefile. List: http://www.antlr.org/mailman

[il-antlr-interest: 26173] Re: [antlr-interest] Whitespace question

2009-10-09 Thread Gavin Lambert
At 10:34 10/10/2009, Reid Rivenburgh wrote: >In my particular case, I think it's okay to let a few illegal >constructs through and catch them further down the line. I was >just hoping that I would be able to easily write a tighter >grammar. As Jim Idle is fond of pointing out, it's often bet

[il-antlr-interest: 26149] Re: [antlr-interest] MSBUILD/Vs2008

2009-10-08 Thread Gavin Lambert
At 12:20 8/10/2009, Sam Harwell wrote: >· Create a working Clean target (which >carries over to Rebuild). For this to work with >source control, I need to make sure that: >o The generated code files are not written to >disk if their contents haven’t changed. >o The same source file

[il-antlr-interest: 26137] Re: [antlr-interest] Unit testing grammar productions and injecting EOF

2009-10-07 Thread Gavin Lambert
At 09:37 6/10/2009, Kaleb Pederson wrote: >After some investigation, I found that the reason for the >failure was that EOF wasn't in the expected follow set, >which makes sense when I'm parsing the whole language. > >As a workaround, I changed my production, adding EOF as an >optional termin

[il-antlr-interest: 26098] Re: [antlr-interest] Out of Memory

2009-10-06 Thread Gavin Lambert
At 12:37 6/10/2009, Kirby Bohling wrote: >Couldn't you do that in the lexer/parser? Just don't match EOF on >the start rule? That you can just have something like: > >parser.game_prefix(); >while (game_or_end_return = parser.game_or_end()) { >// Process game here >// make sure it you did

[il-antlr-interest: 26096] Re: [antlr-interest] [c target] debugging using antlrworks

2009-10-05 Thread Gavin Lambert
At 10:48 5/10/2009, =?koi8-r?B?4NLV28vJziDtycjBycw=?= wrote: >I used your grammar (with small modification). the same result... Don't forget to use Reply All to keep replies on-list... >1) I generate lexer and parser using -debug option. >2) I run my project. It starts to listen antlrworks (

[il-antlr-interest: 26067] Re: [antlr-interest] [c target] debugging using antlrworks

2009-10-03 Thread Gavin Lambert
At 10:48 4/10/2009, =?koi8-r?B?4NLV28vJziDtycjBycw=?= wrote: >I generated parser grammar with -debug option, but nothing works. >I haven't understood how to customize parser init code - there are >no examples. There are examples for the standard C parser init code. Have a look at the downl

[il-antlr-interest: 26042] Re: [antlr-interest] Disambiguating Decimal and Integer '.'

2009-10-01 Thread Gavin Lambert
At 08:12 2/10/2009, Kaleb Pederson wrote: >INTEGER >: NUMBER+; > >DECIMAL >: INTEGER '.' INTEGER; You should have a look at the wiki and the mailing list archives. This is a fairly common problem with a fairly simple solution: fragment INTEGER : NUMBER+ ; DECIMAL : INTEG

[il-antlr-interest: 26040] Re: [antlr-interest] Left factor? Syntactic predicates? Or another solution?

2009-10-01 Thread Gavin Lambert
At 01:24 2/10/2009, Naveen Chawla wrote: >Thanks so much! Yes, I tried complement: object object? >coincidentally just before I read your message and it worked. >Good news is that in the real grammar they ARE actually >equivalent. But is there no way of making 'indirectObject' and >'object' ap

[il-antlr-interest: 26032] Re: [antlr-interest] Left factor? Syntactic predicates? Or another solution?

2009-10-01 Thread Gavin Lambert
At 23:13 1/10/2009, Naveen Chawla wrote: > complement: indirectObject? object; > > indirectObject : nounPhrase; > > object : nounPhrase; > > nounPhrase : 'the' adjectivePhrase? 'noun'; > > adjectivePhrase : '' complement?; > >gives > >"error(211): predicate.g:7:14: [f

[il-antlr-interest: 25952] Re: [antlr-interest] how to get the value of an identifier

2009-09-26 Thread Gavin Lambert
At 03:51 27/09/2009, Thierry USO wrote: >procedure_name >: IDENTIFIER >; > >IDENTIFIER >: LETTER (LETTER|_|DIGIT)+ >; > >- > >How can I get the value of procedure_name and print it (screen or >file) ? Adding {System.out.print($IDENTIFIER.text);} in the >procedure_name rule does n

[il-antlr-interest: 25904] Re: [antlr-interest] Updates for release 3.2 of the C Target

2009-09-24 Thread Gavin Lambert
At 13:05 24/09/2009, Jim Idle wrote: >Some platforms define this to be undefined though. Remember there >are lots if embedded systems that use this. Hence the qualification. >I think it would have been better to define free(NULL) as safe >myself but early Lib C would crash if you did this an

[il-antlr-interest: 25831] Re: [antlr-interest] conditional tree rewrite

2009-09-18 Thread Gavin Lambert
At 00:50 19/09/2009, Marco Trudel wrote: >Or do you only mean in expression trees like the one I mentioned >from "ART_EXPRESSION -> ART_ASSIGNMENT_EXPRESSION -> ... -> >ART_CONSTANT -> 0" for a constant? If so, than that's exactly my >question: how to do the tree rewrite to only get "ART_E

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

2009-09-18 Thread Gavin Lambert
At 19:28 18/09/2009, David Marín Carreño wrote: >OK. I've tried this code, but both ANTLR 3.1.2 and 3.1.3 generate a >faulty tree parser, as they don't declare a "expression" variable >in the corresponding specialStateTransition function. > >I think this is a bug. How can I report it? That

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

2009-09-17 Thread Gavin Lambert
At 04:00 18/09/2009, David Marín Carreño wrote: >^(IF condition ^(THEN statements)) | >^(IFELSE condition ^(THEN then_s=statements) ^(ELSE >else_s=statements)) > >I don't know how to skip THEN statements when the condition is >false. I am trying the following: > >conditionalifthen: > ^(

[il-antlr-interest: 25770] Re: [antlr-interest] ANTLR on Microsoft's Compact Framework?

2009-09-15 Thread Gavin Lambert
At 08:46 16/09/2009, André van der Merwe wrote: >* In Stats.cs: Replace call to Environment.GetCurrentPath with >Asm.GetExecutingAssembly().GetName().CodeBase Assuming you meant Environment.CurrentDirectory: those aren't equivalent. Have you tried using Path.GetFullPath(".") instead? List:

[il-antlr-interest: 25768] Re: [antlr-interest] Empty AST entry stops parsing

2009-09-15 Thread Gavin Lambert
At 01:20 16/09/2009, Kevin Twidle wrote: >line 1:6 no viable alternative at character ' ' >line 1:8 no viable alternative at character ' ' >line 1:11 no viable alternative at character ' ' Those are because you haven't defined any lexer rules that can match whitespace. >tokens{ > BLOCK

[il-antlr-interest: 25759] Re: [antlr-interest] Empty AST entry stops parsing

2009-09-15 Thread Gavin Lambert
At 23:41 15/09/2009, Kevin Twidle wrote: >I have been using my PonderTalk (Smalltalk like) language for a >while now and I have just noticed that leaving a block empty >causes a parser error. This is with ANTLRWorks 1.2.3. I have >refined the grammar to show the point. The problem line is >^(s

[il-antlr-interest: 25755] Re: [antlr-interest] Error running Graphviz Dot - CreateProcessError=5 access is denied

2009-09-15 Thread Gavin Lambert
At 18:07 15/09/2009, avidan efody wrote: >I'm trying to run Graphviz dot from Antlr on Windows Vista, and I >get the following error: > >java.io.IOException: Cannot run program ""C:\Program >Files\Graphviz2.24\bin"": CreateProcesserror=5, Access is denied Have you tried adding dot.exe to th

[il-antlr-interest: 25733] Re: [antlr-interest] ANTLRWorks interpreter issue

2009-09-13 Thread Gavin Lambert
At 02:30 14/09/2009, Eugene Toder wrote: >I've found an issue with interpreter where it doesn't consume the >second alternative in (a | b)* expression. In a simple example >this leads to incomplete parse tree, in more complex cases this >leads to NoViableAltException. >In all cases the gramm

[il-antlr-interest: 25698] Re: [antlr-interest] Looking for reference to how ANTLR performs Lexing....

2009-09-10 Thread Gavin Lambert
At 06:02 11/09/2009, Sylvain, Gregory [USA] wrote: >I have a bunch of questions about how ANTLR (v3) is lexing it's >input stream. I am continually chasing bugs about how ANTLR >lexed some text as one token when I was expecting it to Lex it as >another token. > >I've checked out this list and

[il-antlr-interest: 25645] Re: [antlr-interest] Matching fragments

2009-09-07 Thread Gavin Lambert
At 05:31 8/09/2009, Sam Barnett-Cormack wrote: >However, the rules I'll pass them to won't match EOF. > >It strikes me that all I need to do is make the token stream >wrapper *not* return an EOF. However, the docs seem to specify >that it *should* return an EOF. How, practically or ideally,

[il-antlr-interest: 25517] Re: [antlr-interest] newbie greedy option question

2009-08-28 Thread Gavin Lambert
At 20:42 28/08/2009, stephane richard wrote: >text_element > : (~(OPEN_TAG) | WS)+ > ; [...] >NEWLINE : '\r'? '\n' ; >WS: (' '|'\t'|'\n'|'\r')+ {skip();} ; Given that you are skipping whitespace (although not individual newlines for some bizarre r

[il-antlr-interest: 25496] Re: [antlr-interest] what's in a name?

2009-08-27 Thread Gavin Lambert
At 06:44 28/08/2009, Terence Parr wrote: >Hi, so we're going back and forth on titles/subtitles for the new >book on implementing DSLs and other languages. Now, we're >"Language Design Patterns", where Design is an adjective of >Patterns; Language is not an adj of Design. it's ambiguous >t

[il-antlr-interest: 25463] Re: [antlr-interest] Tokens that span across char streams

2009-08-26 Thread Gavin Lambert
At 07:57 27/08/2009, Stanislav Sokorac wrote: >I have a language that allows macros to be used just about >anywhere, which makes things a bit difficult. For example, a >macro could define half a string, and something like this is >legal: > >#define FOO "start of a string >String a = FOO end of

[il-antlr-interest: 25461] Re: [antlr-interest] misunderstanding channel HIDDEN

2009-08-26 Thread Gavin Lambert
At 06:13 27/08/2009, Ian Eyberg wrote: >I have text that looks like: > > 'b...@l^@a...@h^@' > >(most of the time the text is simply 'blah') >and then it should come out like this: > > 'blah' [...] > UCODE : '\u'{ $channel = HIDDEN; }; > >I'm reading in through antlrinputstream

[il-antlr-interest: 25462] Re: [antlr-interest] Recognizing 5-th hex digit

2009-08-26 Thread Gavin Lambert
At 07:35 27/08/2009, Kieran Beltran wrote: >I have encountered a problem when attempting to recognize two >required Standard Z symbols which are "above" the four-hex set >recognized by my generated lexer. The two symbols are \u1D538 and >\u1D53D. [...] >Is the solution to include a fifth digit

[il-antlr-interest: 25437] Re: [antlr-interest] ANTLR Javadocs

2009-08-25 Thread Gavin Lambert
At 07:31 26/08/2009, David-Sarah Hopwood wrote: >Suppose someone wants their javadoc implementation to include >links into ANTLR classes. They could run javadoc on the full >ANTLR source, or they could just use the "-link " option >of javadoc to point to somewhere on the ANTLR site. The >latt

[il-antlr-interest: 25411] Re: [antlr-interest] 'DOWN' and tokens

2009-08-24 Thread Gavin Lambert
At 21:15 24/08/2009, Safiye Celik wrote: >Yes, the problem was that my parser and tree grammars were not >consistent. And the inconsistency is about the tree of below rule >a: > >a : e (d^ e)* ; >e : b | c! a c! ; > >How would I create the tree of a? I have no idea about dealing >with repetitio

[il-antlr-interest: 25395] Re: [antlr-interest] Strategy for mapping output to line numbers from a tree walker

2009-08-21 Thread Gavin Lambert
At 13:06 22/08/2009, Stanislav Sokorac wrote: >if (VALUE + a > 0) { echo "hi"; } > >where 'VALUE' is a macro that's defined in an include file. Your >lexer substituted VALUE with the defined value (say '1.0'), and >marked the char stream appropriately. Now, your tree walker comes >upon 1.0+a, a

[il-antlr-interest: 25390] Re: [antlr-interest] Strategy for mapping output to line numbers from a tree walker

2009-08-21 Thread Gavin Lambert
At 08:47 22/08/2009, Stanislav Sokorac wrote: >What is the best way to handle this problem when the children of >a node are coming from different CharStreams (include files, >macros, what have you...), and you could expect to have the first >or last token be from another stream? [...] >It seems

[il-antlr-interest: 25380] Re: [antlr-interest] Concatenating child nodes into one

2009-08-21 Thread Gavin Lambert
At 16:27 21/08/2009, Elnur Cabarov wrote: >And when I change literals to lexer rules I get: >The following token definitions can never be matched because >prior tokens match the same input: IMPORT,STATIC Well, as the error message indicates, you need to re-order your lexer rules. In case of am

[il-antlr-interest: 25369] Re: [antlr-interest] .NET Antlr3.Runtime Public Key Changed?

2009-08-20 Thread Gavin Lambert
At 04:47 21/08/2009, Brian J. Sayatovic wrote: >I'm trying to use NHibernate 2.1 and StringTemplate >3.1. NHibernate depends upon Antlr3.Runtime for its HQL query >language. NHibernate 2.1 depends upon Antlr3.Runtime version >3.1.0.39271 public key 3a9cab8f8d22bfb7. meanwhile, >StringTempla

[il-antlr-interest: 25341] Re: [antlr-interest] tree parser syntax

2009-08-19 Thread Gavin Lambert
At 00:59 20/08/2009, Safiye Celik wrote: >I get an error saying "lexer rule INTEGER not allowed in parser". >How would I handle this issue? If I first write "grammar >MyGrammar;" to my .g file and after listing rules and tokens >write "tree grammar MyGrammar;" in order to parsing the tree, I >

[il-antlr-interest: 25334] Re: [antlr-interest] When can .* be used? (was: Matching Last Line in ANTLR)

2009-08-19 Thread Gavin Lambert
At 10:42 19/08/2009, David-Sarah Hopwood wrote: >ENDOFLINE can indeed be simplified to NEWLINE | EOF. > >However, that won't help because it is not the predicate that >causes the problem here; it's the fact that the match immediately >following .* uses the '|' operator. Note that it doesn't

[il-antlr-interest: 25321] Re: [antlr-interest] Matching Last Line in ANTLR?

2009-08-18 Thread Gavin Lambert
At 09:05 19/08/2009, consili...@gmail.com wrote: >For testing I removed the .* and, while there are no errors, it >still doesn't match b. as the token MC_INCORRECT unless there >is a newline after it. [...] >MC_QUESTION : INT ('.'|')') ENDOFLINE; >MC_INCORRECT : LETTER '.' ENDOFLINE; >MC_CO

[il-antlr-interest: 25316] Re: [antlr-interest] Matching Last Line in ANTLR?

2009-08-18 Thread Gavin Lambert
At 08:08 19/08/2009, consili...@gmail.com wrote: >I want to use your solution, however it throws errors about "The >following alternatives can never be matched: 1" for MC_QUESTION >and MC_INCORRECT. Shouldn't the below work? > >MC_QUESTION : INT ('.'|')') .* ENDOFLINE; >MC_INCORRECT : LET

[il-antlr-interest: 25284] Re: [antlr-interest] Problem with ambiguous grammar

2009-08-17 Thread Gavin Lambert
At 20:47 17/08/2009, Thomas Woelfle wrote: >imperative_statement > : imperative_compute_statement > ; > >imperative_statement_list > : imperative_statement+ > ; > >imperative_compute_statement > : COMPUTE^ Identifier+ EQUAL Identifier END_COMPUTE? > ; > >conditional_compute_stat

[il-antlr-interest: 25222] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-14 Thread Gavin Lambert
At 10:12 14/08/2009, consili...@gmail.com wrote: >QuizLexer lexer = new QuizLexer(new ANTLRFileStream(input)); >CommonTokenStream tokens = new CommonTokenStream(lexer); >// prints 0 >System.out.println(tokens.size()); > >So according to this there are no tokens, which would explain the >bl

[il-antlr-interest: 25213] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread Gavin Lambert
At 08:56 14/08/2009, consili...@gmail.com wrote: >Thanks for the tip! I marked the appropriate rules as fragments, >however all the issues in the original post still stand. The >debugger simply generates a Parse Tree of root -> quiz, while >the Interpreter correctly generates the Parse Tree.

[il-antlr-interest: 25210] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread Gavin Lambert
At 07:32 14/08/2009, consili...@gmail.com wrote: >I have a simple grammar for quizzes that doesn't work in the >debugger, although works fine in the interpreter. [...] >LETTER: ('a'..'z'|'A'..'Z'); >INT : '0'..'9'+; >NEWLINE : '\n' '\r'? {skip();}; These rules should

[il-antlr-interest: 25200] Re: [antlr-interest] Tree rewriting: java.lang.RuntimeException more than one node as root

2009-08-13 Thread Gavin Lambert
At 00:59 14/08/2009, Jeroen van Schagen wrote: >I recently started writing an interpreter for the WAEBRIC >language, which is a language for generating XHTML code based on >self defined function blocks. However, I keep getting runtime >exceptions when running my parser. The following program >

[il-antlr-interest: /] Re: [antlr-interest] tree rewrite ambiguous enclosing rule/referenced in production

2009-08-13 Thread Gavin Lambert
At 13:45 13/08/2009, Tim Williams wrote: >For the scopedClause rule below, I'm getting this error(132): >"$scopedClause is ambiguous; rule scopedClause is enclosing rule >and referenced in the production (assuming enclosing rule)" [...] >scopedClause: > LPAREN (scopedClause->scopedCla

[il-antlr-interest: 25113] Re: [antlr-interest] could not even do k=1 for decision xx; reason: timed out

2009-08-08 Thread Gavin Lambert
At 14:08 9/08/2009, Graham Wideman wrote: >The basic issue is what the arguments to -> ^(NEWTOKEN[args] are >expected to be (ie: their types) and where such args can be >obtained from. The arguments must match one of the available implementations of the tree adaptor's create method (with one e

[il-antlr-interest: 25111] Re: [antlr-interest] could not even do k=1 for decision xx; reason: timed out

2009-08-08 Thread Gavin Lambert
At 13:48 9/08/2009, Tomasz Jastrzebski wrote: >I tried replacing: >-> ^($o $addExpr $e) >with: >-> ^(BIN_EXPR[$o.text, $addExpr, $e.tree]>) // >instead of $addExpr.tree >but the tool (at least ver 3.1.1) dooes not allow this - >error(117): missing attribute access on rule scope. Anyway, >$addEx

[il-antlr-interest: 25109] Re: [antlr-interest] could not even do k=1 for decision xx; reason: timed out

2009-08-08 Thread Gavin Lambert
At 06:18 9/08/2009, Tomasz Jastrzebski wrote: >Now I understand that the only reasonable such declaration must >look like: > >multExpr > : primaryExpr (('*' | '/') primaryExpr)* > ; Actually, you *could* use this: multExpr : primaryExpr (('*' | '/') multExpr)? ; The recursion wou

[il-antlr-interest: 25068] Re: [antlr-interest] revised subject: tree matcher problem with validating semantic predicate

2009-08-06 Thread Gavin Lambert
At 09:34 6/08/2009, Tom Smith wrote: >I have narrowed down my problem. The validating semantic >predicate properly throws a FailedPredicateException in >a regular tree grammar, but does not when filter=true. [...] >Am I wrong to expect this? I've never really played with filter=true in tree

[il-antlr-interest: 25005] Re: [antlr-interest] Question about the antlrv3.g

2009-08-03 Thread Gavin Lambert
At 08:46 4/08/2009, Shaoting Cai wrote: >Hello, > >In the latest ANTLRv3.g >(http://fisheye2.atlassian.com/browse/antlr/tool/src/main/antlr3/org/antlr/grammar/v3/ANTLRv3.g?r=5943#l185) >...

[il-antlr-interest: 24993] Re: [antlr-interest] [antlr3c] Posible bug i C runtime generated code (ANTLR v3.1.3 and libantlr3c 3.1.3)

2009-08-03 Thread Gavin Lambert
At 20:38 3/08/2009, Adamic Tomislav wrote: >Using two grammars below, ANTLR generates code that is not >compilable with either C or C++ compiler. Specifically, >generated file "ExampleGrammarEval.c" contains expression >"MyStruct value = NULL;" which is not valid C/C++ (because >value is not

[il-antlr-interest: 24953] Re: [antlr-interest] Parsing quoted phrases and non-quoted keywords

2009-07-31 Thread Gavin Lambert
At 04:31 1/08/2009, Scott Van Wart wrote: >1) When antlr gives me the quoted string, I lose the whitespace >associated with it, which is significant for me only in a quoted >string. "foo bar" becomes <">, , and <">. So if >I'm searching, say, a database, and the amount of whitespace

[il-antlr-interest: 24901] Re: [antlr-interest] rule return value not declared

2009-07-29 Thread Gavin Lambert
At 09:37 29/07/2009, Kendall Shaw wrote: >The result is that the return attribute "list" is not >declared in the resulting parser: [...] >@init { list = new ArrayList(); } >: (t=thingy { list.add($t.name); })+ You should be using $list here. List: http://www.antlr.org/mailman/listin

[il-antlr-interest: 24834] Re: [antlr-interest] specialStateTransition() in Java-generated lexer

2009-07-23 Thread Gavin Lambert
At 09:22 24/07/2009, Kevin J. Cummings wrote: > The only usage of "s" after the "_s = s" assignment, are >assignments to "s" itself, which reflect a value depending >on the if statements inside the switch. If you assigned a >positive value to s, return it. >Otherwise (I assume s is stil

[il-antlr-interest: 24828] Re: [antlr-interest] Language Design Patterns and incremental parsing

2009-07-23 Thread Gavin Lambert
At 05:27 24/07/2009, Andrew Haritonkin wrote: >Interesting... so, the lexer could be hardest part, good to know. >It seems incremental parsing is both, a very complex problem >and not so needed feature. [...] >ANTLR is already good enough and besides I'm not so far to think >about optimizat

[il-antlr-interest: 24823] Re: [antlr-interest] Invalid char literal

2009-07-23 Thread Gavin Lambert
At 16:29 23/07/2009, Bryan S Follins wrote: >Does anyone know what the error "syntax error: invalid char >literal" means? It means that you have something in 'quotes' in your grammar that isn't valid. Most likely, you've put in a Unicode character. ANTLR grammars are currently parsed by ANTL

[il-antlr-interest: 24813] Re: [antlr-interest] wildcard string in grammar

2009-07-22 Thread Gavin Lambert
At 03:06 23/07/2009, Tim Williams wrote: >WILD_STRING: (('a'..'z'|'A'..'Z')* ('*'|'?') >('a'..'z'|'A'..'Z')*)+ > >This generates the warning "Decision can match input >('a'..'z'|'A'..'Z') using multiple alternatives 1,2 disabling >alternative(s) 2." WILD_STRING : ('a'..'z'|'A'..'Z')*

[il-antlr-interest: 24794] Re: [antlr-interest] EarlyExitException Problem

2009-07-21 Thread Gavin Lambert
At 04:58 22/07/2009, Luís Reis wrote: >Hello, I had a grammar written in Antlr 3 and I >am getting EarlyExitExceptions. >This grammar attempts to match things like: > >"[1..3]", "[ 1 .. 3]", "[ 1 .. x ]", "[x..1]", etc. > >However, when provided "[1..3]", it exits with >an EarlyExitException.

[il-antlr-interest: 24773] Re: [antlr-interest] Rule methods are private (CSharp3 target)

2009-07-20 Thread Gavin Lambert
At 01:31 21/07/2009, Elnur Cabarov wrote: >I use Antlr executable by Sam Harwell, but rule methods for >CSharp3 target are private, so I can't call them externally Have you tried putting "public" in front of the rules you want to be callable? (This doesn't make any difference to the Java targ

[il-antlr-interest: 24744] Re: [antlr-interest] Problem coding Antlr grammar for strings

2009-07-19 Thread Gavin Lambert
At 22:39 19/07/2009, Luís Reis wrote: >and that problem still persists... The diagram >on the right of ANTLRWorks' interpreter shows >MismatchedTokenException(-1!=11) -1 means EOF, which means that something is consuming to the end of the file. What happens when you run it through the debugg

[il-antlr-interest: 24737] Re: [antlr-interest] Problem coding Antlr grammar for strings

2009-07-18 Thread Gavin Lambert
At 07:51 19/07/2009, Luís Reis wrote: >STRINGCONST > : ('@"' ( options {greedy=false;} : . )* '"') > //Accepts lots of stuff, including newlines > | ('"' ( > ( > '\\' ('\\' | '"' | 'n' | 't' | OCTALCHAR) > ) | ( > ~('"'|'\\'|LINEBREAK) > ) > )* '"') > ; > >Which ma

[il-antlr-interest: 24728] Re: [antlr-interest] Getting the hang of this

2009-07-17 Thread Gavin Lambert
At 13:39 18/07/2009, Bryan S Follins wrote: >Sometimes I might ask a question, and it make take 24 hours to >get an answer. I can understand that, but it doesn't help the >learning process. When you repost the same question four times within six hours, it tends to annoy people. When that que

[il-antlr-interest: 24706] Re: [antlr-interest] partial tree rewrites

2009-07-16 Thread Gavin Lambert
At 08:30 17/07/2009, Benoit Fouletier wrote: >BTW, should I mark these kind of subrule as fragments? I don't >really get when to use fragment. No, fragment applies only to lexer rules (with an initial capital); it makes them non-toplevel rules. To put it another way, every lexer rule that doe

[il-antlr-interest: 24704] Re: [antlr-interest] Reg Multi-line comments

2009-07-16 Thread Gavin Lambert
At 00:34 17/07/2009, Michael wrote: >> MLB : '/*' ( options { greedy = false; } : .* ) >> ( '*/' | { print error message } >> { skip(); } >> ; >> >> You might need EOF rather just empty alt. > >I tried that too and it gives an error: The problem here is that with the end text potentially

[il-antlr-interest: 24703] Re: [antlr-interest] partial tree rewrites

2009-07-16 Thread Gavin Lambert
At 02:10 17/07/2009, Benoit Fouletier wrote: >(VAR ID -> VAR ID) >( >ASSIGN INT >->COLON TYPE["int"] ASSIGN INT >|ASSIGN StringValue >->COLON TYPE["string"] ASSIGN StringValue >) > >Do I have the syntax wrong, or are partial rewrites simply not >possible? A rewrite always sets the output of the

[il-antlr-interest: 24683] Re: [antlr-interest] forcing parenthesis (no precedence)

2009-07-16 Thread Gavin Lambert
At 18:57 16/07/2009, hakan eryargi wrote: >thank you but i can't get it. simply making AND's and OR's have >same precedence doesnt force user to use parenthesizes. >expression is simply evaluated from left to right ? Just parse it as normal, but put some code into the tree parser to detect ca

[il-antlr-interest: 24634] Re: [antlr-interest] Composite grammars and "no start rule" warning

2009-07-13 Thread Gavin Lambert
At 05:33 14/07/2009, Peterson, Joe wrote: >I've had to make a change to my grammar recently that requires me >to use a rule in a file that I use elsewhere. The rule is in a >separate file and I want to keep that to make it easier to >maintain. Because I have two locations that I need to use it,

[il-antlr-interest: 24608] Re: [antlr-interest] How to get the inner ${identifier}.text

2009-07-10 Thread Gavin Lambert
At 14:54 11/07/2009, Ha Luong wrote: >q1_1a_bk > (time_phrase)? > { > System.out.println($prep_time.text); > } > '\?'; > >time_phrase > :prep_time time; You can either use a scope or return values for this. Here's an example for using return values: q1_1a_

[il-antlr-interest: 24605] Re: [antlr-interest] Proper handling of newlines with gUnit???? (was: Null Pointer Exception from valid gUnit test)...

2009-07-10 Thread Gavin Lambert
At 08:28 11/07/2009, Sylvain, Gregory [USA] wrote: >I'm suspecting that it may be the way gunit is handling multiple >newlines? The grammar defines a EOL as follows: > >EOL : ( CRCRLF | CRLF | LF ) ; >fragment CRCRLF : '\r\r\n' ; >fragment CRLF : '\r\n' ; >fragment LF : '\n' ; I don't

[il-antlr-interest: 24593] Re: [antlr-interest] Interpreter exceptions?

2009-07-10 Thread Gavin Lambert
At 08:50 10/07/2009, Natan wrote: >STRING >:'"' ( '\"' | ~('"') )* '"'; ANTLR parses backslashes as escape sequences. So you really should be using this instead: STRING : '"' ( '\\' '"' | ~'"' )* '"' ; >I am aware that the debug and interpreter trees are not the same, >and

[il-antlr-interest: 24547] Re: [antlr-interest] operator inside a string

2009-07-08 Thread Gavin Lambert
At 21:31 8/07/2009, Bob Night wrote: >Thanks! That solved my problem. > >But to be honest I still don't understand what causes the change >of behaviour. Maybe you need to read the book :) Or possibly just the wiki. Lexer rules start with an uppercase letter. Parser rules start with a lowerca

[il-antlr-interest: 24537] Re: [antlr-interest] operator inside a string

2009-07-07 Thread Gavin Lambert
At 22:03 7/07/2009, Bob Night wrote: >I have a following grammar. Most of the time it works fine. The >problem begins when I try to parse a string like this one: > >"test_input OPERATOR another_test_input" > >The operator inside quotes is still recognized as a OPERATOR >token, while I'd like it

[il-antlr-interest: 24536] Re: [antlr-interest] parse tree construction after left recursion removal

2009-07-07 Thread Gavin Lambert
At 01:10 8/07/2009, Safiye Celik wrote: >I have a rule and its tree construction such below: >a : b | c! a c! | a d^ a [...] >What should I do to remove left recursion, but also provide the >tree I need? Try this: a : (b | c! a c!) (d^ a)? ; Or this: e : b | c! a c! ; a : e (d^ e)* ; (The re

[il-antlr-interest: 24509] Re: [antlr-interest] Ambiguous grammar or Antlr?

2009-07-03 Thread Gavin Lambert
At 17:47 3/07/2009, Gary R. Van Sickle wrote: >But isn't the whole point of LL(*) to eliminate the need to do >exactly this sort of left-factoring? Section 11.3 of Ter's >book gives essentially the former as an example of why LL(*) >makes it so you don't have to do a manual refactoring such

[il-antlr-interest: 24498] Re: [antlr-interest] Question about preserving spaces in quoted strings

2009-07-02 Thread Gavin Lambert
At 08:14 3/07/2009, Penningroth, Mark wrote: >line 1:7 no viable alternative at input '"[Measures].[Unit >Sales]"' You need to change the grammar at this point to be expecting a DQTEXT instead of whatever it is now, and remove any other double-quote matching from your grammar. Remember that

[il-antlr-interest: 24494] Re: [antlr-interest] Question about preserving spaces in quoted strings

2009-07-02 Thread Gavin Lambert
At 07:27 3/07/2009, Penningroth, Mark wrote: >dqcon > : '"' > ( (~'"')=> > ( ('\\')=>'\\'. > | . > ) > )* > '"'; Like you were already told, this should be a lexer rule: DQTEXT : '"' ('\\' . | ~('\\' | '"'))* '"' ; List: http://www.a

[il-antlr-interest: 24473] Re: [antlr-interest] Collecting disparate subtrees into one tree?

2009-07-01 Thread Gavin Lambert
At 00:06 2/07/2009, jared.bunt...@peachjean.com wrote: >It's been awhile since I've written grammars, but what about: > >code: (proc | func)* > -> ^(CODE ^(PROCS proc*) ^(FUNCS func*)) > >I seem to recall that this works fairly well... And if it doesn't, you can try the more explicit varia

[il-antlr-interest: 24407] Re: [antlr-interest] Look-ahead problem parsing phrase?

2009-06-28 Thread Gavin Lambert
At 09:21 29/06/2009, Sean O'Dell wrote: >Why should lexer rules not refer to other lexer rules without >being fragments? I've read that doing so only prevented token >creation. It affects logic, as well? The moment you have one top-level lexer rule referring to another top-level rule, you in

[il-antlr-interest: 24403] Re: [antlr-interest] Look-ahead problem parsing phrase?

2009-06-28 Thread Gavin Lambert
At 05:54 29/06/2009, Sean O'Dell wrote: > WS : (' '|'\t')+; > DIGIT : ('0'..'9'); > LETTER : ('a'..'z'|'A'..'Z'); > NEWLINE : '\r'? '\n'; > > WORD : (LETTER|DIGIT)+; > > EOL : WS? NEWLINE?; > > PHRASE : WORD (WS WORD)*; > > line : WS? PHRASE EOL?; Turn DIGIT and LE

[il-antlr-interest: 24389] Re: [antlr-interest] Using ANTLR without Java

2009-06-27 Thread Gavin Lambert
At 17:48 27/06/2009, Elnur Cabarov wrote: >I'm writing an application in C# and want to use ANTLR in it >(i.e. user should be able to write own grammars or change >existing ones, compile and run them dynamically) > >But I don't want end-users need both .Net framework and Java. Is >there any way

[il-antlr-interest: 24377] Re: [antlr-interest] 0xcdcdcdcd myth with antlr base tree pointer u

2009-06-26 Thread Gavin Lambert
At 05:24 27/06/2009, Xie, Linlin wrote: >I've noticed that that empty pointers are all (am I right?) >initialized to be 0xcdcdcdcd by default. Looks like it's a >debugging value coming from the C runtime library. I wonder if >you have your reason for this to work this way, or better to >initia

[il-antlr-interest: 24362] Re: [antlr-interest] using ANTLR for IDL compiling/code generation

2009-06-25 Thread Gavin Lambert
At 04:51 25/06/2009, Tim Black wrote: >My main hesitation is that it looks like I am still going to have >to implement a preprocessor of sorts to allow #including other >.idl files. Is there anything like support for this in ANTLR? You mean like this:

[il-antlr-interest: 24351] Re: [antlr-interest] why are these productions different

2009-06-24 Thread Gavin Lambert
At 06:41 25/06/2009, John Tijoe wrote: >WORKING --> expr: multExpr ((PLUS | MINUS ) multExpr)*; > >NOT WORKING --> expr: multExpr PLUS multExpr > | multExpr MINUS multExpr > | multExpr > ; ANTLR is an LL parser; you must always keep the left-side of a rule (or rule fragment)

[il-antlr-interest: 24323] Re: [antlr-interest] Eclipse plugins

2009-06-23 Thread Gavin Lambert
At 05:40 24/06/2009, Edgar Espina wrote: >You can't access to the update site from a web browser. The >update site is only accessible from the Eclipse update mechanism. Shouldn't it produce a page explaining that (and where to configure it in Eclipse, if that's necessary), rather than just spe

[il-antlr-interest: 24208] Re: [antlr-interest] Q: Advice on localizing lexer

2009-06-14 Thread Gavin Lambert
At 17:12 14/06/2009, C. Mundi wrote: >This turns out to be very naive, and I see this getting ugly >fast. Already I have to localize the DSL keywords so there's no >way around writing multiple lexers. So far I have only two >languages: English and Japanese. But if this catches on, other >us

[il-antlr-interest: 23925] Re: [antlr-interest] How do you structure a two-part lexer?

2009-05-29 Thread Gavin Lambert
At 08:18 30/05/2009, Steve Cooper wrote: >script: html ('' html)*; > >The problem is that one language will have very different token >sets; while html might have tokens like LT, GT, and TAGNAME, >php will have ID, SEMICOLON, etc. > >So should I go for a single lexer? Two lexers feeding

[il-antlr-interest: 23905] Re: [antlr-interest] Unnecessary Java output file diffs

2009-05-27 Thread Gavin Lambert
At 04:55 28/05/2009, Jim Idle wrote: >The idea is that a token is defined as specific type, but can >also exist as another type at the same time. So, if the parser >needs to know if there is an ID, the code generated asks if the >token is a real ID OR has a superimposed ID and so reduces all >

[il-antlr-interest: 23877] Re: [antlr-interest] Hello All--Problems with ANTLR Works

2009-05-24 Thread Gavin Lambert
At 06:36 25/05/2009, Bryan S Follins wrote: >Yes, >Tried shutting down the system and starting again today. Generate >went fine. >But the Debug gave me this: > >Java io Exception: Cannot run "javac"; CreateProcess error=2; The >system cannot find the file specified. Then the path to the

[il-antlr-interest: 23876] Re: [antlr-interest] Hello All--Problems with ANTLR Works

2009-05-24 Thread Gavin Lambert
At 19:18 24/05/2009, Bryan S Follins wrote: >When I tried to do the first debug I got the error below: Cannot >launch the debugger. Time-out waiting to connect the remote >parser. Are you using Debug or Debug Remote? Debug will run the parser in debug mode directly. Debug Remote will try to

[il-antlr-interest: 23852] Re: [antlr-interest] Rewrite a list to a set of trees

2009-05-22 Thread Gavin Lambert
At 17:58 22/05/2009, Gary R. Van Sickle wrote: >var_decl_list > : TYPENAME ids+=IDENTIFIER (',' ids+=IDENTIFIER)* -> ^(VAR_DECL >TYPENAME IDENTIFIER)+ > ; > >If your rule can't be reduced to a one-liner like that though (e.g. >C declarations), things quickly get complicated, and

[il-antlr-interest: 23634] Re: [antlr-interest] AST rewrite bug C# target

2009-05-09 Thread Gavin Lambert
At 20:55 9/05/2009, Floris van Nee wrote: >There's one more error left though, in rules like: >type_qualifier returns [List ids] >:v=VOID >{ >$ids = new List() { "System", "Void" }; >} >|qual=qualifier >{ >$ids = qual; >} >; > >Here I want to assign the value of qual (which should be of type >Lis

[il-antlr-interest: 23628] Re: [antlr-interest] Stripping Tokens, Skipping leading text

2009-05-08 Thread Gavin Lambert
At 11:33 9/05/2009, Christian Schladetsch wrote: >My attempts so far have failed: > > CODE_BLOCK: '[[' (options{greedy=false;}:.)* ']]' ; > >This correctly parses the entire token, but the token value in >the lexer contains the enclosing delimiters '[[' and ']]' CODE_BLOCK: '[[' .* ']]' { se

[il-antlr-interest: 23592] Re: [antlr-interest] NoViableAltException

2009-05-07 Thread Gavin Lambert
At 09:13 8/05/2009, Bill Steer wrote: >REGISTER = avg(REGISTER, REGISTER, REGISTER); > >where REGISTER is just a multi-part identifier, with the parts >separated by an '!'. The lexer seems to work ok, judging by >the Tokens it returns in another part of my code. But, at >runtime, the parse

[il-antlr-interest: 23554] Re: [antlr-interest] Mutual left recursion rmoval help!!

2009-05-06 Thread Gavin Lambert
At 08:45 7/05/2009, babak.teymo...@noos.fr wrote: >[22:21:26] error(210): The following sets of rules are mutually >left-recursive [value_expression_primary] >[22:21:26] Aborting because the following rules are mutually >left-recursive: > [[T.value_expression_primary,index=2,line=16]] [...]

[il-antlr-interest: 23553] Re: [antlr-interest] Skip subtree in tree grammar

2009-05-06 Thread Gavin Lambert
At 06:54 7/05/2009, Martijn Reuvers wrote: >Does the | .* option not say accept everything until the end of the >if statement, irrelevant of what it is? In theory yes, but as I said earlier there's a quirk in older versions that makes it refuse to match subtrees properly. You need to use th

  1   2   3   4   >