[il-antlr-interest: 32412] Re: [antlr-interest] Source code level of ANTLRWorks

2011-05-09 Thread Ben Corne
The path field expects a directory where it can find the javac binary in.

Adding flags behind the directory also fails:
The debugger fails to initialize and leaves some process running in the
background requiring me to kill the process before I can try to run the
debugger again.

Any more thoughts?
Ben

2011/5/5 Jim Idle j...@temporal-wave.com

 Have you tried adding it in with the PATH? Also you can use -source 1.6
 -target jsr14 and use 1.6 input and 1.4 output.

 Jim

  -Original Message-
  From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
  boun...@antlr.org] On Behalf Of Ben Corne
  Sent: Thursday, May 05, 2011 4:58 AM
  To: antlr-interest@antlr.org
  Subject: Re: [antlr-interest] Source code level of ANTLRWorks
 
  Here's a screenshot of my antlrworks preferences page + javac info
  http://igor.rave.org/antlrjavac.png
 
  I don't see the option where to adjust the commandline call.
  And from what I think to understand from the helppage of my javac, it
  says
  1.4 is the default, but I don't find a way to change this default,
  except by writing a wrapper shell script that attaches -source 1.5
  (which is what I will do now, until more clues are given)
 
  Ben
 
  2011/5/4 Jim Idle j...@temporal-wave.com
 
   That just means you are calling a compiler that has a default level
   less than 1.5. So, chance the javacc command in the preferences or
   remove the old compiler and install 1.6, or makes sure that 1.6 is
  the
   first on the command line. ANTLR works does not influence the Java
   compiler - it only calls the one that you tell it to.
  
   Jim
  
  
  
-Original Message-
From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
boun...@antlr.org] On Behalf Of Ben Corne
Sent: Wednesday, May 04, 2011 6:56 AM
To: antlr-interest@antlr.org
Subject: [antlr-interest] Source code level of ANTLRWorks
   
Hi
   
Is there a way to set the source code level of antlrworks?
I've checked the preferences pane and launchers with no avail.
   
I need to set it to  1.5, since I'm using Java Generics:
   
[15:47:58] 102. ERROR in
/home/bcorne/Downloads/at2-parser-
  3/grammar/output/ATGrammar3Lexer.j
ava (at line 114) [15:47:58] StackString paraphrase = new
StackString();
[15:47:58]  ^^
[15:47:58] Syntax error, parameterized types are only available if
source level is 1.5
   
