[il-antlr-interest: 29459] [antlr-interest] converting Java code to C for PHP grammar

2010-07-19 Thread Dinesha Balasuriya Weragama
I am relatively new to ANTLR and am trying to use the PHP grammar that has been used with the ANTLR PHP target.  This grammar handles the first input token separately as a first body string using the following Java Code to override the nextToken() function. @lexer::members{     // Handle the f

[il-antlr-interest: 29458] Re: [antlr-interest] Getting the Previously Matched Lexer Token in the C Target

2010-07-19 Thread John B. Brodie
Greetings! On Mon, 2010-07-19 at 21:00 -0400, Billy O'Neal wrote: > Hello, Kirby Bohling. > > It's similar to Keyword Vs. ID, but not exact. Consider the following inputs: > > -arg#hashed# > Result: > ARGUMENT (Text="arg") > ARGEXTRA (Text="hashed") > > -arg#hashed# #otherData# > Result: > ARGU

[il-antlr-interest: 29457] Re: [antlr-interest] Getting the Previously Matched Lexer Token in the C Target

2010-07-19 Thread Billy O'Neal
Hello, Kirby Bohling. It's similar to Keyword Vs. ID, but not exact. Consider the following inputs: -arg#hashed# Result: ARGUMENT (Text="arg") ARGEXTRA (Text="hashed") -arg#hashed# #otherData# Result: ARGUMENT (Text="arg") ARGEXTRA (Text="hashed") OTHER (Text="#otherdata#") <-- Note that the ha

[il-antlr-interest: 29456] Re: [antlr-interest] Getting the Previously Matched Lexer Token in the C Target

2010-07-19 Thread Kirby Bohling
If you aren't going to lex that token to something else, I'm pretty sure the right solution is to just lex it as the invalid token. If you are going to lex it to something else, then likely you have the "keyword" vs. "id" problem (use one token for it in the lexer, and pick which one it really is

[il-antlr-interest: 0] [antlr-interest] Getting the Previously Matched Lexer Token in the C Target

2010-07-19 Thread Billy O'Neal
Hello, Everyone :) Was referred here from my StackOverflow question: http://stackoverflow.com/questions/3278338/using-the-antlr-c-target-how-can-i-get-the-previously-matched-token-in-the-lexer I'm quite new to ANTLR; and my Lexer needs to have a gated rule which makes it valid if and only if it o

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

2010-07-19 Thread Bill Andersen
Thanks Jay That did it. On Jul 19, 2010, at 15:52 , Junkman wrote: > Hi Bill, > > You have > > import antlr.*; > > instead of > > import org.antlr.runtime.*; > > Maybe that's the problem? > > org.antlr.runtime.CommonToken implements org.antlr.runtime.Token, so > explicit casting seems out

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

2010-07-19 Thread Junkman
Hi Bill, You have import antlr.*; instead of import org.antlr.runtime.*; Maybe that's the problem? org.antlr.runtime.CommonToken implements org.antlr.runtime.Token, so explicit casting seems out of wack. Jay Bill Andersen wrote: > Thanks John > > Below is my class def.. Eclipse tells me

[il-antlr-interest: 0] Re: [antlr-interest] Lex Matching Issues

2010-07-19 Thread Jim Idle
Use the: identifier : KEY1 | KEY2 | ... | ID ; But when you have: r: KEY1 ... | identifier ; You just need a one token predicate and lists the keyword stuff first. r: (KEY!)=>KEY1 ... | identifier ; I have built entire SQL parsers using this approach and SQL is probably the king of amb

[il-antlr-interest: 29454] Re: [antlr-interest] Lex Matching Issues

2010-07-19 Thread Ron Hunter-Duvar
Cid Dennis wrote: > So I am new to ANTLR and have created a grammar but found a strange issue. > Because of the structure of the language I am parsing there can be tokens > that match reserved works as variables but only when they are in a sub rule > that does not use the reserved word. > > ..

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

2010-07-19 Thread Bill Andersen
Thanks John Below is my class def.. Eclipse tells me the casts to Token below are required. Running a grammar that executes these constructors tells me I can't cast to Token. Here's a sample tree building expression where this class is used. ^(AS_TYPE_LIST[s.getType($ID.text)] ID) t

[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 con

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

2010-07-19 Thread Bill Andersen
Hi folks 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 contradictory. For example I find this example static class V extends CommonTre

[il-antlr-interest: 29451] [antlr-interest] Identifying character position (start and end) of tokens

2010-07-19 Thread myersada
Hello, I am using antlr/C# to create a scripting language with a step-through debugger that highlights in yellow the line of code that is about to execute. I was able to identify the line number based on the 'Line' property of my Antlr-generated AST node (Antlr.Runtime.Tree.ITree, Antlr.Runtime.T

[il-antlr-interest: 0] Re: [antlr-interest] Lex Matching Issues

2010-07-19 Thread John B. Brodie
Greetings! On Mon, 2010-07-19 at 09:52 -0600, Cid Dennis wrote: > So I am new to ANTLR and have created a grammar but found a strange issue. > Because of the structure of the language I am parsing there can be tokens > that match reserved works as variables but only when they are in a sub rule

[il-antlr-interest: 29450] [antlr-interest] Lex Matching Issues

2010-07-19 Thread Cid Dennis
So I am new to ANTLR and have created a grammar but found a strange issue. Because of the structure of the language I am parsing there can be tokens that match reserved works as variables but only when they are in a sub rule that does not use the reserved word. In the example below "ruleset" i