I guess this article might help you:
http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
It has a good test rig.
Cheers, Indhu
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Indhu Bharathi
Sent: Tuesday, November 03, 2009 3
Moving this to antlr-interest.
What you do after that depends on what you want. Have you constructed an AST
in the grammar? Then to get the AST, you have to do this:
CommonTree t = (CommonTree)r.getTree();
And if you want to give this tree to a tree walker, you can do this:
// creat
Use scope variables to remember what you saw in a rule and emit it in
another rule further down in the chain. This will create the tree you want.
But I feel 'TYPE' node is not needed. It is good to build your AST as terse
as possible.
grammar Test;
options {
output=AST;
}
r where it doesn't work and also the
input you tried?
Cheers, Indhu
S7 Software
-Original Message-
From: Frank Du [mailto:frank...@riskmetrics.com]
Sent: Friday, October 30, 2009 10:38 PM
To: Indhu Bharathi; antlr-inter...@antlr.org
Subject: RE: [antlr-interest] Please help with a gramm
Maybe you can use validating semantic predicate
r
@init {
int cntA=0, cntB=0, cntC=0;
}
: ( a {cntA++;} | b {cntB++;} | c {cntC++;} )+
{cntA>1 && cntB<=1 && cntC==1}?
;
Cheers, Indhu
S7 Software
From:
Section 9.6 of ANTLR definitive reference (Building a Java Bytecode
Generator Using a Tree Grammar and Templates) does this.
The free code samples are available at
http://media.pragprog.com/titles/tpantlr/code/tpantlr-code.tgz
Samples for this specific section is available at 'Code/templat
Sustem.out.println will print in the output tab.
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla
Sent: Friday, October 16, 2009 4:21 PM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] How do I output an alert box or something in
uire hacks of this kind are very rare and arises only while
parsing some very obscure languages.
Cheers, Indhu
From: Naveen Chawla [mailto:naveen.c...@googlemail.com]
Sent: Wednesday, October 14, 2009 11:38 PM
To: Indhu Bharathi
Cc: Jim Idle; antlr-inter...@antlr.org
Subject: Re: [ant
The other say I replied from my ipod and was not able to test it with ANTLR.
I checked it now and the code doesn't work for me too. However you can try a
variant:
q : a ((b)=>NOWAY | /*nothing*/)
;
fragment NOWAY
: ;
Doesn’t a simple approach like the one shown below work?
r : ASSIGNMENTOP | KEYWORDMARKER
;
ASSIGNMENTOP : ':=' ;
KEYWORDMARKER : ':' ;
I assume you wa
Prefer using debugger instead of interpreter. Interpreter doesn't work as
expected sometimes (when you are using semantic predicates).
That said, for this particular case it seems to works fine.
r : STRING
;
STRING
: '"' (
u are trying to match? Why are you using 'fragment'?
Cheers, Indhu
-Original Message-
From: Espák Miklós [mailto:esp...@gmail.com]
Sent: Tuesday, October 13, 2009 11:11 PM
To: Indhu Bharathi
Cc: antlr-inter...@antlr.org
Subject: Re: [antlr-interest] accepting nested code blocks
function by some special token to allow catching it by a
lexer rule?
Cheers,
Miklos
2009/10/13 Indhu Bharathi :
> Balanced parenthesis cannot be expressed using regular expression which
> means you cannot recognize it using lexer. You need a push down automata
> which means you need a par
Balanced parenthesis cannot be expressed using regular expression which
means you cannot recognize it using lexer. You need a push down automata
which means you need a parser to recognize it. Try doing it using parser
rules.
Cheers, Indhu
From: antlr-interest-boun...@antlr.org
[mailto:an
http://www.antlr.org/share/list has bison to ANTLR converter. I guess this
should work fine for YACC grammars.
Cheers, Indhu
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of postmaster
Sent: Tuesday, October 13, 2009 8:44 P
AFAIK, there is no shortcut.
You will have to write something like
HELLO : ( ('H'|'h') ('E'|'e') ('L'|'l') ('L'|'l') ('O'|'o') )
;
You can make it more readable using fragments.
HELLO : H E L L O
fragment H: ('H'|'h')
fragment E: ('E'|'e')
fragment L: ('L'|'l')
fragment O:
our problem, I’m not sure if this is an
elegant way of fixing this problem. I would vote for parser checking only
the syntax and the symantics handled by tree walkers. You can establish the
relation between messages while tree walking.
Cheers,
Indhu Bharathi
<http://www.s7software.co
Can you post a small sample where the problem exists?
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Martin Potier
Sent: Monday, October 12, 2009 5:44 PM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] [LEXER] U
Refer 'composite grammar' from wiki.
http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars
Cheers,
Indhu Bharathi
<http://www.s7software.com/> S7 Software Solutions
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Beha
Try something like
r : lbl=searchTerm ({spaceFollows($lbl.stop)}?=> lbl=searchTerm)*
;
@members {
public boolean spaceFollows(Token tkn) {
return input.get(tkn.getTokenIndex()+1).getType()==WS;
}
}
Cheers,
Indhu Bharathi
&l
In that case you have to use syntactic predicate.
Cheers, Indhu
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla
Sent: Wednesday, October 07, 2009 4:33 AM
To: antlr-inter...@antlr.org
Subject: Re: [antlr-interest] Help writing a par
ANTLRWORKS already has this feature. Compile your grammar in ANTLRWORKS.
When there is an ambiguity, the rule will be marked in red and you can check
the "Syntax diagram" tab to graphically see the ambiguity.
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On
Try something like:
(a)=> ((b)=>/*nothing*/ | a)
I remember facing similar problem. I guess you can't use '~' in a syntactic
predicate.
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla
Sent: Monday, October 05, 2009 7:32 PM
T
Is it possible to write a separate program to break the PGN files into
separate games and pass each game to the lexer/parser? That will be a simple
solution assuming there is an easy way to split games in a PGN file.
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr
Try the tool 'strip'. It comes with ANTLR.
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Jonathan Claggett
Sent: Tuesday, September 29, 2009 3:41 AM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] StringTemplate to generate Grammar docs?
I don't think if any tool exists to do it automatically. But the generator
adds the grammar also as comments into the generated lexer/parser. You can
manually go through it and recover the grammar.
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@a
'!' is a rewrite operator used in tree construction. Since lexer doesn't
construction a tree, I don't think this will work.
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Gordon Tyler
Sent: Thursday, September 24, 2009 6:5
You can do something like
ID : LETTER (LETTER|DIGIT)*
{
String text = getText();
Integer tknType;
if( (tknType=table.get(text))!=null ) {
$type = tknType;
}
}
The table can be passed to t
Check if you are creating the lexer/parser under the right
directories. Look like the files are getting generated at root level
in source tree.
On Sep 19, 2009, at 9:28 AM, Sailesh Kandula wrote:
> While building my first ANTLR project SimpleCalc.g i ran into the
> error:
>
> The declare
Try using semantic predicates to look-ahead and decide whether to emit
SLCOMMENT or TEMPLATE
Something like:
fragment SLCOMMENT
: ;
fragment TEMPLATE
: ;
SLCOMMENT_OR_TEMPLATE
: '//' (
A related mail from archive:
you mean a parse tree, not AST, right? There is a ParseTreeBuilder i think.
T
On Sep 1, 2009, at 12:50 PM, Stefan Groschupf wrote:
> Hi,
> I'm making my first baby with antlr.
> Is there any chance to get a AST exactly as antlr work is generating
> wit
dissemination) by persons other than the
intended
recipient(s) is prohibited. If you receive this e-mail in error, please
notify the sender by
phone or email immediately and delete it!
_
From: Indhu Bharathi [mailto:indh...@s7software.com]
Sent: Thursday, September 10, 2009 10:37 PM
T
Yes, backtracking will affect performance. If you are concerned about
performance, don't use backtrack and try left factoring your grammar
instead.
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Bharath R
Sent: Thursday, September 10, 2009 5:25 PM
I guess you can do it with composite grammars.
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Martin Potier
Sent: Wednesday, September 09, 2009 7:10 PM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] Grammar inclusio
What exactly is the error message you get?
On Sep 4, 2009, at 12:57 PM, Klaus Martinschitz wrote:
> Hi!
>
> I already looked around in the internet and do not find any answer to
> solve following problem. I downloaded the newest antlr works version
> 1.2.3 were antlr and antlr works are bundle
Maybe you can use a setter to set what 'ifKeyword' is and use that in a
semantic predicate.
Something like:
@members {
String ifKeyword;
Public void setIfKeyword(String str) {
this.ifKeyword = str;
}
}
ifKeyword
: { LT(1).getText().equals(i
As stated in the link you provided, there is nothing you have to do to get
this functionality. But 'identifier' should be a lexer rule. I guess your
grammar should be something like this:
APPLY : 'apply';
BROWSE : 'browse'
.
ID
ANTLRWORKS accepts tab in input box without any problem. The version I'm
using is 1.2.3
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Dukie Banderjee
Sent: Tuesday, June 09, 2009 12:45 AM
To: antlr-inter...@antlr.org
Subj
SL_COMMENT_2
: '--' (options {greedy=false;} : . )* '\n' {$channel=HIDDEN;}
{
setText( "//" + getText().substring(2) );
}
;
Should work.
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org]
I don't get any exception. BTW, it is good to match the entire 'phrase' as
one token in the lexical analysis itself. Something like:
PHRASE :( '0'..'9' | 'A'..'Z' | ' ' | '\t')+ ;
and modify stmt to:
stmt :SUBJ_TOK COLON PHRASE NL+ ;
Else, you'll end up creating too man
STRING
: '"' ( options {greedy=false;} : . )* '"'
;
Greedy is turned off so that .* doesn't consume the terminating '"' also.
Cheers, Indhu
-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Xiaohua Guo
Sent: Thursday, June 0
By default error recovery is turned on and ANTLR will try to recover from
syntax errors. However it will print error message on stderr.
If you need error recovery to be turned off and throw an exception at the
first sight of an error, you need to override 'recoverFromMismatchedToken'
as shown in
That is an expected behavior. Seeing ' C' the lexer decides to go for 'CORP'
token instead of OTHER(space) and WORD. You need to do some left factoring
there. Or you can modify your grammar to avoid such problems. Here is a
suggested correction:
grammar Test ;
test1 : NUMBER CORP data {System.ou
For your second and third question, solution is to use 'composite grammar'.
You'll be able to extend the existing grammar file. You can also form a
grammar by combining multiple .g files. One file might contain the lexer and
the parser itself could be spread across multiple grammar files. There is
Overwride the emit method and check 'getCharPositionInLine' for the tokens
emited. If the value is zero emit an additional BOL token. This will take
care of beginning of file too.
Something like this:
java.util.LinkedList tokenQueue = new java.util.LinkedList();
public void emit(Token token)
Ah, forgot. Things changed after the book was written. I guess you have to
override the following two methods from BaseRecognizer
void recover (IntStream input, RecognitionException re)
Object recoverFromMismatchedSet (IntStream input, RecognitionException e,
BitSet follow) throws RecognitionE
Two methods of parser (mismatch and recoverFromMismatchedSet) are responsible
for auto-recovery and showing error messages.
If you want to throw an exception and exit right on the first error you need to
override these methods and just throw the exception instead of handling it.
Something like
You get the error because 'SELECT' will match everything in the input
till EOF greedily (because of .+) and obviously WS cannot match
anything. When you use .+, you have to turn off greedy. Try something
like:
TEXT : SELECT ( options {greedy=false;} : . )* FROM
This should work:
This is because on seeing 'f' of foo lexer has two options - 1. IDENT
2. URL. And it takes the second options since that seems to be longer
that the first alternative. Note that the lexer always tries to match
the longest token possible.
After having decided to go for URL, it matches the inpu
Looks like you are parsing with empty input. What is the input you gave
to the parser?
Cheers, Indhu
Marwan Ajraoui wrote:
> Hi there;
>
> I'm getting a strange error form a parser. I have defined a grammar,
> wich contains these rules;
>
>
> decl_codigo : decl_libreria decl_program
>
> decl_l
Looks like a lot of work that has to be done in the lexer is getting
done in the parser. I would prefer tokenizing '[%"Dear "%]' as a
separate token and similarly '[% name %]' as a separate token.
Simple substring, trim operations can get you the actual block and
string content later.
Here i
Did you evaluate the option of making semicolon a default token itself instead
of hidden token? Unless there is compelling reason to make semicolon hidden
token, let's make it default token. That will make the work easy.
Now assuming there is some compelling reason to make semicolon hidden toke
It is true that the parser can 'tune' to any channel. But you can't do
it while parsing. The channel should be set before parsing begins.
If you want to see the off channel token while parsing, you can use LA(
int ) and LT( int ) within the parser.
For your example, you can write something li
Order doesn't matter. ANTLR will match the longest possible token.
One case when order matters is when the rule below cannot match any
token inspite of the 'lengthiest token matching' mechanism.
Example:
ID : 'a'..''z'+ ;
SOME_KEYWORD : 'key' ;
In this case ANTLR will report an err
This is expected behavior only. It is designed this way so that user can
filter for a particular channel if needed. For your task, you can use
getTokens() method which will return a List of tokens that can be iterated.
Cheers, Indhu
Chris Lambrou wrote:
> Yesterday I was stung by some odd behav
how would I pass the whole expression to
> "expression"?
>
> Thanks
> Des
>
>
>
> 2009/4/10 Indhu Bharathi <mailto:indh...@s7software.com>>
>
> Well, in that case the second solution that uses syntactic
> predicate should work.
>
>
gt; being entered, so I have to accomodate it.
>
> I have a rough solution which is to Pre-parse the text and then change
> the text to "=-5+4" and then pass the new text to the second parser,
> but I was wondering if there is a more elegant solution
>
> Than
Curious. Why not change formula production to
formula
: EQ expression
| expression
;
If for some reason you want to enforce that the input has to start with PLUS
or MINUS then maybe you can rewrite formula production as
formula
: EQ expression
| (PLUS | MINUS)=> expression
;
Thi
WS: (' ' | '\n' | '\r' )+ {$channel=HIDDEN};
This should give you compile error. There must be a ';' immediately
after 'HIDDEN'. ( {$channel=HIDDEN;} )
Are you using tab instead of space in input?
David Cournapeau wrote:
> Hi,
>
> I have started using antlr to catch up my lack of knowledge in
Use '@members' to store 'global' variables.
like
@members{
int cnt;
}
and increase 'cnt' in 'species' production, like
species
: ret=atom NUMBER?
{
cnt += $ret.weight * Integer.parseInt($NUMBER.text)
}
;
and print out the sum in file production, like
file
At 03:12 9/04/2009, Indhu Bharathi wrote:
>> INT_FLOAT_PATTERN
>> :(NUMBER DOT NUMBER LETTER ) => NUMBER DOT NUMBER LETTER
>> { $type=PATTERN; }
>>
>> |( NUMBER DOT NUMBER ) => NUMBER DOT NUMBER
>> { $type=FLOAT_LIT; }
LIT; }
;
DOT:'.'
;
fragment PATTERN
:;
fragment FLOAT_LIT
:;
fragment INT_LIT
:;
fragment
NUMBER:('0'..'9')+
;
fragment
LETTER:'a'..'z'
;
Thanks, Indhu
Jim Idle
Hi,
Any clue why this doesn't work? I'm still clueless.
- Indhu
Indhu Bharathi wrote:
> I was working in a big grammar and stumbled on a problem with
> predicates. I've simplified the problem as much as possible and here it is:
>
> When I give the input "1.&
I was working in a big grammar and stumbled on a problem with
predicates. I've simplified the problem as much as possible and here it is:
When I give the input "1.", I expect the tokens . But what
I get is "No viable alternative at character 'EOF'. I'm not able to
understand why this happens.
'expression' is rule 'r' wont return a Token since it is not a lexer rule. It
will instead return 'ParserRuleReturnScope' since it is a parser rule. So
'$expression.stop' or '$t.stop' will give you the last token of 'expr'. You can
use it like shown below:
r : t=expression { newLineBeforeNextT
l pass whereas "foo" will fail :-)
I casted input to 'DebugTokenStream' since I was running inside
ANTLRWorks. You can cast it to CommonTokenStream.
Cheers, Indhu
Indhu Bharathi wrote:
>
> I don't have ANTLR right now to test this. But guess it would
I don't have ANTLR right now to test this. But guess it would work
NEWLINE: '\r'?'\n' {$channel = HIDDEN;};
Then write expression_statement rule like this:
expression_statement
:expression { NewLineBeforeNextToken( input.LT(1) ) }?=> /*nothing*/
;
And in the @
n Behalf Of Indhu Bharathi
Sent: Thursday, April 02, 2009 10:58 PM
To: antlr-interest
Subject: [antlr-interest] Composite grammar and memoize
Hi,
It looks like memoize at rule level doesn't work in composite grammar. I
get the error message '! memo array is null for ParserPart.g&
Hi,
It looks like memoize at rule level doesn't work in composite grammar. I
get the error message '! memo array is null for ParserPart.g'.
'state.ruleMemo' is always null.
Also, it looks like this is a known issue. Has this been fixed or is
there a workaround?
I tried turning on mem
Take a look at 'filter' mode of ANTLR lexer. This will let you skip text
you are not interested in.
Posting a more specific example of what you need might help.
Peter Bertok wrote:
>
>
>
> I'm working on a trivial embedded "wiki" style content management
> system for a web project, and I'm tr
How about something like this?
r:(ID EQ)+ INTLIT SEMICOLON -> ^(ASSIGN ID INTLIT)+
;
So, for your example, this will create two subtrees with ASSIGN as root.
The tree generated will be ^(nil ^(ASSIGN Odd 0) ^(ASSIGN Even 0))
And then you can write string template in the tree walker
Jim Idle wrote:
> Andreas Meyer wrote:
>> David Jameson schrieb:
>>
>>> I have the following grammar fragment
>>>
>>> refTag :
>>> LSQUARE a=expression (COMMA b=expression)? RSQUARE
>>> {
>>> //stuff
>>>
>>> } ->
Can 'dfa.predict' throw 'no viable alternative' exception? I'm facing
this strange problem and wondering what could be the reason. Any pointers?
Thanks, Indhu
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email
Are you sure 'tokens' is the TokenRewriteStream? Generally in the
generated code the member variable 'input' is the token stream. Maybe
you have to write 'input.replace($m.start, $m.stop, "something else");'
unless you have done something to change the name of the token stream.
Also note that 'inp
Maybe 'm=variableDeclaration' didn't match anything in the input...
YINGAnnie wrote:
>
>
> Sorry ,Iforgot to mention, Icorrected $m.end.
>
> Now, I am using {tokens.replace($m.start, $m.stop, "something else");}
>
> but I got java.lang.NullPointerException error.
>
> It seems $m is null.
>
>
> An
There was a typo in my mail. It is $m.stop and not $m.end. Sorry :-)
And here is the documentation:
http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_parser_rule_return_scope.html
:-)
YINGAnnie wrote:
>
>
> Well, I tried it,but this timethe error is :
> java.lang.NullPointerExceptio
This will work:
variableStatement
: VAR? variableDeclaration ( COMMA m=variableDeclaration )* semic
{tokens.replace($m.start, $m.end, "something else");} &n bsp;
;
$m will be of type variableDeclaration_return which will be subclass of
'ParserRuleReturnScope'. $m is not Token.
- Indhu
YINGAnn
a function called "function" in the namespace that has
> the prefix "declare". This function takes the parameter "declare" of
> type XML element having the tag name "declare", and returns also an
> XML element having the tag name "function"
lems you mentioned are eliminated.
>
> As I can see your proposed solution is not scalable if I have the
> keywords: keywordA, keywordB,...,keywordZ, and the Name rules: Name1,
> Name2,..., NameN. Or is it?
>
> Any solution for this?
>
>
> Regards,
> Gabriel
>
>
Looks like you are trying to use keyword as identifier. AFAIK, this
cannot be resolved in the lexer. You have to use predicates in the
parser rule. Something like this:
rule : keyKEYWORD1 (keyKEYWORD2 enc=Name)? ';' ;
keyKEYWORD1
:{input.LT(1).getText().equals("keyword1")}? Name ;
keyK
is not present");
}
}
:attribute+
;
typeAttr:'TYPE' ID ';'
{
$attributes::typeAttrSeen = true;
}
;
- Indhu
Indhu Bharathi wrote:
> Maybe you are looking for something like this:
>
> attributes
>
Maybe you are looking for something like this:
attributes
:attribute+
;
attribute
:typeAttr
|lengthAttr
|pathAttr
;
Here is a complete sample:
grammar Test;
attributes
:attribute+
;
attribu
grammar Test;
expr : (ID {System.out.println( $ID.text );} )*
;
ID : 'a'..'z'+
;
WS : (' ' | '\t' | '\n')+ {$channel = HIDDEN;}
;
- Indhu
william yuan wrote:
> Hi ,
> problem like this ,
> i ve defined a grammar like this
> expr: ID*;
> ID:('a'..'z')*;
> and my input is
> ABC DEF
> so how c
an error state without noticing that a
> different token arrangement would keep it in the green.
>
>
> Mihai
>
> On Tue, Mar 10, 2009 at 3:48 AM, Indhu Bharathi
> mailto:indh...@s7software.com>> wrote:
>
> Try this:
>
> Today: ( (Today_) => '
Hi,
The problem is because ',' or '=' is not defined anywhere in the lexer rule. To
be able to lex an input completely, it is necessary that the lexer grammar must
account for every character that can occur in the input and be able to convert
it into tokens. If you dont want to intoduce these
Hi,
Is it not possible to pass an instance of RuleReturnScope as argument to a
function? With the following sample, I get the error message 'missing attribute
access on rule scope'. Curious to know the reason for this limitation... or am
I missing something? Is there a workaround?
foo : bar1
Try this:
Today: ( (Today_) => 'Today' ) ;
fragment Today_
: 'Today'
;
However, I'm not sure if this's the most elegant way to fix it.
Read the following thread to understand more on why exactly this happens:
http://www.antlr.org/pipermail/antlr-interest/2009-February/032959.html
- Indh
grammar SqlSQL2Parser;
options {
superClass=DmlSQL2Parser;
}
- Indhu
- Original Message -
From: Maciej Gawinecki
To: ANTLR Interest Mailing List
Sent: Tuesday, March 10, 2009 12:29:52 PM GMT+0530 Asia/Calcutta
Subject: [antlr-interest] grammar inheritance
Hi,
Jim Idle said that
%21+Tree+pattern+matching%2C+rewriting+a+reality
. This sounds damn sexy! But has this been released? Does the latest release
(3.1.2) include this?
Thanks, Indhu
- Original Message -
From: Sam Harwell
To: Indhu Bharathi , antlr-inter...@antlr.org
Sent: Thursday, March 5, 2009 8:34:25
Hi,
Is there a way to separate grammar and actions into two different files?
This will be helpful when multiple people are working with the same grammar
file (each might write their own actions for the same production) and don't
want to create redundant copies of the grammar file.
One way I
This sometime happens due to bug in the grammar. Try running debugger with some
very simple grammar. If it works, then the mistake is with the grammar.
- Indhu
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Filipe David Manana
Sent: Sunday, M
Got it. What I missed is the '$' symbol while referencing
I wrote:
r : t=a b a
{
... t.start.getTokenIndex() ...
}
It must have been
r : t=a b a
{
... $t.start.getTokenIndex() ...
}
Thanks :-)
- Original Message -
From: Terence Parr
To: Indhu Bharathi
To: indh...@s7software.com
Cc: antlr-interest
Subject: Re: [antlr-interest] Rewriting in non tree grammar
On Feb 27, 2009, at 12:43 AM, Indhu Bharathi wrote:
> Figured it out :-) Here is a sample grammar that does what is
> required:
>
> grammar Test;
>
> @mem
{
input.insertBefore(pos, "inserted");
}
;
a : 'a'
;
b : 'b'
;
Let me know if there is a better or more elegant way to do this. But I'm fine
with this :-)
Thanks, Indhu
- Original Mes
ind any example out there for this requirement. Can anybody
explain a little more clear. Sorry if there is some simple way to do it and
I'm not getting it.
- Indhu
-Original Message-
From: Terence Parr [mailto:pa...@cs.usfca.edu]
Sent: Friday, February 27, 2009 2:53 AM
To: Indh
Hi,
Suppose I want to do something like this
methodDecl : scope t=returnType ident LRAPEN RPAREN
{
insertBefore(t,
"something");
or
method in your parser with the
exception.
Ter
On Feb 26, 2009, at 8:28 AM, Indhu Bharathi wrote:
> Hi,
>
> I'm attaching a debug listener to my parser and overriding
> 'recognitionException' method as shown below.
>
> public void recognition
>it's no longer possible to alter the content of a token away from what's on
>the input at all.
I'm not sure if this is right. I still do token.setText(...) in my actions and
I'm using ANTLR 3.1.1.
Just a guess... Maybe you have to use TokenRewriteStream instead of the regular
CommonTokenStr
Hi,
I'm attaching a debug listener to my parser and overriding
'recognitionException' method as shown below.
public void recognitionException (RecognitionException e) {
System.err.println(e);
}
But I see that the error message printed is not as good as what is printed in
stderr when the
attribute_type
: 'unsigned long long'
| 'unsigned long'
;
Though you have written 'unsigned long long' and 'unsigned long' in the parser
rule, they will be still considered as lexer rule only.
The lexer after seeing 'unsigned long' will try to go for the bigger match
('unsigned l
1 - 100 of 116 matches
Mail list logo