Regards
Ben Corne
   
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-
email-address
  
   List: http://www.antlr.org/mailman/listinfo/antlr-interest
   Unsubscribe:
   http://www.antlr.org/mailman/options/antlr-interest/your-email-
  address
  
 
  List: http://www.antlr.org/mailman/listinfo/antlr-interest
  Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
  email-address

 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe:
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32413] [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Hans-Juergen Rennau
Hello People,

being an ANTLR beginner, I would very much appreciate advice concerning good 
practise for a rather simple task. The task is the translation of a JPQL's 
(Java 
Persistence Query Language) where clause into a proprietary query language. 
The clause has the well-known expression structure: operands conncected by 
three 
operators: OR, AND and NOT, where precedence increases in that order. Example:
   a.x='1' AND (a.y='2' OR b.z='3') AND a.v like 'abc%'

An important point is that the translation result will have a similar 
structure, 
that is, it will also be operands connected by those operators. Example:
   x='1' AND (y='2' OR z='3') AND v='123*'

For this reason I am not sure if the classical approach for dealing with 
left-associative operators, as shown in the Definitve ANTLR Reference (3. A 
quick tour...) is the most appropriate one in this case. I mean rules like:
   conditional_term ('OR'^ conditional_term)*
   conditional_factor ('AND'^ conditional_factor)*

This creates deep trees, where each operator creates a new level. That is fine 
for processing the operations. But a straightforward translation of the tree 
into a similar sequence of operands and operators yields a result which is 
correct but can be ugly, due to superflous brackets, example:
   (a OR (b OR (c AND d)))

One possibility is to process the tree, removing superfluous brackets - perhaps 
by passing the context operator into the rule as a parameter, so that the 
rule 
can decide if to create brackets or not. This should not be too difficult, but 
my question is: is there a good practise for accomplishing the task? Would you 
recommend the approach just sketched, or a different tree representation to 
start with?

(A tree I do want because there are other parts to be translated, not only the 
where clause, and a tree seems to me the way to deal with (possibly yet 
growing) 
complexity.

Thank you very much for any suggestions.

-- Hans-Juergen


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32414] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Bart Kiers
I get the impression you think that when creating AST's, ANTLR inserts
parenthesis (brackets). This is not the case: I guess what you're seeing is
just the tree's `toStringTree()` that displays these parenthesis to make the
hierarchy of the tree apparent.
Or am I misinterpreting your question?

Regards,

Bart.



On Mon, May 9, 2011 at 3:10 PM, Hans-Juergen Rennau hren...@yahoo.dewrote:

 Hello People,

 being an ANTLR beginner, I would very much appreciate advice concerning
 good
 practise for a rather simple task. The task is the translation of a JPQL's
 (Java
 Persistence Query Language) where clause into a proprietary query
 language.
 The clause has the well-known expression structure: operands conncected by
 three
 operators: OR, AND and NOT, where precedence increases in that order.
 Example:
   a.x='1' AND (a.y='2' OR b.z='3') AND a.v like 'abc%'

 An important point is that the translation result will have a similar
 structure,
 that is, it will also be operands connected by those operators. Example:
   x='1' AND (y='2' OR z='3') AND v='123*'

 For this reason I am not sure if the classical approach for dealing with
 left-associative operators, as shown in the Definitve ANTLR Reference (3.
 A
 quick tour...) is the most appropriate one in this case. I mean rules like:
   conditional_term ('OR'^ conditional_term)*
   conditional_factor ('AND'^ conditional_factor)*

 This creates deep trees, where each operator creates a new level. That is
 fine
 for processing the operations. But a straightforward translation of the
 tree
 into a similar sequence of operands and operators yields a result which is
 correct but can be ugly, due to superflous brackets, example:
   (a OR (b OR (c AND d)))

 One possibility is to process the tree, removing superfluous brackets -
 perhaps
 by passing the context operator into the rule as a parameter, so that the
 rule
 can decide if to create brackets or not. This should not be too difficult,
 but
 my question is: is there a good practise for accomplishing the task? Would
 you
 recommend the approach just sketched, or a different tree representation to
 start with?

 (A tree I do want because there are other parts to be translated, not only
 the
 where clause, and a tree seems to me the way to deal with (possibly yet
 growing)
 complexity.

 Thank you very much for any suggestions.

 -- Hans-Juergen


 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe:
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32415] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Bart Kiers
Wait I think I misunderstood. Your example `(a OR (b OR (c AND d)))` is just
an example expression, right?
In that case, yes, these parenthesis are part of the token stream, but if
you apply rewrite rules (or AST operators `^` and `!`) properly, these
parenthesis are easily removed from your parse tree.

See: http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
or:
http://stackoverflow.com/questions/4931346/how-to-output-the-ast-built-using-antlr

Regards,

Bart.

On Mon, May 9, 2011 at 4:10 PM, Bart Kiers bki...@gmail.com wrote:

 I get the impression you think that when creating AST's, ANTLR inserts
 parenthesis (brackets). This is not the case: I guess what you're seeing is
 just the tree's `toStringTree()` that displays these parenthesis to make the
 hierarchy of the tree apparent.
 Or am I misinterpreting your question?

 Regards,

 Bart.




 On Mon, May 9, 2011 at 3:10 PM, Hans-Juergen Rennau hren...@yahoo.dewrote:

 Hello People,

 being an ANTLR beginner, I would very much appreciate advice concerning
 good
 practise for a rather simple task. The task is the translation of a JPQL's
 (Java
 Persistence Query Language) where clause into a proprietary query
 language.
 The clause has the well-known expression structure: operands conncected by
 three
 operators: OR, AND and NOT, where precedence increases in that order.
 Example:
   a.x='1' AND (a.y='2' OR b.z='3') AND a.v like 'abc%'

 An important point is that the translation result will have a similar
 structure,
 that is, it will also be operands connected by those operators. Example:
   x='1' AND (y='2' OR z='3') AND v='123*'

 For this reason I am not sure if the classical approach for dealing with
 left-associative operators, as shown in the Definitve ANTLR Reference
 (3. A
 quick tour...) is the most appropriate one in this case. I mean rules
 like:
   conditional_term ('OR'^ conditional_term)*
   conditional_factor ('AND'^ conditional_factor)*

 This creates deep trees, where each operator creates a new level. That is
 fine
 for processing the operations. But a straightforward translation of the
 tree
 into a similar sequence of operands and operators yields a result which is
 correct but can be ugly, due to superflous brackets, example:
   (a OR (b OR (c AND d)))

 One possibility is to process the tree, removing superfluous brackets -
 perhaps
 by passing the context operator into the rule as a parameter, so that
 the rule
 can decide if to create brackets or not. This should not be too difficult,
 but
 my question is: is there a good practise for accomplishing the task? Would
 you
 recommend the approach just sketched, or a different tree representation
 to
 start with?

 (A tree I do want because there are other parts to be translated, not only
 the
 where clause, and a tree seems to me the way to deal with (possibly yet
 growing)
 complexity.

 Thank you very much for any suggestions.

 -- Hans-Juergen


 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe:
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address




List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32417] Re: [antlr-interest] Source code level of ANTLRWorks

2011-05-09 Thread Jim Idle
You might be better using remote debugging but you can do what you
suggested earlier and create a script, then tell Works that that is the
java compiler.

Jim

 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Ben Corne
 Sent: Monday, May 09, 2011 5:16 AM
 To: antlr-interest@antlr.org
 Subject: Re: [antlr-interest] Source code level of ANTLRWorks

 The path field expects a directory where it can find the javac binary
 in.

 Adding flags behind the directory also fails:
 The debugger fails to initialize and leaves some process running in the
 background requiring me to kill the process before I can try to run the
 debugger again.

 Any more thoughts?
 Ben

 2011/5/5 Jim Idle j...@temporal-wave.com

  Have you tried adding it in with the PATH? Also you can use -source
  1.6 -target jsr14 and use 1.6 input and 1.4 output.
 
  Jim
 
   -Original Message-
   From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
   boun...@antlr.org] On Behalf Of Ben Corne
   Sent: Thursday, May 05, 2011 4:58 AM
   To: antlr-interest@antlr.org
   Subject: Re: [antlr-interest] Source code level of ANTLRWorks
  
   Here's a screenshot of my antlrworks preferences page + javac info
   http://igor.rave.org/antlrjavac.png
  
   I don't see the option where to adjust the commandline call.
   And from what I think to understand from the helppage of my javac,
   it says
   1.4 is the default, but I don't find a way to change this default,
   except by writing a wrapper shell script that attaches -source 1.5
   (which is what I will do now, until more clues are given)
  
   Ben
  
   2011/5/4 Jim Idle j...@temporal-wave.com
  
That just means you are calling a compiler that has a default
level less than 1.5. So, chance the javacc command in the
preferences or remove the old compiler and install 1.6, or makes
sure that 1.6 is
   the
first on the command line. ANTLR works does not influence the
 Java
compiler - it only calls the one that you tell it to.
   
Jim
   
   
   
 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Ben Corne
 Sent: Wednesday, May 04, 2011 6:56 AM
 To: antlr-interest@antlr.org
 Subject: [antlr-interest] Source code level of ANTLRWorks

 Hi

 Is there a way to set the source code level of antlrworks?
 I've checked the preferences pane and launchers with no avail.

 I need to set it to  1.5, since I'm using Java Generics:

 [15:47:58] 102. ERROR in
 /home/bcorne/Downloads/at2-parser-
   3/grammar/output/ATGrammar3Lexer.j
 ava (at line 114) [15:47:58] StackString paraphrase = new
 StackString();
 [15:47:58]  ^^
 [15:47:58] Syntax error, parameterized types are only available
 if source level is 1.5

 Regards
 Ben Corne

 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe:
 http://www.antlr.org/mailman/options/antlr-interest/your-
 email-address
   
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-
   address
   
  
   List: http://www.antlr.org/mailman/listinfo/antlr-interest
   Unsubscribe:
   http://www.antlr.org/mailman/options/antlr-interest/your-
   email-address
 
  List: http://www.antlr.org/mailman/listinfo/antlr-interest
  Unsubscribe:
  http://www.antlr.org/mailman/options/antlr-interest/your-email-
 address
 

 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
 email-address

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32418] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Jim Idle
If the output language has the same operator precedence as the input
language then there is no need to add additional parens. Just preserve the
presence of parens in the input and reflect them in the output:

expression : expr - ^(EXPRESSION expr) ; // In AST will indicate ()
expr : orexpr - orexpr ; // In AST, indicates no ()
...
atom : LPAREN! expression RPAREN!  // Yields EXPRESSION node, which means
()

---

expression
  : ^(EXPRESSION expr)
  ;


expr
  : ^(AND expr expr)
   ... etc
  | atom
  ;

atom : INT
 | expression // Parens were present
;


If you are trying to remove extraneous parens from the input then you
would need to know the operations on either side of the AND and OR and
decide if the discovered expressions are required. Remember that the
parens are sometimes extraneous but used to  clarify and expression
though, so removing them may not be the best thing to do.

Jim


 -Original Message-
 From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
 boun...@antlr.org] On Behalf Of Hans-Juergen Rennau
 Sent: Monday, May 09, 2011 8:16 AM
 To: Bart Kiers
 Cc: antlr-interest@antlr.orginterest
 Subject: Re: [antlr-interest] Translating expressions - advice?

 Hi Bart, thank you for considering my question! Indeed, what I wrote
 was perhaps misleading. Giving the example
(((a OR b) OR c) AND d)

 I meant the result of translating the AST into text in a canonical
 way, that is, writing this concatenation:

 formula R
: ^(operator ldefOperand rightOperand) = this string: openBracket +
 leftOperand + closeBracket + operator + openBracket + rightOperand +
 closeBracket

 I suppose a deep tree created as sketched in the previous posting, that
 is, by the scheme
: operand (operator^ operand)*

 can be safely translated by applying the rule given above (R)
 recursively. So far, so good. But the brackets are superfluous unless
 the current operator has a lower precedence than the operator in the
 context, the tree level of which the present operand is a child. For
 example, this input
A + B + C + D + E + F

 generates
 (A + B) + C) + D) + E + F)

 So my question amounts to: is it a good idea to accomplish the
 translation in these steps:
 a) build the AST in the standard way (meant for operation execution),
 creating a deep tree with one inner node per operator
 b) serialize it using an adapted form of R, which uses or omits the
 brackets dependent on a rule parameter providing the context operator

 ? Or should one build the AST differently, namely, making the top-level
 operands of an operator the children of the operator, like:
 ^('+' A B C D E F)

 Thank you, and kind regards
 -- Hans-Juergen




 
 Von: Bart Kiers bki...@gmail.com
 An: Hans-Juergen Rennau hren...@yahoo.de
 CC: antlr-interest@antlr.org interest antlr-interest@antlr.org
 Gesendet: Montag, den 9. Mai 2011, 16:16:53 Uhr
 Betreff: Re: [antlr-interest] Translating expressions - advice?

 Wait I think I misunderstood. Your example `(a OR (b OR (c AND d)))` is
 just an example expression, right?
 In that case, yes, these parenthesis are part of the token stream, but
 if you apply rewrite rules (or AST operators `^` and `!`) properly,
 these parenthesis are easily removed from your parse tree.

 See: http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
 or: http://stackoverflow.com/questions/4931346/how-to-output-the-ast-
 built-using-antlr


 Regards,

 Bart.


 On Mon, May 9, 2011 at 4:10 PM, Bart Kiers bki...@gmail.com wrote:

 I get the impression you think that when creating AST's, ANTLR inserts
 parenthesis (brackets). This is not the case: I guess what you're
 seeing is just the tree's `toStringTree()` that displays these
 parenthesis to make the hierarchy of the tree apparent.

 Or am I misinterpreting your question?
 
 
 Regards,
 
 
 Bart.
 
 

 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
 email-address

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32419] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Loring Craymer
Optimal placement of parentheses is tricky; as a first step, you want to use 
the 
form
^('+' A B C D E F )
as long as the operator is associative;
then you want to parenthesize only when required to by changes in operator 
precedence; the easiest way is actually to have two versions of each expression 
rule, one for top level invocation and one for nested invocation (the nested 
versions parenthesize).

--Loring



- Original Message 
 From: Hans-Juergen Rennau hren...@yahoo.de
 To: Bart Kiers bki...@gmail.com
 Cc: antlr-interest@antlr.orginterest antlr-interest@antlr.org
 Sent: Mon, May 9, 2011 8:16:25 AM
 Subject: Re: [antlr-interest] Translating expressions - advice?
 
 Hi Bart, thank you for considering my question! Indeed, what I wrote was 
perhaps 

 misleading. Giving the example
(((a OR b) OR c) AND d)
 
 I  meant the result of translating the AST into text in a canonical way, 
 that 

 is, writing this concatenation: 
 
 formula R  
: ^(operator ldefOperand rightOperand) = this string:  openBracket + 
 leftOperand + closeBracket + operator + openBracket +  rightOperand + 
 closeBracket
 
 I suppose a deep tree created as sketched  in the previous posting, that is, 
 by 

 the scheme
: operand  (operator^ operand)*
 
 can be safely translated by applying the rule given  above (R) recursively. 
So 

 far, so good. But the brackets are superfluous  unless the current operator 
 has 
a 

 lower precedence than the operator in the  context, the tree level of which 
the 

 present operand is a child. For  example, this input
A + B + C + D + E + F
 
 generates
 (A  + B) + C) + D) + E + F)
 
 So my question amounts to: is it a good idea to  accomplish the translation 
 in 

 these steps:
 a) build the AST in the  standard way (meant for operation execution), 
 creating 
a 

 deep tree with one  inner node per operator
 b) serialize it using an adapted form of R, which  uses or omits the 
 brackets 

 dependent on a rule parameter providing the  context operator
 
 ? Or should one build the AST differently, namely,  making the top-level 
operands 

 of an operator the children of the operator,  like:
 ^('+' A B C D E F)
 
 Thank you, and kind regards
 --  Hans-Juergen
 
 
 
 
 
 Von: Bart  Kiers bki...@gmail.com
 An: Hans-Juergen  Rennau hren...@yahoo.de
 CC: antlr-interest@antlr.org interest  antlr-interest@antlr.org
 Gesendet:  Montag, den 9. Mai 2011, 16:16:53 Uhr
 Betreff: Re: [antlr-interest]  Translating expressions - advice?
 
 Wait I think I misunderstood. Your  example `(a OR (b OR (c AND d)))` is just 
an 

 example expression,  right?
 In that case, yes, these parenthesis are part of the token stream, but  if 
 you 

 apply rewrite rules (or AST operators `^` and `!`) properly, these  
 parenthesis 

 are easily removed from your parse tree.
 
 See: http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
 or: 
http://stackoverflow.com/questions/4931346/how-to-output-the-ast-built-using-antlr

 
 
 Regards,
 
 Bart.
 
 
 On  Mon, May 9, 2011 at 4:10 PM, Bart Kiers bki...@gmail.com wrote:
 
 I get the  impression you think that when creating AST's, ANTLR inserts 
 parenthesis  (brackets). This is not the case: I guess what you're seeing is 
just 

 the  tree's `toStringTree()` that displays these parenthesis to make the 
 hierarchy of the tree apparent.
 Or am I misinterpreting your  question?
 
 
 Regards,
 
 
 Bart.
 
 
 
 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
 

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32420] [antlr-interest] Composite grammars: compile error with @header tag.

2011-05-09 Thread Pavel Ganelin
I have 4 grammar file: lexer L.g, parser P.g and two grammars G1 and G2 (see
below). After running antlr to generate Java files compilation fails:

[mkdir] Created dir: target\classes
[javac] Compiling 10 source files to target\classes
[javac] target\src\example\G1Lexer.java:18: cannot find symbol
[javac] symbol  : class G1_L
[javac] location: class G1Lexer
[javac] public G1_L gL;
[javac]^
[javac] target\src\example\G1Lexer.java:9: duplicate class: G1Lexer
[javac] public class G1Lexer extends Lexer {
[javac]^
[javac] target\src\example\G1_L.java:22: cannot access example.G1Lexer
[javac] bad class file: target\src\example\G1Lexer.java
[javac] file does not contain class example.G1Lexer
[javac] Please remove or make sure it appears in the correct
subdirectory of the classpath.
[javac] public G1Lexer gG1;
[javac]^
[javac] 3 errors

The workaround would be to move @lexer::header file to both G1.g and G2.g.
It works but the solution has 2 drawbacks:

1. Code duplication.
2. L.java can not be compiled as standalone file anymore because it lacks
package declaration.

==L.g

lexer grammar L;

@lexer::header {
package example;
}

IDENT : 'A-Z' +
;
==P.g==
parser grammar P ;

tokens {
  BEGIN = 'begin';
  END = 'end';
}

method: BEGIN IDENT END;
 G1.g ==
grammar G1 ;
import L,P;

tokens {
  PROGRAM = 'program';
}


@header {
package example;
}

program: PROGRAM method;
===G2.g=
grammar G2 ;
import L,P;

tokens {
  FUNCTION = 'function';
}

@header {
package example;
}

function: FUNCTION method;
==

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32421] [antlr-interest] Feature Request - Visualize the Parse Graph for multiple rules by Rule Decisions and Tokens consumed

2011-05-09 Thread Douglas Godfrey
Feature Request:

A way to visualize the Parse Graph of a grammar by the sequence of Tokens
consumed by the rules.

The Parse Graph should be generated by selecting a rule or rule decision and
using the contextual menu
or the Grammar menu. The root of the Parse Graph should be the start of the
selected rule or decision.

The Parse Graph should visually represent the flow of control in the parser
generated by a grammar
starting from the selected rule or decision.

The Parse Graph should show the rules, rule decisions and the Tokens or user
provided Predicates that
determine which path is followed. A decision invoking a Sub-rule should be
inlined until a leading Token
or predicate is found.

Antlr generated predicates should list the Tokens in the follow set that
trigger that predicate.
If the set is more than 2-3 Tokens then do not list the tokens in the graph
node but instead have a label
that refers to a named list of tokens added to the bottom of the Parse Graph
diagram.

User provided predicates should be shown as a node named by the predicate
function with a label
indicating the line number of the predicate in the grammar. Predicate Nodes
should distinguish between
Syntactic, Semantic and Gated Predicates

The graph generation should have an option to limit the depth of analysis so
the generated graph will be
small enough for a person to read. If analysis is terminated by the depth
limit, then that should be visually
indicated by adding an Ellipsis node as a terminal leaf node.

The graph generation should also honor the current printer page setup and
margins. If a diagram would be
wider than the current page margins it should be wrapped to another line.

The output should be a PS, PDF or Dot file with display and save options
like the existing Rule Dependency
and Syntax Diagram graphs.

The graph should be formatted like a Pascal Railroad Diagram similar to the
existing Syntax Diagrams
instead of free-form like the Rule-Dependency-Graph. The resulting graph
should be suitable for use as
formal language documentation for the language parsed by the grammar.

i.e. If the grammar was for the Pascal language, selecting the Program rule
would generate a railroad
  diagram for the Pascal Language that would look like a more detailed
version of the diagrams found
  in every elementary Pascal textbook.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.