<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-12279</id>
	<title>Nabble - SableCC</title>
	<updated>2009-12-07T14:49:55Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/SableCC-f12279.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SableCC-f12279.html" />
	<subtitle type="html">SableCC home is &lt;a href=&quot;http://sablecc.org/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26686853</id>
	<title>Re: Help with Grammar Ambiguity</title>
	<published>2009-12-07T14:49:55Z</published>
	<updated>2009-12-07T14:49:55Z</updated>
	<author>
		<name>Jon Shapcott</name>
	</author>
	<content type="html">&lt;br&gt;On Sun, Dec 06, 2009 at 03:49:52PM -0500, Etienne M. Gagnon wrote:
&lt;br&gt;&amp;gt; I'm glad this helped you. Just buy my (future) book, next year. :)
&lt;br&gt;&lt;br&gt;Is this going to be a general parsing/compilig book, or one about
&lt;br&gt;SableCC 4?
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Jon Shapcott &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26686853&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;eden@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;quot;This is the Space Age, and we are Here To Go&amp;quot; - William S. Burroughs
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26686853&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-Grammar-Ambiguity-tp26662285p26686853.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26668993</id>
	<title>Re: Help with Grammar Ambiguity</title>
	<published>2009-12-06T12:49:52Z</published>
	<updated>2009-12-06T12:49:52Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">Hi Eli,
&lt;br&gt;&lt;br&gt;I'm glad this helped you. Just buy my (future) book, next year. :)
&lt;br&gt;&lt;br&gt;Have fun!
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;Eli Gottlieb wrote:
&lt;br&gt;&amp;gt; Ah, there's the mistake. &amp;nbsp;I forgot to add a semicolon to the 
&lt;br&gt;&amp;gt; expression case of the statement production.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If you'd like e-cookies or a Christmas card or something, please just 
&lt;br&gt;&amp;gt; say. &amp;nbsp;I've spent the past two or three days pondering this!
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26668993&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-Grammar-Ambiguity-tp26662285p26668993.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26665075</id>
	<title>Re: Help with Grammar Ambiguity</title>
	<published>2009-12-05T21:44:01Z</published>
	<updated>2009-12-05T21:44:01Z</updated>
	<author>
		<name>Eli Gottlieb</name>
	</author>
	<content type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;Ah, there's the mistake. &amp;nbsp;I forgot to add a semicolon to the expression case of the statement production.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;If you'd like e-cookies or a Christmas card or something, please just say. &amp;nbsp;I've spent the past two or three days pondering this!&lt;br&gt;&lt;div&gt;&lt;div&gt;On Dec 6, 2009, at 12:14 AM, Etienne M. Gagnon wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;
&lt;div bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Eli,&lt;br&gt;
&lt;br&gt;
Interesting case. I've looked at your grammar. I think I found the
source of the conflict:&lt;br&gt;
&lt;br&gt;
&amp;nbsp; statement_block = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; lbracket statement+ rbracket;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;
&amp;nbsp; statement = &lt;br&gt;
&amp;nbsp;&amp;nbsp; ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {expressionst} expression;&lt;br&gt;
&lt;br&gt;
So, your language allows for a sequence of expressions without
separators:&lt;br&gt;
&lt;br&gt;
i 3 j k i (3) j k ...&lt;br&gt;
&lt;br&gt;
Of course, there is an ambiguity here. &quot;i (3)&quot; has two possible
syntactic interpretations: &lt;br&gt;
&lt;ol&gt;
  &lt;li&gt;The expression &quot;i&quot; followed by the expression &quot;(3)&quot;.&lt;/li&gt;
  &lt;li&gt;The expression &quot;i(3)&quot; representing a function call.&lt;/li&gt;
&lt;/ol&gt;
The solution: add separators or terminators to your statements.
Traditionally, language designers have used &quot;;&quot; as statement separator
or terminator.&lt;br&gt;
&lt;br&gt;
Have fun!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
Eli Gottlieb a écrit&amp;nbsp;:
&lt;blockquote cite=&quot;mid:1260067245.2298.9.camel@eli-netbook&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;I'm using SableCC 3.2 to obtain a parser for a custom compiler and it
reports a grammar ambiguity on my expression productions.

If anyone has the spare time to help, I could use some insight on the
ambiguity creating the shift/reduce conflict.  A left_expression (or
expression of any kind) followed by a left parenthesis *should* always
be illegal except in the case of a function_call_expression, so
obviously I want it to go with the shift option to resolve this
conflict.  I just can't find what makes the reduce possible or how to
specify to SableCC that I want a shift in that situation to parse out a
function call.
  &lt;/pre&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;shift/reduce conflict in state [stack: TModule PQualifiedIdentifier TDefine PTypedVariableDeclaration TAssignmentOperator PQualifiedIdentifier *] on TLparen in {
	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen PExpressionList TRparen ] (shift),
	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen TRparen ] (shift),
	[ PLeftExpression = PQualifiedIdentifier * ] followed by TLparen (reduce)
}
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
Thanks for any light you might be able to shed,
Eli Gottlieb
  &lt;/pre&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;hr size=&quot;4&quot; width=&quot;90%&quot;&gt;
_______________________________________________
SableCC-Discussion mailing list
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26665075&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/div&gt;

_______________________________________________&lt;br&gt;SableCC-Discussion mailing list&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26665075&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;&lt;br&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26665075&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-Grammar-Ambiguity-tp26662285p26665075.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26662388</id>
	<title>Re: Help with Grammar Ambiguity</title>
	<published>2009-12-05T21:14:24Z</published>
	<updated>2009-12-05T21:14:24Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=UTF-8&quot; http-equiv=&quot;Content-Type&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Eli,&lt;br&gt;
&lt;br&gt;
Interesting case. I've looked at your grammar. I think I found the
source of the conflict:&lt;br&gt;
&lt;br&gt;
  statement_block = &lt;br&gt;
    lbracket statement+ rbracket;&lt;br&gt;
    &lt;br&gt;
  statement = &lt;br&gt;
   ...&lt;br&gt;
    {expressionst} expression;&lt;br&gt;
&lt;br&gt;
So, your language allows for a sequence of expressions without
separators:&lt;br&gt;
&lt;br&gt;
i 3 j k i (3) j k ...&lt;br&gt;
&lt;br&gt;
Of course, there is an ambiguity here. &quot;i (3)&quot; has two possible
syntactic interpretations: &lt;br&gt;
&lt;ol&gt;
  &lt;li&gt;The expression &quot;i&quot; followed by the expression &quot;(3)&quot;.&lt;/li&gt;
  &lt;li&gt;The expression &quot;i(3)&quot; representing a function call.&lt;/li&gt;
&lt;/ol&gt;
The solution: add separators or terminators to your statements.
Traditionally, language designers have used &quot;;&quot; as statement separator
or terminator.&lt;br&gt;
&lt;br&gt;
Have fun!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
Eli Gottlieb a écrit :
&lt;blockquote cite=&quot;mid:1260067245.2298.9.camel@eli-netbook&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;I'm using SableCC 3.2 to obtain a parser for a custom compiler and it
reports a grammar ambiguity on my expression productions.

If anyone has the spare time to help, I could use some insight on the
ambiguity creating the shift/reduce conflict.  A left_expression (or
expression of any kind) followed by a left parenthesis *should* always
be illegal except in the case of a function_call_expression, so
obviously I want it to go with the shift option to resolve this
conflict.  I just can't find what makes the reduce possible or how to
specify to SableCC that I want a shift in that situation to parse out a
function call.
  &lt;/pre&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;shift/reduce conflict in state [stack: TModule PQualifiedIdentifier TDefine PTypedVariableDeclaration TAssignmentOperator PQualifiedIdentifier *] on TLparen in {
	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen PExpressionList TRparen ] (shift),
	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen TRparen ] (shift),
	[ PLeftExpression = PQualifiedIdentifier * ] followed by TLparen (reduce)
}
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
Thanks for any light you might be able to shed,
Eli Gottlieb
  &lt;/pre&gt;
  &lt;pre wrap=&quot;&quot;&gt;
&lt;hr size=&quot;4&quot; width=&quot;90%&quot;&gt;
_______________________________________________
SableCC-Discussion mailing list
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26662388&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26662388&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-Grammar-Ambiguity-tp26662285p26662388.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26662285</id>
	<title>Help with Grammar Ambiguity</title>
	<published>2009-12-05T18:40:45Z</published>
	<updated>2009-12-05T18:40:45Z</updated>
	<author>
		<name>Eli Gottlieb</name>
	</author>
	<content type="html">I'm using SableCC 3.2 to obtain a parser for a custom compiler and it
&lt;br&gt;reports a grammar ambiguity on my expression productions.
&lt;br&gt;&lt;br&gt;If anyone has the spare time to help, I could use some insight on the
&lt;br&gt;ambiguity creating the shift/reduce conflict. &amp;nbsp;A left_expression (or
&lt;br&gt;expression of any kind) followed by a left parenthesis *should* always
&lt;br&gt;be illegal except in the case of a function_call_expression, so
&lt;br&gt;obviously I want it to go with the shift option to resolve this
&lt;br&gt;conflict. &amp;nbsp;I just can't find what makes the reduce possible or how to
&lt;br&gt;specify to SableCC that I want a shift in that situation to parse out a
&lt;br&gt;function call.
&lt;br&gt;&amp;gt; shift/reduce conflict in state [stack: TModule PQualifiedIdentifier TDefine PTypedVariableDeclaration TAssignmentOperator PQualifiedIdentifier *] on TLparen in {
&lt;br&gt;&amp;gt; 	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen PExpressionList TRparen ] (shift),
&lt;br&gt;&amp;gt; 	[ PFunctionCallExpression = PQualifiedIdentifier * TLparen TRparen ] (shift),
&lt;br&gt;&amp;gt; 	[ PLeftExpression = PQualifiedIdentifier * ] followed by TLparen (reduce)
&lt;br&gt;&amp;gt; }
&lt;br&gt;&lt;br&gt;Thanks for any light you might be able to shed,
&lt;br&gt;Eli Gottlieb
&lt;br&gt;&lt;br /&gt;Package decasyntax;
&lt;br&gt;&lt;br&gt;Helpers
&lt;br&gt;&amp;nbsp; unicode_input_character = [0..0xffff];
&lt;br&gt;&amp;nbsp; letter = ['A'..'Z'] | ['a'..'z'] | [0x7F .. 0xFF];
&lt;br&gt;&amp;nbsp; digit = ['0'..'9'];
&lt;br&gt;&amp;nbsp; nondigit = '_' | '?' | '!' | letter;
&lt;br&gt;&amp;nbsp; all = [0 .. 0xFFFF];
&lt;br&gt;&amp;nbsp; cr = 13;
&lt;br&gt;&amp;nbsp; lf = 10;
&lt;br&gt;&amp;nbsp; tab = 9;
&lt;br&gt;&amp;nbsp; eol = cr | lf | cr lf;
&lt;br&gt;&amp;nbsp; input_character = [unicode_input_character - [cr + lf]];
&lt;br&gt;&amp;nbsp; not_cr_lf = [all - [cr + lf]];
&lt;br&gt;&amp;nbsp; not_star = [all - '*'];
&lt;br&gt;&amp;nbsp; not_star_slash = [not_star - '/'];
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; non_zero_digit = ['1'..'9'];
&lt;br&gt;&amp;nbsp; hex_digit = ['0'..'9'] | ['a'..'f'] | ['A'..'F'];
&lt;br&gt;&amp;nbsp; octal_digit = ['0'..'7'];
&lt;br&gt;&amp;nbsp; zero_to_three = ['0'..'3'];
&lt;br&gt;&amp;nbsp; decimal_numeral = '0' | non_zero_digit digit*;
&lt;br&gt;&amp;nbsp; hex_numeral = '0x' hex_digit+;
&lt;br&gt;&amp;nbsp; octal_numeral = '0' octal_digit+;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; single_character = [input_character - ['&amp;quot;' + '\']];
&lt;br&gt;&amp;nbsp; octal_escape = '\' (octal_digit octal_digit? | zero_to_three octal_digit octal_digit);
&lt;br&gt;&amp;nbsp; escape_sequence = '\b' | '\t' | '\n' | '\f' | '\r' | '\&amp;quot;' | '\' ''' | '\\' | octal_escape;
&lt;br&gt;&amp;nbsp; string_character = single_character | escape_sequence;
&lt;br&gt;&lt;br&gt;&amp;nbsp; bitwise_binary_operator = 'and' | 'or';
&lt;br&gt;&amp;nbsp; comparison_operator = '=' | '&amp;gt;' | '&amp;lt;' | '&amp;gt;=' | '&amp;lt;=' | '&amp;lt;&amp;gt;';
&lt;br&gt;&amp;nbsp; muldiv_operator = '*' | '/';
&lt;br&gt;&amp;nbsp; addsub_operator = '+' | '-';
&lt;br&gt;&amp;nbsp; at_operator = '@';
&lt;br&gt;&amp;nbsp; exponentiation_operator = '^';
&lt;br&gt;&amp;nbsp; apply_operator = '-&amp;gt;';
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;Tokens
&lt;br&gt;&lt;br&gt;&amp;nbsp; unqualified_identifier = nondigit (digit | nondigit)*;
&lt;br&gt;&amp;nbsp; integer_constant = decimal_numeral | hex_numeral | octal_numeral;
&lt;br&gt;&amp;nbsp; string_constant = '&amp;quot;' string_character* '&amp;quot;';
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; global_variable_modifier = 'anonymous' | 'constant';
&lt;br&gt;&amp;nbsp; class_section_name = 'public' | 'private' | 'protected';
&lt;br&gt;&amp;nbsp; object_function_keyword = 'generic' | 'method';
&lt;br&gt;&amp;nbsp; boolean_constant = 'true' | 'false';
&lt;br&gt;&amp;nbsp; module_modifier = 'unsafe' | 'pure';
&lt;br&gt;&amp;nbsp; binary_operator = addsub_operator | muldiv_operator | comparison_operator | bitwise_binary_operator | exponentiation_operator | apply_operator;
&lt;br&gt;&amp;nbsp; comparison_operator = comparison_operator;
&lt;br&gt;&amp;nbsp; muldiv_operator = muldiv_operator;
&lt;br&gt;&amp;nbsp; addsub_operator = addsub_operator;
&lt;br&gt;&amp;nbsp; bitwise_binary_operator = bitwise_binary_operator;
&lt;br&gt;&amp;nbsp; minus_operator = '-';
&lt;br&gt;&amp;nbsp; exponentiation_operator = '^';
&lt;br&gt;&amp;nbsp; apply_operator = '-&amp;gt;';
&lt;br&gt;&amp;nbsp; at_operator = '@';
&lt;br&gt;&amp;nbsp; not_operator = 'not';
&lt;br&gt;&amp;nbsp; inout = 'inout';
&lt;br&gt;&amp;nbsp; generic = 'generic';
&lt;br&gt;&amp;nbsp; method = 'method';
&lt;br&gt;&amp;nbsp; comma = ',';
&lt;br&gt;&amp;nbsp; assignment_operator = ':=';
&lt;br&gt;&amp;nbsp; lparen = '(';
&lt;br&gt;&amp;nbsp; rparen = ')';
&lt;br&gt;&amp;nbsp; lbracket = '{';
&lt;br&gt;&amp;nbsp; rbracket = '}';
&lt;br&gt;&amp;nbsp; lsbracket = '[';
&lt;br&gt;&amp;nbsp; rsbracket = ']';
&lt;br&gt;&amp;nbsp; dot = '.';
&lt;br&gt;&amp;nbsp; semicolon = ';';
&lt;br&gt;&amp;nbsp; end_module = 'end.';
&lt;br&gt;&amp;nbsp; module = 'module';
&lt;br&gt;&amp;nbsp; labracket = '&amp;lt;';
&lt;br&gt;&amp;nbsp; rabracket = '&amp;gt;';
&lt;br&gt;&amp;nbsp; import = 'import';
&lt;br&gt;&amp;nbsp; define = 'define';
&lt;br&gt;&amp;nbsp; constructor = 'constructor';
&lt;br&gt;&amp;nbsp; destructor = 'destructor';
&lt;br&gt;&amp;nbsp; extends = 'extends';
&lt;br&gt;&amp;nbsp; class_keyword = 'class';
&lt;br&gt;&amp;nbsp; subrange = 'subrange';
&lt;br&gt;&amp;nbsp; enum = 'enum';
&lt;br&gt;&amp;nbsp; exception = 'exception';
&lt;br&gt;&amp;nbsp; from = 'from';
&lt;br&gt;&amp;nbsp; to = 'to';
&lt;br&gt;&amp;nbsp; equals = '=';
&lt;br&gt;&amp;nbsp; function = 'function';
&lt;br&gt;&amp;nbsp; lambda = 'lambda';
&lt;br&gt;&amp;nbsp; return = 'return';
&lt;br&gt;&amp;nbsp; while = 'while';
&lt;br&gt;&amp;nbsp; do = 'do';
&lt;br&gt;&amp;nbsp; until = 'until';
&lt;br&gt;&amp;nbsp; for = 'for';
&lt;br&gt;&amp;nbsp; case = 'case';
&lt;br&gt;&amp;nbsp; cond = 'cond';
&lt;br&gt;&amp;nbsp; let = 'let';
&lt;br&gt;&amp;nbsp; except = 'except';
&lt;br&gt;&amp;nbsp; finally = 'finally';
&lt;br&gt;&amp;nbsp; try = 'try';
&lt;br&gt;&amp;nbsp; throw = 'throw';
&lt;br&gt;&amp;nbsp; else = 'else';
&lt;br&gt;&amp;nbsp; cast = 'cast';
&lt;br&gt;&amp;nbsp; alias = '&amp;';
&lt;br&gt;&amp;nbsp; as = 'as';
&lt;br&gt;&amp;nbsp; type = 'type';
&lt;br&gt;&amp;nbsp; closure = 'closure';
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; blank = eol | tab | ' ';
&lt;br&gt;&amp;nbsp; tabspace = [tab + ' '];
&lt;br&gt;&amp;nbsp; space = [cr + [lf + [tab + ' ']]];
&lt;br&gt;&amp;nbsp; comment = '/*' not_star* '*'+ (not_star_slash not_star* '*'+)* '/';
&lt;br&gt;&lt;br&gt;Ignored Tokens
&lt;br&gt;&lt;br&gt;&amp;nbsp; blank,
&lt;br&gt;&amp;nbsp; comment;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;Productions
&lt;br&gt;&amp;nbsp; module_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; module [name]:identifier module_parameters? [imports]:import_declaration* [definitions]:definition* end_module;
&lt;br&gt;&lt;br&gt;&amp;nbsp; qualified_identifier = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {simple} unqualified_identifier |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {imported} qualified_identifier dot unqualified_identifier;
&lt;br&gt;&lt;br&gt;&amp;nbsp; identifier = qualified_identifier;
&lt;br&gt;&lt;br&gt;&amp;nbsp; /* Syntax forms for module-level definitions, including types. */
&lt;br&gt;&amp;nbsp; identifier_list = {one} unqualified_identifier | {many} identifier_list comma unqualified_identifier;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; module_parameter_list = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} [name]:unqualified_identifier |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} [rest]:module_parameter_list comma [last]:unqualified_identifier;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; module_parameters = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; labracket [parameters]:module_parameter_list rabracket;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; import_declaration = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; import [name]:qualified_identifier semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; type_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; type [name]:unqualified_identifier equals type_form semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; type_form =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {class} class_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {subrange} subrange_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {enum} enum_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {exception} exception_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {functype} functype_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {closure} closure_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {alias} alias_form |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {rename} qualified_identifier;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; class_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; class_keyword [extension]:extension_clause? lbracket [sections]:class_section_definition* rbracket;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; subrange_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; subrange [parent]:identifier from [floor]:expression to [ceiling]:expression;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; enum_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; enum [extension]:extension_clause? lparen identifier_list rparen;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; exception_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; exception [extension]:extension_clause? lparen identifier_list rparen;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; functype_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; function [type]:qualified_identifier? lparen [arguments]:argument_list rparen;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; closure_form = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; closure lparen [functype]:qualified_identifier rparen lbracket [variables]:member_declaration* rbracket;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; alias_form =
&lt;br&gt;&amp;nbsp; &amp;nbsp; [type]:qualified_identifier alias;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {globaldef} global_variable_definition |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {typedef} type_definition |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {moduledef} module_definition |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {fundef} function_definition;
&lt;br&gt;&lt;br&gt;&amp;nbsp; typed_variable_declaration =
&lt;br&gt;&amp;nbsp; &amp;nbsp; [type]:identifier [name]:unqualified_identifier;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; typed_variable_definition =
&lt;br&gt;&amp;nbsp; &amp;nbsp; [declaration]:typed_variable_declaration assignment_operator [initial_value]:expression;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; global_variable_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; define [modifier]:global_variable_modifier? [definition]:typed_variable_definition semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; member_declaration = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {named} [type]:identifier [names]:identifier_list semicolon |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {indexed} [type]:identifier lsbracket [quantity]:integer_constant rsbracket semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; constructor_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; constructor [name]:identifier lparen [arguments]:argument_list rparen [body]:statement_block;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; destructor_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; destructor [name]:identifier lparen [arguments]:argument_list rparen [body]:statement_block;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; class_routine_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {constructor} constructor_definition |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {destructor} destructor_definition;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; class_section_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; [section_type]:class_section_name [members]:member_declaration* [routines]:class_routine_definition*;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; extension_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; extends qualified_identifier;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; argument_declaration =
&lt;br&gt;&amp;nbsp; &amp;nbsp; [modifier]:inout? [type]:qualified_identifier [names]:identifier_list;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; argument_list = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} argument_declaration |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} argument_list semicolon argument_declaration;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; generic_body = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {none} semicolon |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {body} statement_block;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; function_definition = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {generic} generic [type]:qualified_identifier? [name]:identifier lparen [arguments]:argument_list rparen generic_body |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {method} method [name]:identifier lparen [arguments]:argument_list rparen [body]:statement_block |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {function} function [name]:unqualified_identifier lparen [arguments]:argument_list rparen [body]:statement_block;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; expression = exp6;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; exp6 = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {comparison} [exp1]:exp5 [operator]:comparison_operator [exp2]:exp5 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp5;
&lt;br&gt;&lt;br&gt;&amp;nbsp; exp5 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {apply} [function]:exp5 apply_operator [arguments]:exp4 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp4;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; exp4 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {addsub} [exp1]:exp4 [operator]:addsub_operator [exp2]:exp3 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp3;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp; exp3 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {muldiv} [exp1]:exp3 [operator]:muldiv_operator [exp2]:exp2 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp2; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; exp2 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {binary_bitwise} [exp1]:exp2 [operator]:bitwise_binary_operator [exp2]:exp1 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp1;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; exp1 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {exponentiation} [exp1]:exp1 exponentiation_operator [exp2]:exp0 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {others} exp0;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; exp0 =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {not} not_operator exp0 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {minus} minus_operator exp0 |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {at} at_operator [location]:left_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {call} function_call_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {primitive} primitive_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {tupleexp} tuple_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {lambdaexp} lambda_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {parenthetical} parenthetical_expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {left} left_expression;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; function_call_expression =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {varargs} [function]:identifier lparen [arguments]:expression_list? rparen |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {parentheticalargs} [function]:parenthetical_expression lparen [arguments]:expression_list? rparen;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&amp;nbsp; parenthetical_expression =
&lt;br&gt;&amp;nbsp; &amp;nbsp; lparen expression rparen;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; variable_subscript =
&lt;br&gt;&amp;nbsp; &amp;nbsp; lsbracket expression rsbracket;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; left_expression = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {variable} [var]:qualified_identifier |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {subscript} [var]:left_expression [subscript]:variable_subscript |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {parensub} [var]:parenthetical_expression [subscript]:variable_subscript;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; primitive_expression = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {integer} integer_constant |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {boolean} boolean_constant |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {string} string_constant;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; expression_list = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} expression |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} expression_list comma expression;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; tuple_expression = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; lsbracket expression_list rsbracket;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; lambda_expression = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; lambda lparen argument_list rparen statement_block;
&lt;br&gt;&lt;br&gt;&amp;nbsp; apply_expression =
&lt;br&gt;&amp;nbsp; &amp;nbsp; [function]:expression apply_operator [arguments]:expression;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; return_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; return expression semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; assignment_statement =
&lt;br&gt;&amp;nbsp; &amp;nbsp; left_expression assignment_operator expression semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; let_assignment = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; identifier assignment_operator expression;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; let_assignment_list = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} let_assignment |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} let_assignment_list semicolon let_assignment;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; let_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; let lparen [let_assigments]:let_assignment_list rparen statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; except_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; except lparen typed_variable_declaration rparen statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; finally_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; finally statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; try_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; try statement [exceptions]:except_clause* [finally]:finally_clause?;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; for_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; for lparen [initializer]:let_assignment [first_separator]:semicolon [test]:expression [second_separator]:semicolon [step]:statement rparen [loop]:statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; while_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; while expression do statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; do_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; do statement until expression semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; throw_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; throw expression semicolon;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; else_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; else statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; case_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; case lparen expression rparen statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; cond_statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} cond [case]:case_clause [else]:else_clause? |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} cond lbracket [cases]:case_clause+ rbracket [else]:else_clause?;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; cast_clause = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; case lparen typed_variable_definition rparen [success]:statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; cast_statement =
&lt;br&gt;&amp;nbsp; &amp;nbsp; {one} cast [case]:case_clause else [failure]:statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {many} cast lbracket [cases]:case_clause+ rbracket else [failure]: statement;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; statement_block = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; lbracket statement+ rbracket;
&lt;br&gt;&amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; statement = 
&lt;br&gt;&amp;nbsp; &amp;nbsp; {returnst} return_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {assignmentst} assignment_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {letst} let_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {tryst} try_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {forst} for_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {whilest} while_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {dost} do_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {throwst} throw_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {condst} cond_statement |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {blockst} statement_block |
&lt;br&gt;&amp;nbsp; &amp;nbsp; {expressionst} expression;
&lt;br&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26662285&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-Grammar-Ambiguity-tp26662285p26662285.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26620924</id>
	<title>Re: Newlines and EOF in SableCC 3.2</title>
	<published>2009-12-02T20:42:33Z</published>
	<updated>2009-12-02T20:42:33Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">Hi Roger,
&lt;br&gt;&lt;br&gt;You could cheat. :) &amp;nbsp;You could hack the input stream to generate a 
&lt;br&gt;spurious newline in front of the stream's EOF. That would solve your 
&lt;br&gt;problem, while waiting for SableCC 4.
&lt;br&gt;&lt;br&gt;Have fun!
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;Pomeroy, Roger C a écrit :
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I am currently using SableCC &amp;nbsp;3.2 (I can't wait for 4.0, its good to see the progress)... but in the meantime, I have a question.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In my grammar, blanks and newlines are significant. &amp;nbsp;User input lines are terminated with newlines. &amp;nbsp;A snippet of the a couple productions look like:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; test_statements {-&amp;gt;statement} = &amp;nbsp;// everything except for testpreferences (that cannot be inside testgroup, case)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {push_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;push &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.push(push)}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {pushc_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pushc &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pushc(pushc)}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {pushg_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pushg &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pushg(pushg)}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {pop} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pop &amp;nbsp; &amp;nbsp; &amp;nbsp;[trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pop(pop)}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; .....
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;My problem is that if a user inputs a file that has something like:
&lt;br&gt;&amp;gt; &amp;nbsp; ...
&lt;br&gt;&amp;gt; &amp;nbsp;PUSH &amp;lt;newline&amp;gt;
&lt;br&gt;&amp;gt; &amp;lt;eof&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; it works just fine, but if the user doesn't add a &amp;lt;newline&amp;gt; at the end of the input and has &amp;nbsp;something like:
&lt;br&gt;&amp;gt; ....
&lt;br&gt;&amp;gt; PUSH &amp;lt;eof&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I get a parser error on the last line of the file because there is no newline.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So my question is ... how can I handle this? &amp;nbsp;I can't make the new_line token optional in the production, because that gives rise to lots of shift/reduce errors. &amp;nbsp;What I really want is to be able to say that a statement is terminated by EITHER a new_line or an EOF, but as far as I can tell, there is no way for me to write such a production... Is that correct?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Roger
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Roger Pomeroy
&lt;br&gt;&amp;gt; Associate Technical Fellow
&lt;br&gt;&amp;gt; Aerodynamics/Geometry
&lt;br&gt;&amp;gt; Phone &amp;nbsp;425-237-2568
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; SableCC-Discussion mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26620924&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26620924&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Newlines-and-EOF-in-SableCC-3.2-tp26620868p26620924.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26620868</id>
	<title>Newlines and EOF in SableCC 3.2</title>
	<published>2009-12-02T08:22:41Z</published>
	<updated>2009-12-02T08:22:41Z</updated>
	<author>
		<name>roger_pomeroy</name>
	</author>
	<content type="html">I am currently using SableCC &amp;nbsp;3.2 (I can't wait for 4.0, its good to see the progress)... but in the meantime, I have a question.
&lt;br&gt;&lt;br&gt;In my grammar, blanks and newlines are significant. &amp;nbsp;User input lines are terminated with newlines. &amp;nbsp;A snippet of the a couple productions look like:
&lt;br&gt;&lt;br&gt;&amp;nbsp; test_statements {-&amp;gt;statement} = &amp;nbsp;// everything except for testpreferences (that cannot be inside testgroup, case)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {push_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;push &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.push(push)}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; | {pushc_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pushc &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pushc(pushc)}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; | {pushg_stmt} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pushg &amp;nbsp; &amp;nbsp; [trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pushg(pushg)}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; | {pop} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pop &amp;nbsp; &amp;nbsp; &amp;nbsp;[trail]:blank* new_line &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {-&amp;gt;New statement.pop(pop)}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .....
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;My problem is that if a user inputs a file that has something like:
&lt;br&gt;&amp;nbsp; ...
&lt;br&gt;&amp;nbsp;PUSH &amp;lt;newline&amp;gt;
&lt;br&gt;&amp;lt;eof&amp;gt;
&lt;br&gt;&lt;br&gt;it works just fine, but if the user doesn't add a &amp;lt;newline&amp;gt; at the end of the input and has &amp;nbsp;something like:
&lt;br&gt;....
&lt;br&gt;PUSH &amp;lt;eof&amp;gt;
&lt;br&gt;&lt;br&gt;I get a parser error on the last line of the file because there is no newline.
&lt;br&gt;&lt;br&gt;So my question is ... how can I handle this? &amp;nbsp;I can't make the new_line token optional in the production, because that gives rise to lots of shift/reduce errors. &amp;nbsp;What I really want is to be able to say that a statement is terminated by EITHER a new_line or an EOF, but as far as I can tell, there is no way for me to write such a production... Is that correct?
&lt;br&gt;&lt;br&gt;Thanks!
&lt;br&gt;&lt;br&gt;Roger
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Roger Pomeroy
&lt;br&gt;Associate Technical Fellow
&lt;br&gt;Aerodynamics/Geometry
&lt;br&gt;Phone &amp;nbsp;425-237-2568
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26620868&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Newlines-and-EOF-in-SableCC-3.2-tp26620868p26620868.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26384030</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution	for	expressions</title>
	<published>2009-11-16T19:46:49Z</published>
	<updated>2009-11-16T19:46:49Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Niklas,&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117030443.GC47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;Reporting an error on an &quot;invalid&quot; specification is easy.

In the lexer, with the partial order, should you report an error when an 
ordering ends-up not being used? This might annoy users to no end.
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
Do you mean redundant (e.g. due to transitivity) order declarations?
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Let say that you have:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Precedence&lt;br&gt;
&amp;nbsp; a &amp;gt; b;&lt;br&gt;
&amp;nbsp; a &amp;gt; c;&lt;br&gt;
&amp;nbsp; b &amp;gt; c;&lt;br&gt;
&lt;br&gt;
Assume that there is a lexical conflict involving all of a, b, and c
(e.g. the intersection of the 3 languages is not empty, and it contains
a longest match).&lt;br&gt;
&lt;br&gt;
Then, a wins. This means that, unless there's another conflict, the &quot;b
&amp;gt; c&quot; priority is useless. It would not be annoying if we reported &quot;b
&amp;gt; c&quot; as an erroneous precedence (because unused). Future grammar
modifications might make this precedence useful.&lt;br&gt;
&lt;br&gt;
I think that we should only report an error on a lexical precedence
that does not involve tokens with &quot;intersecting languages&quot; (I know,
that's not mathematically precise; you get what I mean).&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117030443.GC47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;I think that the general idea should be:
- Putting a parser binary priority on an alternative that is not left 
and right recursive (after inlining) =&amp;gt; error.
- Putting a parser unary priority on an alternative that is not left or 
right recursive (after inlining) =&amp;gt; error.
- Putting a parser priority clause containing a single unary level =&amp;gt; 
error.
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
...or multiple successive unary levels that have the same fixity
(prefix or postfix).
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Right. Hrm... This is a lot of details to check. Sematic verifications
in SableCC 4 =&amp;gt; a curse for me!&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117030443.GC47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;If a specific priority (not in the above list) is specified but remains 
unused =&amp;gt; ignore instead of annoying the user.
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
It might be interesting to know that some assumed ambiguity doesn't
arise after all. (On the other hand, it could just be output in form
of a diagnostic message.)
  &lt;/pre&gt;
&lt;/blockquote&gt;
In the lexer -&amp;gt; see my comments earlier.&lt;br&gt;
&lt;br&gt;
In the parser -&amp;gt; unlikely:&lt;br&gt;
&lt;pre&gt;a = a ...whatever... a | ...&lt;/pre&gt;
is necessarily ambiguous. As soon as you get both left and right
recursion in a &quot;useful&quot; production, there's ambiguity.&lt;br&gt;
&lt;br&gt;
If we detect one-sided only recursion in the Precedence declaration
(that was your detail above), then we know there's no need for
precedence and we report an error.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117030443.GC47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;    statement =
        ...
        {if:}       'if' expr 'then' statement
        {if_else:}  'if' expr 'then' statement 'else' statement

        Precedence
            if_else;
            if;

would still be a shift/reduce conflict?  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
It should. You should definitely try it with beta 2. :)&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117030443.GC47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;And &quot;Dangling&quot; always forces shift?
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Of course; reducing would change the language.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26384030&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26384030.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383853</id>
	<title>Re: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T19:22:33Z</published>
	<updated>2009-11-16T19:22:33Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Tue 2009-11-17 at 10:26h, Christopher Van Kirk wrote on sablecc-discussion:
&lt;br&gt;:
&lt;br&gt;&amp;gt; Also, consider perhaps using 'DelimitedBy' rather than 'Separator'
&lt;br&gt;&amp;gt; if you decide to go with a word.
&lt;br&gt;&lt;br&gt;&amp;quot;Delimiter&amp;quot; is more general than &amp;quot;separator&amp;quot;. Bracketing, quoting and
&lt;br&gt;terminator symbols are all delimiters, but are not separators.
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383853&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383853.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383765</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for	expressions</title>
	<published>2009-11-16T19:04:44Z</published>
	<updated>2009-11-16T19:04:44Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Mon 2009-11-16 at 19:05h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;&amp;gt; Niklas Matthies wrote:
&lt;br&gt;:
&lt;br&gt;&amp;gt; Precedence
&lt;br&gt;&amp;gt; &amp;nbsp; fac;
&lt;br&gt;&amp;gt; &amp;nbsp; Left div;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; It's elegant =&amp;gt; I buy it. :)
&lt;br&gt;&lt;br&gt;Cool!
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;gt;(More generally maybe, making it an error to specify an ambiguity
&lt;br&gt;&amp;gt; &amp;gt;resolution constraint where there is no ambiguity.)
&lt;br&gt;&amp;gt; &amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; Reporting an error on an &amp;quot;invalid&amp;quot; specification is easy.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In the lexer, with the partial order, should you report an error when an 
&lt;br&gt;&amp;gt; ordering ends-up not being used? This might annoy users to no end.
&lt;br&gt;&lt;br&gt;Do you mean redundant (e.g. due to transitivity) order declarations?
&lt;br&gt;&lt;br&gt;&amp;gt; I think that the general idea should be:
&lt;br&gt;&amp;gt; - Putting a parser binary priority on an alternative that is not left 
&lt;br&gt;&amp;gt; and right recursive (after inlining) =&amp;gt; error.
&lt;br&gt;&amp;gt; - Putting a parser unary priority on an alternative that is not left or 
&lt;br&gt;&amp;gt; right recursive (after inlining) =&amp;gt; error.
&lt;br&gt;&amp;gt; - Putting a parser priority clause containing a single unary level =&amp;gt; 
&lt;br&gt;&amp;gt; error.
&lt;br&gt;&lt;br&gt;...or multiple successive unary levels that have the same fixity
&lt;br&gt;(prefix or postfix).
&lt;br&gt;&lt;br&gt;&amp;gt; - Putting a lexer priority between two tokens that don't overlap =&amp;gt; error
&lt;br&gt;&lt;br&gt;Sounds sensible overall.
&lt;br&gt;&lt;br&gt;Some of these will probably need to be relaxed though if or when a
&lt;br&gt;library/inclusion mechanism is introduced.
&lt;br&gt;&lt;br&gt;&amp;gt; If a specific priority (not in the above list) is specified but remains 
&lt;br&gt;&amp;gt; unused =&amp;gt; ignore instead of annoying the user.
&lt;br&gt;&lt;br&gt;It might be interesting to know that some assumed ambiguity doesn't
&lt;br&gt;arise after all. (On the other hand, it could just be output in form
&lt;br&gt;of a diagnostic message.)
&lt;br&gt;&lt;br&gt;In general, there's always the possibility to remove an error when it
&lt;br&gt;turns out to be too annoying. That would be a compatible change, as
&lt;br&gt;opposed to adding an error.
&lt;br&gt;&lt;br&gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; There's a Dangling construct for the dangling ambiguity. It's one of
&lt;br&gt;&amp;gt; the not-yet implemented features.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Will look like:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; stm =
&lt;br&gt;&amp;gt; &amp;nbsp;{if:} 'if' '(' exp ')' stm Dangling else? |
&lt;br&gt;&amp;gt; &amp;nbsp;...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Danging else =
&lt;br&gt;&amp;gt; &amp;nbsp;'else' stm;
&lt;/div&gt;&lt;br&gt;Okay. But
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; statement =
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {if:} &amp;nbsp; &amp;nbsp; &amp;nbsp; 'if' expr 'then' statement
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {if_else:} &amp;nbsp;'if' expr 'then' statement 'else' statement
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if_else;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if;
&lt;br&gt;&lt;br&gt;would still be a shift/reduce conflict?
&lt;br&gt;&lt;br&gt;And &amp;quot;Dangling&amp;quot; always forces shift?
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383765&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383765.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383509</id>
	<title>Re: Linear-approximate LALR(K)	and	ambiguity	resolution	for	expressions</title>
	<published>2009-11-16T18:30:13Z</published>
	<updated>2009-11-16T18:30:13Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Niklas,&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117020730.GB47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;x = ( a b c / d e f )*;
// vs
x = ( a b c Separator d e f)*;
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
Hmm... For some reason it looks slightly odd to me that Separator has
lower precedence than concatenation here. Not that it doesn't make
sense, though.
  &lt;/pre&gt;
&lt;/blockquote&gt;
It is difficult to read:&lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt; x = ( a b c / d e f )*;
&lt;/pre&gt;
as&lt;br&gt;
&lt;pre&gt; x = ( (a b c) / (d e f) )*
&lt;/pre&gt;
My brain keeps seeing:&lt;br&gt;
&lt;pre&gt; x = ( a b ( c / d ) e f )*
&lt;/pre&gt;
But, my brain is able to easily give lower precedence to keywords.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117020730.GB47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;So, 'Separator' is gaining some points. Is there some shorter
synonym (not acronym nor abbreviation) for it?
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
&quot;Link&quot;. But &quot;separator&quot; is the established term for, well, separators.
Unless you want a more general term for when the &quot;separator&quot; is really
an (associative?) operator. In which case &quot;Separated By&quot; would work
better than &quot;Separator&quot;.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
OK, so 'Separator' it remains.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117020730.GB47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Now, that raises another question. Can I write

    expr =
        {mul:} (expr Separator '*')^(2,*)
        {add:} (expr Separator '+')^(2,*)
        {var:}  var

        Precedence
            mul;
            add;

;)

  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Nitpick:&amp;nbsp; &lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt;  {mul:} (expr Separator '*')^(2...)&lt;/pre&gt;
Ouch! My brain hurts...&amp;nbsp; Le me think about it...&lt;br&gt;
&lt;br&gt;
Inlining would give:&lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt;{mul_1:} expr '*' expr |

{mul_2:} expr '*' expr tail | 

tail = tail '*' expr | '*' expr;
&lt;/pre&gt;
&lt;br&gt;
You would get a conflict, as mul and add are not unary operators. But,
had you written:&lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt;  expr =
        {mul:} (expr Separator '*')^(2...)
        {add:} (expr Separator '+')^(2...)
        {var:}  var

        Precedence
           Left mul;
           Left add;
&lt;/pre&gt;
It would have failed, as after inlining, mul_2 is not directly left and
right recursive. Too bad.&lt;br&gt;
&lt;br&gt;
Have fun!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383509&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383509.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383559</id>
	<title>Re: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T18:17:28Z</published>
	<updated>2009-11-16T18:17:28Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Christopher,&lt;br&gt;
&lt;br&gt;
Christopher Van Kirk wrote:
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;With this separator syntax do we always have to boil our delimited element
down to a single production? 
  &lt;/pre&gt;
&lt;/blockquote&gt;
Yep, each of the delimited element and the separator element must be a
single production/token. It's enforced by the syntax.&lt;br&gt;
&lt;br&gt;
This is not the case in the lexer, which is much more flexible, as
regular expressions don't serve to create syntax trees. A regular
expression can be &quot;ambiguous&quot; without causing any problem; all the
lexer needs to report back is the matched string, not the structure of
the match.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Could you say have a production like this:

grid = ( ( '{' ( ( '{' exp '}' ) / ',' )* '}' ) / ',' )*;
	-&amp;gt; [[exp]] (list of lists of exp)
  &lt;/pre&gt;
&lt;/blockquote&gt;
Are you sure of the location of '{' and '}'? Did you mean:&lt;br&gt;
&lt;pre&gt;  grid = '{' (row Separator ',')* '}';
  row = '{' (exp Separator ',')* '}';  
&lt;/pre&gt;
?&lt;br&gt;
&lt;br&gt;
If yes, you can see that the SableCC 4 syntax, even without freely used
parentheses, is much shorter than the SableCC3 syntax to express the
same thing. The big difference is that you get a workable AST without
needing to do CST-&amp;gt;AST transformations with SableCC 4.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Obviously these could be gotten around by breaking up the productions into
smaller pieces, but I'm curious whether they would be disallowed because
they attempt to describe delimited parenthesized expressions.&lt;/pre&gt;
&lt;/blockquote&gt;
Yes. Parentheses are not allowed in productions/alternatives, except
for separated elements.&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt; It also goes
without saying that they are difficult to make sense of.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
It's even worse when you get down to the AST.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Next, can the delimiter itself be an expression or does it have to be a
token?&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
It can be a production (referred by its name). The production can be as
complex as you wish.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt; I can't think of a use case for an expression delimiter off the top
of my head but it would be neat to be able to do something like that.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
If you start adding comments in the grammar, which could potentially be
done with LR(K) without (hopefully) introducing too many conflicts, I
can see production separators.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:AA38450F833E4C5CB1A5C889A157C5BC@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Ps: I'll try very hard not to ask about the AST, but really that's the part
I really care about, so it's tough! Also, consider perhaps using
'DelimitedBy' rather than 'Separator' if you decide to go with a word.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&amp;lt;rant&amp;gt; :) :)&lt;br&gt;
&lt;br&gt;
Is there really a problem understanding that &lt;tt&gt;(id Separator ',')*&lt;/tt&gt;
is a list of ids separated by commas? The idea is not to write the
grammar in English, but to write a &lt;i&gt;readable&lt;/i&gt; grammar.&lt;br&gt;
&lt;br&gt;
It's nice for the grammar to be close to English, but it is not a goal.
The goal is readability. If we wanted perfect English, we would need to
write:&lt;br&gt;
&lt;pre&gt;Token  // singular
 one_token;
&lt;/pre&gt;
and&lt;br&gt;
&lt;pre&gt;Tokens // plural
 first_token, second_token;
&lt;/pre&gt;
I've chosen to try simplifying things in SableCC4. We simply write
&quot;Ignored&quot;, instead of &quot;Ignored Tokens&quot;. I don't think that grammars are
less readable for it. 'Separator' is shorter than 'Separated' 'By' and
'Delimited' 'By'.&amp;nbsp; Ideally, I would like an 8 letters or less word.
'Separator', at 9 letters, seems a little long but I can live with it.&lt;br&gt;
&lt;br&gt;
&amp;lt;/rant&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I know, I know... Your fingers are burning to write the C# back-end.
We'll get there. It's not too far, now!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Have fun!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383559&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383559.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383347</id>
	<title>Re: Linear-approximate LALR(K) and	ambiguity	resolution	for	expressions</title>
	<published>2009-11-16T18:07:30Z</published>
	<updated>2009-11-16T18:07:30Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Mon 2009-11-16 at 20:00h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;:
&lt;br&gt;&amp;gt; The bigger danger, for the readability of the '/' operator would be 
&lt;br&gt;&amp;gt; within lexers. Within the parser, the separeted element and the 
&lt;br&gt;&amp;gt; separator element must both be simple elements (identifier or inline 
&lt;br&gt;&amp;gt; token). Within the lexer, things get uglier:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; x = ( a b c / d e f )*;
&lt;br&gt;&amp;gt; // vs
&lt;br&gt;&amp;gt; x = ( a b c Separator d e f)*;
&lt;br&gt;&lt;br&gt;Hmm... For some reason it looks slightly odd to me that Separator has
&lt;br&gt;lower precedence than concatenation here. Not that it doesn't make
&lt;br&gt;sense, though.
&lt;br&gt;&lt;br&gt;&amp;gt; So, 'Separator' is gaining some points. Is there some shorter
&lt;br&gt;&amp;gt; synonym (not acronym nor abbreviation) for it?
&lt;br&gt;&lt;br&gt;&amp;quot;Link&amp;quot;. But &amp;quot;separator&amp;quot; is the established term for, well, separators.
&lt;br&gt;Unless you want a more general term for when the &amp;quot;separator&amp;quot; is really
&lt;br&gt;an (associative?) operator. In which case &amp;quot;Separated By&amp;quot; would work
&lt;br&gt;better than &amp;quot;Separator&amp;quot;.
&lt;br&gt;&lt;br&gt;Now, that raises another question. Can I write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; expr =
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {mul:} (expr Separator '*')^(2,*)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {add:} (expr Separator '+')^(2,*)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {var:} &amp;nbsp;var
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mul;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; add;
&lt;br&gt;&lt;br&gt;;)
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383347&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383347.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26383036</id>
	<title>RE: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T17:29:24Z</published>
	<updated>2009-11-16T17:29:24Z</updated>
	<author>
		<name>Christopher Van Kirk</name>
	</author>
	<content type="html">No problem. I'll get my revenge by asking many more silly questions over the
&lt;br&gt;course of your beta that you will be obliged to answer.
&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383036&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
&lt;br&gt;[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383036&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;.
&lt;br&gt;org] On Behalf Of Etienne M. Gagnon
&lt;br&gt;Sent: Tuesday, November 17, 2009 10:07 AM
&lt;br&gt;To: Discussion mailing list for the SableCC project
&lt;br&gt;Subject: Re: Linear-approximate LALR(K) and ambiguityresolution for
&lt;br&gt;expressions
&lt;br&gt;&lt;br&gt;Hi Christopher,
&lt;br&gt;&lt;br&gt;Etienne M. Gagnon wrote:
&lt;br&gt;&amp;gt; Ah! No, I don't want to explain this!...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Because you don't get 0 expressions? Why don't we simply write 'exp 
&lt;br&gt;&amp;gt; exp*' instead of 'exp+' ? What does the AST looks like? What names do 
&lt;br&gt;&amp;gt; you give to &amp;quot;exp&amp;quot;, &amp;quot;,&amp;quot; and &amp;quot;exp&amp;quot;? ...
&lt;br&gt;&lt;br&gt;Reading myself back, I'm afraid that this didn't come out the way I 
&lt;br&gt;intended. I should have put a few smiles around to indicate my intended 
&lt;br&gt;light tone. It looks so serious on reading!
&lt;br&gt;&lt;br&gt;You were just asking the question I had tried hard not to get! I really 
&lt;br&gt;don't want to get into the AST discussion (which is, as you 
&lt;br&gt;unconsciously realized, the real motivation for adding this operator).
&lt;br&gt;&lt;br&gt;So, thanks for your question, and please (re-)read my answer with a few 
&lt;br&gt;smiles.
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383036&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26383036&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26383036.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382975</id>
	<title>RE: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T17:26:18Z</published>
	<updated>2009-11-16T17:26:18Z</updated>
	<author>
		<name>Christopher Van Kirk</name>
	</author>
	<content type="html">Sorry about that. My example didn't quite match yours, but I do see why it
&lt;br&gt;wouldn't work.
&lt;br&gt;&lt;br&gt;With this separator syntax do we always have to boil our delimited element
&lt;br&gt;down to a single production? 
&lt;br&gt;&lt;br&gt;Could you say have a production like this:
&lt;br&gt;&lt;br&gt;grid = ( ( '{' ( ( '{' exp '}' ) / ',' )* '}' ) / ',' )*;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt; [[exp]] (list of lists of exp)
&lt;br&gt;&lt;br&gt;or this:
&lt;br&gt;&lt;br&gt;grid = ( ( '{' row '}' ) / ',' )* )
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt; [row] (list of rows)
&lt;br&gt;row = ( ( '{' exp '}' ) / ',' )* )
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt; [exp] (list of exp's)
&lt;br&gt;&lt;br&gt;Obviously these could be gotten around by breaking up the productions into
&lt;br&gt;smaller pieces, but I'm curious whether they would be disallowed because
&lt;br&gt;they attempt to describe delimited parenthesized expressions. It also goes
&lt;br&gt;without saying that they are difficult to make sense of.
&lt;br&gt;&lt;br&gt;Next, can the delimiter itself be an expression or does it have to be a
&lt;br&gt;token? I can't think of a use case for an expression delimiter off the top
&lt;br&gt;of my head but it would be neat to be able to do something like that.
&lt;br&gt;&lt;br&gt;Chris...
&lt;br&gt;&lt;br&gt;Ps: I'll try very hard not to ask about the AST, but really that's the part
&lt;br&gt;I really care about, so it's tough! Also, consider perhaps using
&lt;br&gt;'DelimitedBy' rather than 'Separator' if you decide to go with a word.
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382975&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
&lt;br&gt;[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382975&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;.
&lt;br&gt;org] On Behalf Of Etienne M. Gagnon
&lt;br&gt;Sent: Tuesday, November 17, 2009 9:24 AM
&lt;br&gt;To: Discussion mailing list for the SableCC project
&lt;br&gt;Subject: Re: Linear-approximate LALR(K) and ambiguityresolution for
&lt;br&gt;expressions
&lt;br&gt;&lt;br&gt;Christopher Van Kirk wrote:
&lt;br&gt;&amp;gt; Throwing my nonsensical two cents in:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What would be wrong with:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; fun_call = id '(' exp [',' exp ]* ')';
&lt;br&gt;&lt;br&gt;Ah! No, I don't want to explain this!...
&lt;br&gt;&lt;br&gt;Because you don't get 0 expressions? Why don't we simply write 'exp 
&lt;br&gt;exp*' instead of 'exp+' ? What does the AST looks like? What names do 
&lt;br&gt;you give to &amp;quot;exp&amp;quot;, &amp;quot;,&amp;quot; and &amp;quot;exp&amp;quot;? ...
&lt;br&gt;&lt;br&gt;The AST problem is real; you need names so that visitors work. You need 
&lt;br&gt;to also be able to specify CST-&amp;gt;AST transformations with a simple 
&lt;br&gt;syntax. You lose simplicity as soon as you add parentheses to 
&lt;br&gt;alternatives. The separator syntax is my only deviation off this, but it 
&lt;br&gt;is a specific case that can be handled relatively simply (as I've put 
&lt;br&gt;strict syntactic rules on its use).
&lt;br&gt;&lt;br&gt;----
&lt;br&gt;(Opening a can of worm and regretting it soon...)
&lt;br&gt;&lt;br&gt;With SableCC 4, you would write:
&lt;br&gt;&lt;br&gt;&amp;nbsp;fun_call = id '(' [args:](exp / ',')* ')';
&lt;br&gt;&lt;br&gt;You could then write (in Java):
&lt;br&gt;&lt;br&gt;&amp;nbsp;case_FunCall(NFunCall node) {
&lt;br&gt;&amp;nbsp; &amp;nbsp;String function_name = node.get_Id().getText();
&lt;br&gt;&amp;nbsp; &amp;nbsp;node.getArgs().apply(this); // visit args
&lt;br&gt;&amp;nbsp; &amp;nbsp;...
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;(Closing the can of worms, and hoping very much that nobody discusses 
&lt;br&gt;the AST at this point...)
&lt;br&gt;---
&lt;br&gt;&lt;br&gt;If you really want something similar, simply write:
&lt;br&gt;&lt;br&gt;fun_call = id '(' exp_list? ')';
&lt;br&gt;&lt;br&gt;exp_list = exp additional_exp*;
&lt;br&gt;&lt;br&gt;additional_exp = ',' exp;
&lt;br&gt;&lt;br&gt;At least, you'll get an AST with good names, and it'll be easy to do 
&lt;br&gt;tree transformations.
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382975&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382975&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382975.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382868</id>
	<title>Re: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T17:06:31Z</published>
	<updated>2009-11-16T17:06:31Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">Hi Christopher,
&lt;br&gt;&lt;br&gt;Etienne M. Gagnon wrote:
&lt;br&gt;&amp;gt; Ah! No, I don't want to explain this!...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Because you don't get 0 expressions? Why don't we simply write 'exp 
&lt;br&gt;&amp;gt; exp*' instead of 'exp+' ? What does the AST looks like? What names do 
&lt;br&gt;&amp;gt; you give to &amp;quot;exp&amp;quot;, &amp;quot;,&amp;quot; and &amp;quot;exp&amp;quot;? ...
&lt;br&gt;&lt;br&gt;Reading myself back, I'm afraid that this didn't come out the way I 
&lt;br&gt;intended. I should have put a few smiles around to indicate my intended 
&lt;br&gt;light tone. It looks so serious on reading!
&lt;br&gt;&lt;br&gt;You were just asking the question I had tried hard not to get! I really 
&lt;br&gt;don't want to get into the AST discussion (which is, as you 
&lt;br&gt;unconsciously realized, the real motivation for adding this operator).
&lt;br&gt;&lt;br&gt;So, thanks for your question, and please (re-)read my answer with a few 
&lt;br&gt;smiles.
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382868&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382868.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382768</id>
	<title>Re: Linear-approximate LALR(K) and	ambiguity	resolution	for	expressions</title>
	<published>2009-11-16T17:00:02Z</published>
	<updated>2009-11-16T17:00:02Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117002959.GA47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;No argument here, except that &quot;matched by a token&quot; sounds very wrong
to me, as opposed to &quot;matched by a token definition/lexer rule&quot; (and
the result of the match being a token). IMO it unduly blurs the
difference between 'id' (= a token class) and 'id(&quot;if&quot;)' (= a
particular token). The mathematical entities on which the precedence
is declared upon are the former, not the latter. These are distinct
concepts. It's like confusing objects with classes. If you say that
the string &quot;if&quot; is matched by the token 'id(&quot;id&quot;)', then you must also
say that it isn't matched by the token 'id(&quot;foo&quot;)'. That doesn't make
sense. What's relevant is that &quot;if&quot; is matched by 'id', and whether it
is a longest match, and then whether it is unique in that capacity or
whether there are other longest matches.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
OK, my vocabulary wasn't mathematically perfect. :)&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117002959.GA47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Yeah I'm ranting :). But this is exactly the kind of mixing up of
concepts that used to confuse the hell out of me when I was still
studying.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Luckily, the website is a Wiki. You'll be able to help clarify my
inexact explanations! :)&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117002959.GA47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;The other thing, we shouldn't forget, is the context of use. A typical 
use will look like:

 var_decl = 'var' (id / ',')+ ';'

Question: If this was the first time you saw it, would you /guess/ the 
semantics of &quot;/&quot; correctly?
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
I _suspect_ that I would wonder whether it means some kind of
alternative (like |) or something like that. Ah, here's the real
deal: As there are parentheses around it, I would naturally assume
that &quot;/&quot; is a self-sufficient operator. For example that one could
define a production

    foo = id / ',';

Any guesses on what &quot;/&quot; means would tend to be based on that
assumption. The truth, though, is that &quot;id / ','&quot; is incomplete by
itself, it requires a repetition operator to be applied.

Incidentally, this is one more reason why I would prefer putting the
separation operator outside rather than inside.For 
  &lt;/pre&gt;
&lt;/blockquote&gt;
For me:&lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt;  var_decl = 'var' (id Separator ',')+ ';';&lt;/pre&gt;
is explicit enough so that my brain sees clearly that 'Separator' is
only making sense within its enclosing '(...)+' list.&lt;br&gt;
&lt;br&gt;
The bigger danger, for the readability of the '/' operator would be
within lexers. Within the parser, the separeted element and the
separator element must both be simple elements (identifier or inline
token). Within the lexer, things get uglier:&lt;br&gt;
&lt;pre&gt;x = ( a b c / d e f )*;
// vs
x = ( a b c Separator d e f)*;
&lt;/pre&gt;
So, 'Separator' is gaining some points. Is there some shorter synonym
(not acronym nor abbreviation) for it?&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091117002959.GA47883@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;And we revert &quot;Diff&quot; to &quot;Difference&quot; to remove the temptation of 
proposing abbreviated keywords. :)
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
&quot;Diff&quot; was infix, right? How about &quot;Except&quot; or &quot;Minus&quot; then?
It's always weird when infix operators don't have infix names
(like &quot;x add y&quot; instead of &quot;x plus y&quot;).
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Minus is not a good idea, as we already use &quot;-&quot; (the minus symbol) for
lexical subtraction.&lt;br&gt;
&lt;br&gt;
On the other hand, I very much like 'Except':&lt;br&gt;
&lt;pre&gt;id = letter (letter | digit)* Except ('if' | 'else' | 'while');
&lt;/pre&gt;
Thanks!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382768&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382768.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382532</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity	resolution	for	expressions</title>
	<published>2009-11-16T16:29:59Z</published>
	<updated>2009-11-16T16:29:59Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Mon 2009-11-16 at 17:05h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Don't forget the the lexer *first* looks for the longest match. So,
&lt;br&gt;&amp;gt; if the input is:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; iffy
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; the lexer will match and identifier over matching the 'if' keyword.
&lt;br&gt;&amp;gt; So, in terms of making things clear for users, I really prefer to
&lt;br&gt;&amp;gt; keep explaining things in terms of *first* finding the longest
&lt;br&gt;&amp;gt; string that is matched by tokens, then *second* selecting the token
&lt;br&gt;&amp;gt; with the highest precedence.
&lt;/div&gt;&lt;br&gt;No argument here, except that &amp;quot;matched by a token&amp;quot; sounds very wrong
&lt;br&gt;to me, as opposed to &amp;quot;matched by a token definition/lexer rule&amp;quot; (and
&lt;br&gt;the result of the match being a token). IMO it unduly blurs the
&lt;br&gt;difference between 'id' (= a token class) and 'id(&amp;quot;if&amp;quot;)' (= a
&lt;br&gt;particular token). The mathematical entities on which the precedence
&lt;br&gt;is declared upon are the former, not the latter. These are distinct
&lt;br&gt;concepts. It's like confusing objects with classes. If you say that
&lt;br&gt;the string &amp;quot;if&amp;quot; is matched by the token 'id(&amp;quot;id&amp;quot;)', then you must also
&lt;br&gt;say that it isn't matched by the token 'id(&amp;quot;foo&amp;quot;)'. That doesn't make
&lt;br&gt;sense. What's relevant is that &amp;quot;if&amp;quot; is matched by 'id', and whether it
&lt;br&gt;is a longest match, and then whether it is unique in that capacity or
&lt;br&gt;whether there are other longest matches.
&lt;br&gt;&lt;br&gt;Yeah I'm ranting :). But this is exactly the kind of mixing up of
&lt;br&gt;concepts that used to confuse the hell out of me when I was still
&lt;br&gt;studying.
&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; &amp;gt;So how about:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;nbsp; &amp;nbsp;fun_call = id '(' exp* SeparatedBy ',' ')';
&lt;br&gt;&amp;gt; &amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I actually had &amp;quot;Separated By&amp;quot; as two keywords, initially. The problem is 
&lt;br&gt;&amp;gt; that this results in a tedious syntax for a common pattern; not 
&lt;br&gt;&amp;gt; necessarily a good idea.
&lt;br&gt;&lt;br&gt;I don't know. In the long run, readability is always more important
&lt;br&gt;than ease of writing. And grammars aren't something you write all the
&lt;br&gt;time (well, *you* probably do ;)), it's something you engage in for a
&lt;br&gt;week or two or three, and then a year later or so you (or, as likely,
&lt;br&gt;a colleague) need to revisit the grammar to add a new feature or the
&lt;br&gt;like, and at that point you certainly don't remember all the details
&lt;br&gt;of the grammar syntax, and the subject matter is already complicated
&lt;br&gt;enough as it is. So, I would opt for the less cryptic.
&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; The problem, in your syntax, is that we see a single &amp;quot;,&amp;quot;, yet, in the 
&lt;br&gt;&amp;gt; parse tree, there are as many &amp;quot;,&amp;quot; as &amp;quot;exp&amp;quot; minus one. This is why I 
&lt;br&gt;&amp;gt; decided that the * would be outside the parentheses.
&lt;br&gt;&lt;br&gt;Well, my perception seems to work differently here (I have not problem
&lt;br&gt;seeing &amp;quot;SeperatedBy something&amp;quot; as an operator on repetitions), but
&lt;br&gt;it's your choice of course.
&lt;br&gt;&lt;br&gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;gt;Maybe making &amp;quot;Sep&amp;quot; an alias would be acceptable:
&lt;br&gt;&amp;gt; &amp;gt; &amp;nbsp; &amp;nbsp;fun_call = id '(' exp* Sep ',' ')';
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;A decent editor will have word completion of course. ;)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I don't like aliases; we have to chose something and stick with it.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Users, when they see two different syntactic structures, expect a 
&lt;br&gt;&amp;gt; distinct semantics. Aliases break this assumption, and users start 
&lt;br&gt;&amp;gt; dreaming up arbitrary semantic differences...
&lt;/div&gt;&lt;br&gt;True. As a matter of fact, this is exactly the &amp;quot;different/same names&amp;quot;
&lt;br&gt;argument I made elsewehere. :)
&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; The other thing, we shouldn't forget, is the context of use. A typical 
&lt;br&gt;&amp;gt; use will look like:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;var_decl = 'var' (id / ',')+ ';'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Question: If this was the first time you saw it, would you /guess/ the 
&lt;br&gt;&amp;gt; semantics of &amp;quot;/&amp;quot; correctly?
&lt;br&gt;&lt;br&gt;I _suspect_ that I would wonder whether it means some kind of
&lt;br&gt;alternative (like |) or something like that. Ah, here's the real
&lt;br&gt;deal: As there are parentheses around it, I would naturally assume
&lt;br&gt;that &amp;quot;/&amp;quot; is a self-sufficient operator. For example that one could
&lt;br&gt;define a production
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; foo = id / ',';
&lt;br&gt;&lt;br&gt;Any guesses on what &amp;quot;/&amp;quot; means would tend to be based on that
&lt;br&gt;assumption. The truth, though, is that &amp;quot;id / ','&amp;quot; is incomplete by
&lt;br&gt;itself, it requires a repetition operator to be applied.
&lt;br&gt;&lt;br&gt;Incidentally, this is one more reason why I would prefer putting the
&lt;br&gt;separation operator outside rather than inside.
&lt;br&gt;&lt;br&gt;&amp;gt; And we revert &amp;quot;Diff&amp;quot; to &amp;quot;Difference&amp;quot; to remove the temptation of 
&lt;br&gt;&amp;gt; proposing abbreviated keywords. :)
&lt;br&gt;&lt;br&gt;&amp;quot;Diff&amp;quot; was infix, right? How about &amp;quot;Except&amp;quot; or &amp;quot;Minus&amp;quot; then?
&lt;br&gt;It's always weird when infix operators don't have infix names
&lt;br&gt;(like &amp;quot;x add y&amp;quot; instead of &amp;quot;x plus y&amp;quot;).
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382532&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382532.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382499</id>
	<title>Re: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T16:24:18Z</published>
	<updated>2009-11-16T16:24:18Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">Christopher Van Kirk wrote:
&lt;br&gt;&amp;gt; Throwing my nonsensical two cents in:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What would be wrong with:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; fun_call = id '(' exp [',' exp ]* ')';
&lt;br&gt;&lt;br&gt;Ah! No, I don't want to explain this!...
&lt;br&gt;&lt;br&gt;Because you don't get 0 expressions? Why don't we simply write 'exp 
&lt;br&gt;exp*' instead of 'exp+' ? What does the AST looks like? What names do 
&lt;br&gt;you give to &amp;quot;exp&amp;quot;, &amp;quot;,&amp;quot; and &amp;quot;exp&amp;quot;? ...
&lt;br&gt;&lt;br&gt;The AST problem is real; you need names so that visitors work. You need 
&lt;br&gt;to also be able to specify CST-&amp;gt;AST transformations with a simple 
&lt;br&gt;syntax. You lose simplicity as soon as you add parentheses to 
&lt;br&gt;alternatives. The separator syntax is my only deviation off this, but it 
&lt;br&gt;is a specific case that can be handled relatively simply (as I've put 
&lt;br&gt;strict syntactic rules on its use).
&lt;br&gt;&lt;br&gt;----
&lt;br&gt;(Opening a can of worm and regretting it soon...)
&lt;br&gt;&lt;br&gt;With SableCC 4, you would write:
&lt;br&gt;&lt;br&gt;&amp;nbsp;fun_call = id '(' [args:](exp / ',')* ')';
&lt;br&gt;&lt;br&gt;You could then write (in Java):
&lt;br&gt;&lt;br&gt;&amp;nbsp;case_FunCall(NFunCall node) {
&lt;br&gt;&amp;nbsp; &amp;nbsp;String function_name = node.get_Id().getText();
&lt;br&gt;&amp;nbsp; &amp;nbsp;node.getArgs().apply(this); // visit args
&lt;br&gt;&amp;nbsp; &amp;nbsp;...
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;(Closing the can of worms, and hoping very much that nobody discusses 
&lt;br&gt;the AST at this point...)
&lt;br&gt;---
&lt;br&gt;&lt;br&gt;If you really want something similar, simply write:
&lt;br&gt;&lt;br&gt;fun_call = id '(' exp_list? ')';
&lt;br&gt;&lt;br&gt;exp_list = exp additional_exp*;
&lt;br&gt;&lt;br&gt;additional_exp = ',' exp;
&lt;br&gt;&lt;br&gt;At least, you'll get an AST with good names, and it'll be easy to do 
&lt;br&gt;tree transformations.
&lt;br&gt;&lt;br&gt;Etienne
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Etienne M. Gagnon, Ph.D.
&lt;br&gt;SableCC: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382499&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382499.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382492</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for	expressions</title>
	<published>2009-11-16T16:05:26Z</published>
	<updated>2009-11-16T16:05:26Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Niklas Matthies wrote:
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;[...]
  &lt;pre wrap=&quot;&quot;&gt;So we need to write

    Precedence
        Right fac;
        Left div;

or

    Precedence
        Left fac;
        Left div;

where Left vs. Right doesn't make any difference for fac.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Right, but it still works. Not elegant, I concede, and I seek elegance
in SableCC.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;[...]
Saying that these operators have the same precedence is meaningless,
and having to specify Left or Right for prefix/postfix operators is
pointless.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Makes sense.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;
Therefore it would be useful to be able to write

    Precedence
        fac;
        Left div;
[...]
(Or possibly something like &quot;Unary fac;&quot; if a keyword is absolutely
needed.)
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
'Unary' and 'Associative' are two keywords I have eliminated.
Originally, the syntax was:&lt;br&gt;
&lt;pre&gt; Precedence
   Right Unary fac;  // operator appears on the right
   Left Associative div;
&lt;/pre&gt;
I was seeking a lighter syntax, thus what SableCC currently implements.&lt;br&gt;
&lt;br&gt;
I like your idea to specify unary opertor precedence levels without any
keyword. This way, the use of a keyword is reserved for &quot;associativity&quot;.&lt;br&gt;
&lt;pre&gt; Precedence
   fac;
   Left div;
&lt;/pre&gt;
It's elegant =&amp;gt; I buy it. :)&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;(More generally maybe, making it an error to specify an ambiguity
resolution constraint where there is no ambiguity.)
  &lt;/pre&gt;
&lt;/blockquote&gt;
Reporting an error on an &quot;invalid&quot; specification is easy.&lt;br&gt;
&lt;br&gt;
In the lexer, with the partial order, should you report an error when
an ordering ends-up not being used? This might annoy users to no end.&lt;br&gt;
&lt;br&gt;
I think that the general idea should be:&lt;br&gt;
&amp;nbsp;- Putting a parser binary priority on an alternative that is not left
and right recursive (after inlining) =&amp;gt; error.&lt;br&gt;
&amp;nbsp;- Putting a parser unary priority on an alternative that is not left
or right recursive (after inlining) =&amp;gt; error.&lt;br&gt;
&amp;nbsp;- Putting a parser priority clause containing a single unary level
=&amp;gt; error.&lt;br&gt;
&amp;nbsp;- Putting a lexer priority between two tokens that don't overlap =&amp;gt;
error&lt;br&gt;
&lt;br&gt;
If a specific priority (not in the above list) is specified but remains
unused =&amp;gt; ignore instead of annoying the user.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;More questions:

Can the ambiguity resolution also be used to disambiguate dangling
else?
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
There's a Dangling construct for the dangling ambiguity. It's one of
the not-yet implemented features.&lt;br&gt;
&lt;br&gt;
Will look like:&lt;br&gt;
&lt;pre&gt; stm =
  {if:} 'if' '(' exp ')' stm Dangling else? |
  ...

 Danging else =
  'else' stm;

&lt;/pre&gt;
&lt;blockquote cite=&quot;mid:20091116225948.GB91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;And would the following work:

    exp =
        {add:} add_exp |
        {mul:} mul_exp |
        {num:} num;
   
        Priority
            Left mul;
            Left add;

    add_exp = exp '+' exp;
    mul_exp = exp '*' exp;
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Yes through implicit inlining, when tree transformations and inlining
are implemented.&amp;nbsp; The following will also work:&lt;br&gt;
&lt;pre&gt; exp =
  {add:}      exp add_op exp |
  {mul:}      exp mul_op exp |
  {fac:}      exp fac_op |
  {num:} num;

  Priority
   fac;
   Left mul;
   Left add;

 add_op = '+' | '-';
 mul_op = '*' | '/' | '%';
 fac_op = '!';
&lt;/pre&gt;
SableCC will inline the element right of &quot;exp&quot; until it finds a token
and report an error if it can't get a token.&lt;br&gt;
&lt;br&gt;
The rule, for inlining a production, is that it must not be directly
recursive. SableCC will apply explicit inlining requests, first, to
avoid giving users surprising error messages.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382492&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382492.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26382075</id>
	<title>RE: Linear-approximate LALR(K) and ambiguityresolution	for	expressions</title>
	<published>2009-11-16T15:52:33Z</published>
	<updated>2009-11-16T15:52:33Z</updated>
	<author>
		<name>Christopher Van Kirk</name>
	</author>
	<content type="html">Throwing my nonsensical two cents in:
&lt;br&gt;&lt;br&gt;What would be wrong with:
&lt;br&gt;&lt;br&gt;fun_call = id '(' exp [',' exp ]* ')';
&lt;br&gt;&lt;br&gt;Where the square braces indicate an optional parameter. This is usually how
&lt;br&gt;it looks in the manuals.
&lt;br&gt;&lt;br&gt;Chris...
&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382075&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
&lt;br&gt;[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382075&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;.
&lt;br&gt;org] On Behalf Of Niklas Matthies
&lt;br&gt;Sent: Tuesday, November 17, 2009 6:11 AM
&lt;br&gt;To: Discussion mailing list for the SableCC project
&lt;br&gt;Subject: Re: Linear-approximate LALR(K) and ambiguityresolution for
&lt;br&gt;expressions
&lt;br&gt;&lt;br&gt;Hi,
&lt;br&gt;&lt;br&gt;On Mon 2009-11-16 at 14:15h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;&amp;gt; Niklas Matthies wrote:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;Just to make sure: I should use 'Precedence' to describe both &amp;quot;token 
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;precedence&amp;quot; (in the lexer) and &amp;quot;operator precedence&amp;quot; (in the parser), as
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;in the following example. Right?
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;It's less common to apply the term &amp;quot;precedence&amp;quot; to tokens (actually
&lt;br&gt;&amp;gt; &amp;gt;it's not about the precedence of tokens here, but of token definitions!),
&lt;br&gt;&amp;gt; &amp;gt;but it isn't wrong either. So, why not.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Given a string matched by N distinct tokens, we want to select the token 
&lt;br&gt;&amp;gt; that has precedence over all other tokens. Of course, the implementation 
&lt;br&gt;&amp;gt; can be done by &amp;quot;changing&amp;quot; token definitions so that only one token 
&lt;br&gt;&amp;gt; matches a given string, yet, theoretically, all of the N tokens match.
&lt;/div&gt;&lt;br&gt;I'd say that it is input words that match, or are matched by, token
&lt;br&gt;definitions (which define sets of words), and the result of each match
&lt;br&gt;is a token. Of course you can say that
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; plus &amp;gt; id
&lt;br&gt;&lt;br&gt;means that each token that is the result of a successful match of
&lt;br&gt;&amp;quot;plus&amp;quot; has precedence over all tokens that are the result of a
&lt;br&gt;successful match of &amp;quot;id&amp;quot;, but IMO it's more straightforward to say
&lt;br&gt;that the token definition &amp;quot;plus&amp;quot; has precedence over the token
&lt;br&gt;definition &amp;quot;id&amp;quot; for input words that match both definitions.
&lt;br&gt;&lt;br&gt;Just like precedence declarations on the parser level define
&lt;br&gt;precedence of one production over another, not of syntax tree nodes
&lt;br&gt;over other syntax tree nodes.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;gt;One other thing I'm noticing here is that in the parser, the
&lt;br&gt;&amp;gt; &amp;gt;precedence levels are separated by &amp;quot;;&amp;quot;, while here the precedence is
&lt;br&gt;&amp;gt; &amp;gt;marked by &amp;quot;&amp;gt;&amp;quot;. This could be a reason to use different names for these
&lt;br&gt;&amp;gt; &amp;gt;sections or to align their syntax.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In the parser, precedence is a total order, and each precedence level 
&lt;br&gt;&amp;gt; requires an associativity declaration. The lexer supports partial 
&lt;br&gt;&amp;gt; ordering (actually, currently it requires a total order, but this will 
&lt;br&gt;&amp;gt; change). The lexer has no concept of associativity, so &amp;quot;&amp;gt;&amp;quot; just gets the 
&lt;br&gt;&amp;gt; job done.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; SableCC 4 already has many new keywords. I've worked hard at reducing 
&lt;br&gt;&amp;gt; their number to a minimum, while not making the language cryptic.
&lt;/div&gt;&lt;br&gt;Right, but consistency is also a design force. Different things should
&lt;br&gt;have different syntax/names and same things the same syntax/names.
&lt;br&gt;I'm not saying the current syntax is bad, but it's a point to be
&lt;br&gt;considered.
&lt;br&gt;&lt;br&gt;&amp;gt; There's still one keyword I'm not sure about: &amp;quot;Separator&amp;quot; (usable in 
&lt;br&gt;&amp;gt; lexers and parsers):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;fun_call = id '(' (exp Separator ',')* ')';
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I am toying with the idea of replacing it with '/' as is &amp;quot;divided by&amp;quot; 
&lt;br&gt;&amp;gt; (which is an common definition for this operator):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;fun_call = id '(' (exp / ',')* ')';
&lt;br&gt;&lt;br&gt;The drawback of &amp;quot;/&amp;quot; is that one has to know what it means, as it isn't
&lt;br&gt;self-evident at all, and not a standard syntax like the Kleene star.
&lt;br&gt;Using the division operator &amp;quot;/&amp;quot; in the sense of &amp;quot;separated by&amp;quot; is
&lt;br&gt;quite a far stretch, even as a mnemonic.
&lt;br&gt;&lt;br&gt;In a fluent[1] Java API for regular expressions I wrote, one can write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Regex expr = ...;
&lt;br&gt;&amp;nbsp; &amp;nbsp; Regex args = zeroOrMore(expr).separatedBy(',');
&lt;br&gt;&lt;br&gt;So how about:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; fun_call = id '(' exp* SeparatedBy ',' ')';
&lt;br&gt;&lt;br&gt;That would be more self-explanatory. Putting the separator &amp;quot;outside&amp;quot;
&lt;br&gt;of the repition has some benefits: It doesn't require an extra set of
&lt;br&gt;parentheses, it's arguably easier to read out loud in a comprehensible
&lt;br&gt;way, it keeps the AST facts (&amp;quot;here we have a list of expressions&amp;quot;)
&lt;br&gt;together (&amp;quot;exp*&amp;quot;), and lastly the separator comes more expected when
&lt;br&gt;the repetition has already been established (e.g.
&lt;br&gt;&amp;quot;expr.separatedBy(',').zeroOrMore()&amp;quot; wouldn't be quite as readable).
&lt;br&gt;&lt;br&gt;[1] &lt;a href=&quot;http://martinfowler.com/bliki/FluentInterface.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://martinfowler.com/bliki/FluentInterface.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; The separator is likely to be a commonly used operator in parsing 
&lt;br&gt;&amp;gt; grammars, so making common things easy to type is not a bad idea.
&lt;br&gt;&lt;br&gt;Maybe making &amp;quot;Sep&amp;quot; an alias would be acceptable:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; fun_call = id '(' exp* Sep ',' ')';
&lt;br&gt;&lt;br&gt;A decent editor will have word completion of course. ;)
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382075&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26382075&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26382075.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26381566</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-16T14:59:48Z</published>
	<updated>2009-11-16T14:59:48Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Sun 2009-11-15 at 15:24h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;:
&lt;br&gt;&amp;gt; Actually, with unary operators you still have to decide whether you
&lt;br&gt;&amp;gt; want to give left or right priority, e.g.:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; ++ a - b &amp;nbsp;(assuming ++ and - have the same precedence level) =&amp;gt;
&lt;br&gt;&amp;gt; left &amp;nbsp;: (++ a) - b
&lt;br&gt;&amp;gt; right : ++ (a - b)
&lt;br&gt;&lt;br&gt;Er, no. This is not right vs. left, it's just different precedence.
&lt;br&gt;Take the example of a language with two operators, a left-associative
&lt;br&gt;binary operator div := '/' and a postfix operator fac != '!', where 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; a!/b!/c! &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(*)
&lt;br&gt;&lt;br&gt;should be parsed as
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; ((a!)/(b!))/(c!)
&lt;br&gt;&lt;br&gt;We can't write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left div, fac;
&lt;br&gt;&lt;br&gt;because this would result in (*) being parsed as
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; (((((a!)/b)!)/c)!
&lt;br&gt;&lt;br&gt;Of course we also can't write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Right div, fac;
&lt;br&gt;&lt;br&gt;which would cause (*) to be parsed as
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; (a!)/((b!)/(c!))
&lt;br&gt;&lt;br&gt;So we need to write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Right fac;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left div;
&lt;br&gt;&lt;br&gt;or
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left fac;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left div;
&lt;br&gt;&lt;br&gt;where Left vs. Right doesn't make any difference for fac.
&lt;br&gt;&lt;br&gt;More generally,
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left prefix_op, infix_op, suffix_op;
&lt;br&gt;&lt;br&gt;is always equivalent to
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Left or Right&amp;gt; prefix_op;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left infix_op;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Left or Right&amp;gt; suffix_op;
&lt;br&gt;&lt;br&gt;and
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Right prefix_op, infix_op, suffix_op;
&lt;br&gt;&lt;br&gt;is always equivalent to
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Left or Right&amp;gt; suffix_op;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Right infix_op;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Left or Right&amp;gt; prefix_op;
&lt;br&gt;&lt;br&gt;Saying that these operators have the same precedence is meaningless,
&lt;br&gt;and having to specify Left or Right for prefix/postfix operators is
&lt;br&gt;pointless.
&lt;br&gt;&lt;br&gt;Therefore it would be useful to be able to write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fac;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left div;
&lt;br&gt;&lt;br&gt;and (to take my previous example)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Precedence
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cond, filter;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left map, map_filter;
&lt;br&gt;&lt;br&gt;(Or possibly something like &amp;quot;Unary fac;&amp;quot; if a keyword is absolutely
&lt;br&gt;needed.)
&lt;br&gt;&lt;br&gt;I would also advocate making
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left fac;
&lt;br&gt;&lt;br&gt;an error, and by consequence also
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left div, fac;
&lt;br&gt;&lt;br&gt;(More generally maybe, making it an error to specify an ambiguity
&lt;br&gt;resolution constraint where there is no ambiguity.)
&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; Yet, I wouldn't be surprised if your intentions were actually to
&lt;br&gt;&amp;gt; disallow : if if a else if b else c else if d else e.
&lt;br&gt;&lt;br&gt;There are some 'thens' missing here. I suppose you mean something like:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if if a then b else c then if d then e else f else if g then h else i
&lt;br&gt;&lt;br&gt;I wouldn't want to disallow that, as it's unambiguous. It also can be
&lt;br&gt;made quite readable by appropriate formatting:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; x = if
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if a then b else c
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; then
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if d then e else f
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if g then h else i
&lt;br&gt;&lt;br&gt;I wouldn't want to be forced to add parentheses here.
&lt;br&gt;&lt;br&gt;More questions:
&lt;br&gt;&lt;br&gt;Can the ambiguity resolution also be used to disambiguate dangling
&lt;br&gt;else?
&lt;br&gt;&lt;br&gt;And would the following work:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; exp =
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {add:} add_exp |
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {mul:} mul_exp |
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {num:} num;
&lt;br&gt;&amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Priority
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left mul;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Left add;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; add_exp = exp '+' exp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; mul_exp = exp '*' exp;
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26381566&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26381566.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26381202</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-16T14:42:03Z</published>
	<updated>2009-11-16T14:42:03Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Stephen P Spackman wrote:
&lt;blockquote cite=&quot;mid:1ae90d080911161424x6e13c2c0xb3aea3889455cb2@mail.gmail.com&quot; type=&quot;cite&quot;&gt;&lt;br&gt;
  &lt;div class=&quot;gmail_quote&quot;&gt;
  &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;In
a fluent[1] Java API for regular expressions I wrote, one can write&lt;br&gt;
    &lt;br&gt;
&amp;nbsp; &amp;nbsp;Regex expr = ...;&lt;br&gt;
&amp;nbsp; &amp;nbsp;Regex args = zeroOrMore(expr).separatedBy(',');&lt;br&gt;
  &lt;/blockquote&gt;
  &lt;div&gt;&lt;br&gt;
Which I have to agree is quite nice. &lt;br&gt;
  &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
SableCC has the following:&lt;br&gt;
&lt;br&gt;
&amp;nbsp; base.zeroOrMoreWithSeparator(separator);&lt;br&gt;
&lt;br&gt;
You can see it in the RegularExpressionEvaluator visitor:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void outASeparatedZeroOrMoreExpression(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASeparatedZeroOrMoreExpression node) {&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automaton base = retrieve(node.getBase());&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automaton separator = retrieve(node.getSeparator());&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; save(node, base.zeroOrMoreWithSeparator(separator));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:1ae90d080911161424x6e13c2c0xb3aea3889455cb2@mail.gmail.com&quot; type=&quot;cite&quot;&gt;
  &lt;div class=&quot;gmail_quote&quot;&gt;
  &lt;div&gt;...Which makes me want to suggest that we write &quot;foo{}&quot; instead
of &quot;foo*&quot; and &quot;foo{','}&quot; for the separated case. Not, you know, that
that would fit into the rest of the notation.&lt;br&gt;
  &lt;br&gt;
fun_call = id '(' exp */ ',' ')'; , anyone?&lt;br&gt;
  &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Not for me. There should be a &quot;*&quot; somewhere on ','.&amp;nbsp; The multiplicity
operator affects both the expression and the comma (with a count
difference of one).&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26381202&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26381202.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26380992</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for  expressions</title>
	<published>2009-11-16T14:24:27Z</published>
	<updated>2009-11-16T14:24:27Z</updated>
	<author>
		<name>Stephen P Spackman</name>
	</author>
	<content type="html">Hi, all.&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/11/16 Niklas Matthies &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26380992&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ml_sablecc-user@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
The drawback of &amp;quot;/&amp;quot; is that one has to know what it means, as it isn&amp;#39;t&lt;br&gt;
self-evident at all, and not a standard syntax like the Kleene star.&lt;br&gt;
Using the division operator &amp;quot;/&amp;quot; in the sense of &amp;quot;separated by&amp;quot; is&lt;br&gt;
quite a far stretch, even as a mnemonic.&lt;br&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;I&amp;#39;m not sure I agree. Concatenation is clearly the natural multiplicative operator in string grammars; divison should thus mean truncation. It&amp;#39;s true that (foo / &amp;#39;,&amp;#39;)* does not literally mean that foo minus some trailing comma repeats, but I can&amp;#39;t agree that it&amp;#39;s unmnemonic: it *is* something to do with division, just as the Kleene star *is* something to do with multiplication - which is where * gets its mnemonic power. &lt;br&gt;
&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
In a fluent[1] Java API for regular expressions I wrote, one can write&lt;br&gt;
&lt;br&gt;
    Regex expr = ...;&lt;br&gt;
    Regex args = zeroOrMore(expr).separatedBy(&amp;#39;,&amp;#39;);&lt;br&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;Which I have to agree is quite nice. &lt;br&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;

So how about:&lt;br&gt;
&lt;br&gt;
    fun_call = id &amp;#39;(&amp;#39; exp* SeparatedBy &amp;#39;,&amp;#39; &amp;#39;)&amp;#39;;&lt;br&gt;
&lt;br&gt;
That would be more self-explanatory. Putting the separator &amp;quot;outside&amp;quot;&lt;br&gt;
of the repition has some benefits: It doesn&amp;#39;t require an extra set of&lt;br&gt;
parentheses, it&amp;#39;s arguably easier to read out loud in a comprehensible&lt;br&gt;
way, it keeps the AST facts (&amp;quot;here we have a list of expressions&amp;quot;)&lt;br&gt;
together (&amp;quot;exp*&amp;quot;), and lastly the separator comes more expected when&lt;br&gt;
the repetition has already been established (e.g.&lt;br&gt;
&amp;quot;expr.separatedBy(&amp;#39;,&amp;#39;).zeroOrMore()&amp;quot; wouldn&amp;#39;t be quite as readable).&lt;br&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;...Which makes me want to suggest that we write &amp;quot;foo{}&amp;quot; instead of &amp;quot;foo*&amp;quot; and &amp;quot;foo{&amp;#39;,&amp;#39;}&amp;quot; for the separated case. Not, you know, that that would fit into the rest of the notation.&lt;br&gt;
&lt;br&gt;fun_call = id &amp;#39;(&amp;#39; exp */ &amp;#39;,&amp;#39; &amp;#39;)&amp;#39;; , anyone?&lt;br&gt;&lt;br&gt;Regards&lt;br&gt;Stephen&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26380992&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26380992.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26380631</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity	resolution	for	expressions</title>
	<published>2009-11-16T14:05:10Z</published>
	<updated>2009-11-16T14:05:10Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Niklas,&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116211031.GA91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;Given a string matched by N distinct tokens, we want to select the token 
that has precedence over all other tokens. Of course, the implementation 
can be done by &quot;changing&quot; token definitions so that only one token 
matches a given string, yet, theoretically, all of the N tokens match.
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
I'd say that it is input words that match, or are matched by, token
definitions (which define sets of words), and the result of each match
is a token. Of course you can say that

    plus &amp;gt; id

means that each token that is the result of a successful match of
&quot;plus&quot; has precedence over all tokens that are the result of a
successful match of &quot;id&quot;, but IMO it's more straightforward to say
that the token definition &quot;plus&quot; has precedence over the token
definition &quot;id&quot; for input words that match both definitions.

Just like precedence declarations on the parser level define
precedence of one production over another, not of syntax tree nodes
over other syntax tree nodes.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Don't forget the the lexer &lt;b&gt;first&lt;/b&gt; looks for the longest match.
So, if the input is:&lt;br&gt;
&lt;pre&gt;iffy
&lt;/pre&gt;
the lexer will match and identifier over matching the 'if' keyword. So,
in terms of making things clear for users, I really prefer to keep
explaining things in terms of &lt;b&gt;first&lt;/b&gt; finding the longest string
that is matched by tokens, then &lt;b&gt;second&lt;/b&gt; selecting the token with
the highest precedence.&lt;br&gt;
&lt;br&gt;
For this reason, only tokens involved in a &quot;lexical conflict&quot; (e.g.
longest match conflict), need to have precedence. SableCC is able to
figure out natural precedence (e.g. language of token A is subset of
language of token B =&amp;gt; A has natural precedence over B). Currently,
SableCC 4 requires a total order (explicit and/or implicit) among
conflicting tokens, yet a partial order where a single token wins over
all others is sufficient. This more flexible (partial order)
requirement will be implemented.&lt;br&gt;
&lt;br&gt;
Yet, &quot;plus &amp;gt; id&quot; already means that plus has precedence over id.
It's just that token precedence comes second, after the longest match.
So, don't think that we disagree about anything here.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116211031.GA91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;In the parser, precedence is a total order, and each precedence level 
requires an associativity declaration. The lexer supports partial 
ordering (actually, currently it requires a total order, but this will 
change). The lexer has no concept of associativity, so &quot;&amp;gt;&quot; just gets the 
job done.

SableCC 4 already has many new keywords. I've worked hard at reducing 
their number to a minimum, while not making the language cryptic.
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
Right, but consistency is also a design force. Different things should
have different syntax/names and same things the same syntax/names.
I'm not saying the current syntax is bad, but it's a point to be
considered.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
The difference between Priority and Precedence in the my Oxford
Dictionary is not big. I am in favor of selecting a single keyword and
sticking to it. The difference in details, between lexer and parser
precedence is apparent in their different syntactic structure ( &quot;&amp;gt;&quot;
in the lexer, &quot;Left&quot; and &quot;Right&quot; in the parser).&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116211031.GA91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;There's still one keyword I'm not sure about: &quot;Separator&quot; (usable in 
lexers and parsers):

 fun_call = id '(' (exp Separator ',')* ')';

I am toying with the idea of replacing it with '/' as is &quot;divided by&quot; 
(which is an common definition for this operator):

 fun_call = id '(' (exp / ',')* ')';
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
The drawback of &quot;/&quot; is that one has to know what it means, as it isn't
self-evident at all, and not a standard syntax like the Kleene star.
Using the division operator &quot;/&quot; in the sense of &quot;separated by&quot; is
quite a far stretch, even as a mnemonic.

In a fluent[1] Java API for regular expressions I wrote, one can write

    Regex expr = ...;
    Regex args = zeroOrMore(expr).separatedBy(',');

So how about:

    fun_call = id '(' exp* SeparatedBy ',' ')';
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
I actually had &quot;Separated By&quot; as two keywords, initially. The problem
is that this results in a tedious syntax for a common pattern; not
necessarily a good idea.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116211031.GA91785@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;That would be more self-explanatory. Putting the separator &quot;outside&quot;
of the repition has some benefits: It doesn't require an extra set of
parentheses, it's arguably easier to read out loud in a comprehensible
way, it keeps the AST facts (&quot;here we have a list of expressions&quot;)
together (&quot;exp*&quot;), and lastly the separator comes more expected when
the repetition has already been established (e.g.
&quot;expr.separatedBy(',').zeroOrMore()&quot; wouldn't be quite as readable).
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
The problem, in your syntax, is that we see a single &quot;,&quot;, yet, in the
parse tree, there are as many &quot;,&quot; as &quot;exp&quot; minus one. This is why I
decided that the * would be outside the parentheses.&lt;br&gt;
&lt;br&gt;
I see you coming:&lt;br&gt;
&lt;pre&gt;   '(' (exp* SeparatedBy ','^(*-1) ) ')'
&lt;/pre&gt;
But, then, is every expression followed by a bunch of commas? Nah...
I've thought about these cases and rejected them.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116211031.GA91785@nmhq.net&quot; type=&quot;cite&quot;&gt;Maybe
making &quot;Sep&quot; an alias would be acceptable:&lt;br&gt;
  &lt;pre wrap=&quot;&quot;&gt;
    fun_call = id '(' exp* Sep ',' ')';

A decent editor will have word completion of course. ;)
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
I don't like aliases; we have to chose something and stick with it.&lt;br&gt;
&lt;br&gt;
Users, when they see two different syntactic structures, expect a
distinct semantics. Aliases break this assumption, and users start
dreaming up arbitrary semantic differences...&lt;br&gt;
&lt;br&gt;
Currently, SableCC 4 has a single abbreviated keyword (and I wouldn't
mind making it a whole word): Diff =&amp;gt; Difference. Sep is not an
intuitive abbreviation. We might as well use &quot;/&quot; rather than &quot;Sep&quot;, if
we want to force users to read the documentation.&lt;br&gt;
&lt;br&gt;
The other thing, we shouldn't forget, is the context of use. A typical
use will look like:&lt;br&gt;
&lt;pre&gt;  var_decl = 'var' (id / ',')+ ';'
&lt;/pre&gt;
Question: If this was the first time you saw it, would you &lt;i&gt;guess&lt;/i&gt;
the semantics of &quot;/&quot; correctly?&amp;nbsp; If yes, I say we select &quot;/&quot;. If no, we
select &quot;Separator&quot;.&lt;br&gt;
&lt;br&gt;
And we revert &quot;Diff&quot; to &quot;Difference&quot; to remove the temptation of
proposing abbreviated keywords. :) &lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26380631&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26380631.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26380585</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-16T13:26:19Z</published>
	<updated>2009-11-16T13:26:19Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Stephen,&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:1ae90d080911161149h46456ad6q565868318f35eb6f@mail.gmail.com&quot; type=&quot;cite&quot;&gt;
  &lt;div class=&quot;gmail_quote&quot;&gt;
  &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
    &lt;div bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;Any opinion? Should I keep
the tedious but clear &quot;Separator&quot; keyword,
or should I replace it by the short '/' operator, potentially confusing
Lex/Flex converts?&lt;br&gt;
    &lt;/div&gt;
  &lt;/blockquote&gt;
  &lt;/div&gt;
  &lt;br&gt;
For myself, I have a strong preference for '/' (or '$' or '%' or '#' if
'/' is found to be too confusing). This is an important abbreviating
notation, and making it too verbose will really compromise its utility.&lt;br&gt;
&lt;/blockquote&gt;
Wouldn't '$' or '%' be even more cryptic? They don't have &quot;natural
semantic&quot;. &quot;%&quot; is often used as &quot;modulo&quot; or &quot;comment&quot;. '$' has so many
uses. In ObjectMacro, it is the command character. I'd like, as much as
possible, that grammars be readable by new users that haven't yet read
the (...upcoming...) documentation. At least, the natural semantics of
&quot;/&quot; is to divide: a list of identifier is divided by comma separators.&lt;br&gt;
&lt;br&gt;
I went through the list of ASCII symbols; to me &quot;/&quot; was the only
candidate as replacement for &quot;Separator&quot;.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:1ae90d080911161149h46456ad6q565868318f35eb6f@mail.gmail.com&quot; type=&quot;cite&quot;&gt;Honestly, I'm a little bothered by things like 'Diff',
too, since to me they compromise too far on 'expressionness'; I'd be
more inclined either to err on the side of line noise within
expressions, or to use something that stands out lexically (.diff.,
:diff:, $diff, or even DIFF).&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
There are very few Keyword operators: And, Diff, Look, Look Not,
Shortest, Longest, and (currently) Separator. These operators shouldn't
be of common use. Separator is the only one that will potentially be of
common use.&lt;br&gt;
&lt;br&gt;
Commonly used operators are expressed with symbols: - (lexical
subtraction), + * ? (multiplicity), ^N ^(N..M) ^(N...) exponent, etc.&lt;br&gt;
&lt;br&gt;
In particular, Diff should not be of common use, as lexical subtraction
almost always yields the expected result:&lt;br&gt;
&lt;pre&gt;&amp;nbsp; not_f = ('a'..'z') - 'f';&amp;nbsp; // equivalent to ('a'..'z') Diff 'f'
&amp;nbsp; comment_start = '/*';
&amp;nbsp; comment_body = Any* - '*/';
&amp;nbsp; comment_end = '/*';&lt;/pre&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:1ae90d080911161149h46456ad6q565868318f35eb6f@mail.gmail.com&quot; type=&quot;cite&quot;&gt;I guess I feel that making coarse structure apparent is a
greater kindness to the beginner and a smaller impediment to the expert
than verbosity. After all, if you don't know what an operator does,
you're going to look it up anyway. (And I think this is the idea behind
precedence declarations, too: to separate the coarse grammar from the
technical details.)&lt;br&gt;
  &lt;br&gt;
Regards, and great to see it coming together,&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Thanks for the comments.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26380585&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26380585.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26379574</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution	for	expressions</title>
	<published>2009-11-16T13:10:31Z</published>
	<updated>2009-11-16T13:10:31Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;On Mon 2009-11-16 at 14:15h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Niklas Matthies wrote:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;Just to make sure: I should use 'Precedence' to describe both &amp;quot;token 
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;precedence&amp;quot; (in the lexer) and &amp;quot;operator precedence&amp;quot; (in the parser), as 
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;in the following example. Right?
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;It's less common to apply the term &amp;quot;precedence&amp;quot; to tokens (actually
&lt;br&gt;&amp;gt; &amp;gt;it's not about the precedence of tokens here, but of token definitions!),
&lt;br&gt;&amp;gt; &amp;gt;but it isn't wrong either. So, why not.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Given a string matched by N distinct tokens, we want to select the token 
&lt;br&gt;&amp;gt; that has precedence over all other tokens. Of course, the implementation 
&lt;br&gt;&amp;gt; can be done by &amp;quot;changing&amp;quot; token definitions so that only one token 
&lt;br&gt;&amp;gt; matches a given string, yet, theoretically, all of the N tokens match.
&lt;/div&gt;&lt;br&gt;I'd say that it is input words that match, or are matched by, token
&lt;br&gt;definitions (which define sets of words), and the result of each match
&lt;br&gt;is a token. Of course you can say that
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; plus &amp;gt; id
&lt;br&gt;&lt;br&gt;means that each token that is the result of a successful match of
&lt;br&gt;&amp;quot;plus&amp;quot; has precedence over all tokens that are the result of a
&lt;br&gt;successful match of &amp;quot;id&amp;quot;, but IMO it's more straightforward to say
&lt;br&gt;that the token definition &amp;quot;plus&amp;quot; has precedence over the token
&lt;br&gt;definition &amp;quot;id&amp;quot; for input words that match both definitions.
&lt;br&gt;&lt;br&gt;Just like precedence declarations on the parser level define
&lt;br&gt;precedence of one production over another, not of syntax tree nodes
&lt;br&gt;over other syntax tree nodes.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;gt;One other thing I'm noticing here is that in the parser, the
&lt;br&gt;&amp;gt; &amp;gt;precedence levels are separated by &amp;quot;;&amp;quot;, while here the precedence is
&lt;br&gt;&amp;gt; &amp;gt;marked by &amp;quot;&amp;gt;&amp;quot;. This could be a reason to use different names for these
&lt;br&gt;&amp;gt; &amp;gt;sections or to align their syntax.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In the parser, precedence is a total order, and each precedence level 
&lt;br&gt;&amp;gt; requires an associativity declaration. The lexer supports partial 
&lt;br&gt;&amp;gt; ordering (actually, currently it requires a total order, but this will 
&lt;br&gt;&amp;gt; change). The lexer has no concept of associativity, so &amp;quot;&amp;gt;&amp;quot; just gets the 
&lt;br&gt;&amp;gt; job done.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; SableCC 4 already has many new keywords. I've worked hard at reducing 
&lt;br&gt;&amp;gt; their number to a minimum, while not making the language cryptic.
&lt;/div&gt;&lt;br&gt;Right, but consistency is also a design force. Different things should
&lt;br&gt;have different syntax/names and same things the same syntax/names.
&lt;br&gt;I'm not saying the current syntax is bad, but it's a point to be
&lt;br&gt;considered.
&lt;br&gt;&lt;br&gt;&amp;gt; There's still one keyword I'm not sure about: &amp;quot;Separator&amp;quot; (usable in 
&lt;br&gt;&amp;gt; lexers and parsers):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;fun_call = id '(' (exp Separator ',')* ')';
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I am toying with the idea of replacing it with '/' as is &amp;quot;divided by&amp;quot; 
&lt;br&gt;&amp;gt; (which is an common definition for this operator):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;fun_call = id '(' (exp / ',')* ')';
&lt;br&gt;&lt;br&gt;The drawback of &amp;quot;/&amp;quot; is that one has to know what it means, as it isn't
&lt;br&gt;self-evident at all, and not a standard syntax like the Kleene star.
&lt;br&gt;Using the division operator &amp;quot;/&amp;quot; in the sense of &amp;quot;separated by&amp;quot; is
&lt;br&gt;quite a far stretch, even as a mnemonic.
&lt;br&gt;&lt;br&gt;In a fluent[1] Java API for regular expressions I wrote, one can write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Regex expr = ...;
&lt;br&gt;&amp;nbsp; &amp;nbsp; Regex args = zeroOrMore(expr).separatedBy(',');
&lt;br&gt;&lt;br&gt;So how about:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; fun_call = id '(' exp* SeparatedBy ',' ')';
&lt;br&gt;&lt;br&gt;That would be more self-explanatory. Putting the separator &amp;quot;outside&amp;quot;
&lt;br&gt;of the repition has some benefits: It doesn't require an extra set of
&lt;br&gt;parentheses, it's arguably easier to read out loud in a comprehensible
&lt;br&gt;way, it keeps the AST facts (&amp;quot;here we have a list of expressions&amp;quot;)
&lt;br&gt;together (&amp;quot;exp*&amp;quot;), and lastly the separator comes more expected when
&lt;br&gt;the repetition has already been established (e.g.
&lt;br&gt;&amp;quot;expr.separatedBy(',').zeroOrMore()&amp;quot; wouldn't be quite as readable).
&lt;br&gt;&lt;br&gt;[1] &lt;a href=&quot;http://martinfowler.com/bliki/FluentInterface.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://martinfowler.com/bliki/FluentInterface.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;:
&lt;br&gt;&amp;gt; The separator is likely to be a commonly used operator in parsing 
&lt;br&gt;&amp;gt; grammars, so making common things easy to type is not a bad idea.
&lt;br&gt;&lt;br&gt;Maybe making &amp;quot;Sep&amp;quot; an alias would be acceptable:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; fun_call = id '(' exp* Sep ',' ')';
&lt;br&gt;&lt;br&gt;A decent editor will have word completion of course. ;)
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26379574&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26379574.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26379151</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for  expressions</title>
	<published>2009-11-16T11:49:45Z</published>
	<updated>2009-11-16T11:49:45Z</updated>
	<author>
		<name>Stephen P Spackman</name>
	</author>
	<content type="html">Hi, Etienne.&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;SableCC 4 already has many new keywords. I&amp;#39;ve worked hard at reducing
their number to a minimum, while not making the language cryptic.
There&amp;#39;s still one keyword I&amp;#39;m not sure about: &amp;quot;Separator&amp;quot; (usable in
lexers and parsers):&lt;br&gt;
&lt;pre&gt;  fun_call = id &amp;#39;(&amp;#39; (exp Separator &amp;#39;,&amp;#39;)* &amp;#39;)&amp;#39;;
&lt;/pre&gt;
I am toying with the idea of replacing it with &amp;#39;/&amp;#39; as is &amp;quot;divided by&amp;quot;
(which is an common definition for this operat&lt;div class=&quot;gmail_quote&quot;&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
&lt;br&gt;
&lt;blockquote type=&quot;cite&quot;&gt;
  &lt;pre&gt;Incidentally, I&amp;#39;ve seen it argued that operator precedence shouldn&amp;#39;t&lt;br&gt;necessarily be transitive (e.g. in [1]), which would support the &amp;quot;&amp;gt;&amp;quot;&lt;br&gt;notation for operator precedence. But I guess that in the SableCC&lt;br&gt;
context, non-transitive operator precedence wouldn&amp;#39;t be able to&lt;br&gt;achieve non-ambiguity without changing (reducing) the accepted&lt;br&gt;language.&lt;br&gt;  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Yes, this would change the language. Interesting paper, though. Thanks
for the link!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre cols=&quot;72&quot;&gt;-- &lt;br&gt;Etienne M. Gagnon, Ph.D.&lt;br&gt;SableCC:                                            &lt;a href=&quot;http://sablecc.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;br&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;br&gt;_______________________________________________&lt;br&gt;
SableCC-Discussion mailing list&lt;br&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26379151&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;or):&lt;br&gt;
&lt;pre&gt;  fun_call = id &amp;#39;(&amp;#39; (exp / &amp;#39;,&amp;#39;)* &amp;#39;)&amp;#39;;
&lt;/pre&gt;
The unfortunate thing is that &amp;quot;/&amp;quot; has been used by Lex and Flex as
synonym (!) for &amp;quot;Lookahead&amp;quot;. I wouldn&amp;#39;t want users to confuse &amp;quot;Look&amp;quot;
and &amp;quot;Separator&amp;quot;!&lt;br&gt;
&lt;br&gt;
The separator is likely to be a commonly used operator in parsing
grammars, so making common things easy to type is not a bad idea.&lt;br&gt;
&lt;br&gt;
Any opinion? Should I keep the tedious but clear &amp;quot;Separator&amp;quot; keyword,
or should I replace it by the short &amp;#39;/&amp;#39; operator, potentially confusing
Lex/Flex converts?&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;For myself, I have a strong preference for &amp;#39;/&amp;#39; (or &amp;#39;$&amp;#39; or &amp;#39;%&amp;#39; or &amp;#39;#&amp;#39; if &amp;#39;/&amp;#39; is found to be too confusing). This is an important abbreviating notation, and making it too verbose will really compromise its utility.&lt;br&gt;
&lt;br&gt;Honestly, I&amp;#39;m a little bothered by things like &amp;#39;Diff&amp;#39;, too, since to me they compromise too far on &amp;#39;expressionness&amp;#39;; I&amp;#39;d be more inclined either to err on the side of line noise within expressions, or to use something that stands out lexically (.diff., :diff:, $diff, or even DIFF).&lt;br&gt;
&lt;br&gt;I guess I feel that making coarse structure apparent is a greater kindness to the beginner and a smaller impediment to the expert than verbosity. After all, if you don&amp;#39;t know what an operator does, you&amp;#39;re going to look it up anyway. (And I think this is the idea behind precedence declarations, too: to separate the coarse grammar from the technical details.)&lt;br&gt;
&lt;br&gt;Regards, and great to see it coming together,&lt;br&gt;Stephen&lt;br&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26379151&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26379151.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26377911</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution	for	expressions</title>
	<published>2009-11-16T11:15:13Z</published>
	<updated>2009-11-16T11:15:13Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Niklas,&lt;br&gt;
&lt;br&gt;
Niklas Matthies wrote:&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116182851.GA75434@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;Just to make sure: I should use 'Precedence' to describe both &quot;token 
precedence&quot; (in the lexer) and &quot;operator precedence&quot; (in the parser), as 
in the following example. Right?
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
It's less common to apply the term &quot;precedence&quot; to tokens (actually
it's not about the precedence of tokens here, but of token definitions!),
but it isn't wrong either. So, why not.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Given a string matched by N distinct tokens, we want to select the
token that has precedence over all other tokens. Of course, the
implementation can be done by &quot;changing&quot; token definitions so that only
one token matches a given string, yet, theoretically, all of the N
tokens match.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116182851.GA75434@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Do I understand this correctly that the above has the same effect
as if 'id' had been defined as

  id = letter (letter | digit)* - (plus | minus | star | slash);

?
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Almost. In SableCC 4, the &quot;-&quot; operator is a lexical subtraction
operator, not a regular expression difference operator (or set
difference). So, to be precise, it would be equivalent to:&lt;br&gt;
&lt;pre&gt;  id = letter (letter | digit)* Diff (plus | minus | star | slash);
&lt;/pre&gt;
&lt;br&gt;
The &quot;-&quot; lexical subtraction operator has been explained in
&lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://lists.sablecc.org/pipermail/sablecc-discussion/msg00578.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/pipermail/sablecc-discussion/msg00578.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116182851.GA75434@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;One other thing I'm noticing here is that in the parser, the
precedence levels are separated by &quot;;&quot;, while here the precedence is
marked by &quot;&amp;gt;&quot;. This could be a reason to use different names for these
sections or to align their syntax.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
In the parser, precedence is a total order, and each precedence level
requires an associativity declaration. The lexer supports partial
ordering (actually, currently it requires a total order, but this will
change). The lexer has no concept of associativity, so &quot;&amp;gt;&quot; just gets
the job done.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
SableCC 4 already has many new keywords. I've worked hard at reducing
their number to a minimum, while not making the language cryptic.
There's still one keyword I'm not sure about: &quot;Separator&quot; (usable in
lexers and parsers):&lt;br&gt;
&lt;pre&gt;  fun_call = id '(' (exp Separator ',')* ')';
&lt;/pre&gt;
I am toying with the idea of replacing it with '/' as is &quot;divided by&quot;
(which is an common definition for this operator):&lt;br&gt;
&lt;pre&gt;  fun_call = id '(' (exp / ',')* ')';
&lt;/pre&gt;
The unfortunate thing is that &quot;/&quot; has been used by Lex and Flex as
synonym (!) for &quot;Lookahead&quot;. I wouldn't want users to confuse &quot;Look&quot;
and &quot;Separator&quot;!&lt;br&gt;
&lt;br&gt;
The separator is likely to be a commonly used operator in parsing
grammars, so making common things easy to type is not a bad idea.&lt;br&gt;
&lt;br&gt;
Any opinion? Should I keep the tedious but clear &quot;Separator&quot; keyword,
or should I replace it by the short '/' operator, potentially confusing
Lex/Flex converts?&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091116182851.GA75434@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;
Incidentally, I've seen it argued that operator precedence shouldn't
necessarily be transitive (e.g. in [1]), which would support the &quot;&amp;gt;&quot;
notation for operator precedence. But I guess that in the SableCC
context, non-transitive operator precedence wouldn't be able to
achieve non-ambiguity without changing (reducing) the accepted
language.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Yes, this would change the language. Interesting paper, though. Thanks
for the link!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26377911&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26377911.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26377200</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for	expressions</title>
	<published>2009-11-16T10:28:51Z</published>
	<updated>2009-11-16T10:28:51Z</updated>
	<author>
		<name>Niklas Matthies</name>
	</author>
	<content type="html">On Mon 2009-11-16 at 10:36h, Etienne M. Gagnon wrote on sablecc-discussion:
&lt;br&gt;&amp;gt; Hi Christopher,
&lt;br&gt;:
&lt;br&gt;&amp;gt; &amp;gt;Regarding the 'Priority' versus 'Precedence&amp;quot; suggestion posed by 
&lt;br&gt;&amp;gt; &amp;gt;Niklas, I would have to agree that 'Precedence' is a more natural word 
&lt;br&gt;&amp;gt; &amp;gt;to describe the behavior in English. That's the term we're taught to 
&lt;br&gt;&amp;gt; &amp;gt;describe it in CS courses, so it's probably best to stick with it.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Just to make sure: I should use 'Precedence' to describe both &amp;quot;token 
&lt;br&gt;&amp;gt; precedence&amp;quot; (in the lexer) and &amp;quot;operator precedence&amp;quot; (in the parser), as 
&lt;br&gt;&amp;gt; in the following example. Right?
&lt;br&gt;&lt;br&gt;It's less common to apply the term &amp;quot;precedence&amp;quot; to tokens (actually
&lt;br&gt;it's not about the precedence of tokens here, but of token definitions!),
&lt;br&gt;but it isn't wrong either. So, why not.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Language demo;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Lexer
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;id = letter (letter | digit)*;
&lt;br&gt;&amp;gt; &amp;nbsp;num = digit+;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;letter = 'a'..'z' | 'A'..'Z';
&lt;br&gt;&amp;gt; &amp;nbsp;digit = '0'..'9';
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;plus = '+' | 'add';
&lt;br&gt;&amp;gt; &amp;nbsp;minus = '-' | 'sub';
&lt;br&gt;&amp;gt; &amp;nbsp;star = '*' | 'mul';
&lt;br&gt;&amp;gt; &amp;nbsp;slash = '/' | 'div';
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;Ignored
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;' ', #9, #10, #13;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp;Precedence
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;plus &amp;gt; id;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;minus &amp;gt; id;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;star &amp;gt; id;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;slash &amp;gt; id;
&lt;/div&gt;&lt;br&gt;Do I understand this correctly that the above has the same effect
&lt;br&gt;as if 'id' had been defined as
&lt;br&gt;&lt;br&gt;&amp;nbsp; id = letter (letter | digit)* - (plus | minus | star | slash);
&lt;br&gt;&lt;br&gt;?
&lt;br&gt;&lt;br&gt;One other thing I'm noticing here is that in the parser, the
&lt;br&gt;precedence levels are separated by &amp;quot;;&amp;quot;, while here the precedence is
&lt;br&gt;marked by &amp;quot;&amp;gt;&amp;quot;. This could be a reason to use different names for these
&lt;br&gt;sections or to align their syntax.
&lt;br&gt;&lt;br&gt;Incidentally, I've seen it argued that operator precedence shouldn't
&lt;br&gt;necessarily be transitive (e.g. in [1]), which would support the &amp;quot;&amp;gt;&amp;quot;
&lt;br&gt;notation for operator precedence. But I guess that in the SableCC
&lt;br&gt;context, non-transitive operator precedence wouldn't be able to
&lt;br&gt;achieve non-ambiguity without changing (reducing) the accepted
&lt;br&gt;language.
&lt;br&gt;&lt;br&gt;-- Niklas Matthies
&lt;br&gt;&lt;br&gt;[1] &lt;a href=&quot;http://www.cs.nott.ac.uk/~nad/publications/danielsson-norell-mixfix.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.cs.nott.ac.uk/~nad/publications/danielsson-norell-mixfix.pdf&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26377200&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26377200.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26374129</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for	expressions</title>
	<published>2009-11-16T07:36:24Z</published>
	<updated>2009-11-16T07:36:24Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Christopher,&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:5138344FE8C840EF9A4C1244B45545A8@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;div class=&quot;Section1&quot;&gt;
  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;I had a
brief look at this over the
weekend with a view to making a C# backend and got stuck with
ObjectMacro. It
appears that we need to the names and meaning of the various hooks that
SableCC
calls it with, but these didn&amp;#8217;t really leap out at me looking at your
Java template file, the samples, or the post expansion version.&lt;br&gt;
Also, the new syntax seems to be
profoundly different from the old one, which is not a problem really
except
that it&amp;#8217;s not clear what some of the new keywords mean or do. Is there
document
somewhere that discusses them? The ones in particular that had me
scratching my
head were:&lt;br&gt;
Transformation, Tree, Restartable,
Investigator, Dangling, Any and Epsilon.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;br&gt;
The current code generation is not in ready to start targeting other
languages. I have taken many shortcuts in order to make the parsing
engine available for testing.&lt;br&gt;
&lt;br&gt;
Currently, the code directly generates Java. This will be completely
changed. The real SableCC 4 backend will first generate &quot;intermediate&quot;
code/tree. This intermediate tree will be used as source for generating
other targets (including Java). This is how the ObjectMacro backend is
already implemented.&lt;br&gt;
&lt;br&gt;
Too many SableCC 4 features are missing at this point (tree
transformations, investigators, selectors, contexts, etc.). It is too
early to start targeting other languages.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:5138344FE8C840EF9A4C1244B45545A8@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;div class=&quot;Section1&quot;&gt;
  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;Regarding
the &amp;#8216;Priority&amp;#8217;
versus &amp;#8216;Precedence&amp;#8221; suggestion posed by Niklas, I would have to
agree that &amp;#8216;Precedence&amp;#8217; is a more natural word to describe the
behavior in English. That&amp;#8217;s the term we&amp;#8217;re taught to describe it in
CS courses, so it&amp;#8217;s probably best to stick with it.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Just to make sure: I should use 'Precedence' to describe both &quot;token
precedence&quot; (in the lexer) and &quot;operator precedence&quot; (in the parser),
as in
the following example. Right?&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Language demo;

Lexer

  id = letter (letter | digit)*;
  num = digit+;

  letter = 'a'..'z' | 'A'..'Z';
  digit = '0'..'9';

  plus = '+' | 'add';
  minus = '-' | 'sub';
  star = '*' | 'mul';
  slash = '/' | 'div';

  Ignored
    ' ', #9, #10, #13;

  Precedence
    plus &amp;gt; id;
    minus &amp;gt; id;
    star &amp;gt; id;
    slash &amp;gt; id;

Parser

  exp =
    {add:} exp plus exp |
    {sub:} exp minus exp |
    {mul:} exp star exp |
    {div:} exp slash exp |
    {par:} '(' exp ')' |
    {num:} num;

    Precedence
      Left mul, div;
      Left add, sub;
&lt;/pre&gt;
&lt;br&gt;
I just noticed that this example reveals a little semantic verification
discrepancy (SableCC wants me to explicitly declare tokens that should
be known implicitly)...&lt;br&gt;
&lt;blockquote cite=&quot;mid:5138344FE8C840EF9A4C1244B45545A8@FDC490&quot; type=&quot;cite&quot;&gt;
  &lt;div class=&quot;Section1&quot;&gt;
  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;Needless to
say it&amp;#8217;s exciting to see
it nearing completion.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;br&gt;
I know. But, there's still a fair amount of work to do to put all the
pieces together.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26374129&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26374129.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26369692</id>
	<title>RE: Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-16T02:21:13Z</published>
	<updated>2009-11-16T02:21:13Z</updated>
	<author>
		<name>Christopher Van Kirk</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;

&lt;head&gt;
&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=us-ascii&quot;&gt;


&lt;meta name=Generator content=&quot;Microsoft Word 10 (filtered)&quot;&gt;



&lt;/head&gt;

&lt;body bgcolor=white lang=EN-US link=blue vlink=blue&gt;

&lt;div class=Section1&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Hi Etienne,&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;I had a brief look at this over the
weekend with a view to making a C# backend and got stuck with ObjectMacro. It
appears that we need to the names and meaning of the various hooks that SableCC
calls it with, but these didn&amp;#8217;t really leap out at me looking at your
Java template file, the samples, or the post expansion version. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Also, the new syntax seems to be
profoundly different from the old one, which is not a problem really except
that it&amp;#8217;s not clear what some of the new keywords mean or do. Is there document
somewhere that discusses them? The ones in particular that had me scratching my
head were:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Transformation, Tree, Restartable,
Investigator, Dangling, Any and Epsilon.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Regarding the &amp;#8216;Priority&amp;#8217;
versus &amp;#8216;Precedence&amp;#8221; suggestion posed by Niklas, I would have to
agree that &amp;#8216;Precedence&amp;#8217; is a more natural word to describe the
behavior in English. That&amp;#8217;s the term we&amp;#8217;re taught to describe it in
CS courses, so it&amp;#8217;s probably best to stick with it.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Needless to say it&amp;#8217;s exciting to see
it nearing completion. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Cheers,&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;Chris&amp;#8230;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=navy face=Arial&gt;&lt;span style='font-size:
10.0pt;font-family:Arial;color:navy'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=2 color=black face=Tahoma&gt;&lt;span style='font-size:
10.0pt;font-family:Tahoma;color:windowtext'&gt;-----Original Message-----&lt;br&gt;
&lt;b&gt;&lt;span style='font-weight:bold'&gt;From:&lt;/span&gt;&lt;/b&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26369692&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26369692&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;]
&lt;b&gt;&lt;span style='font-weight:bold'&gt;On Behalf Of &lt;/span&gt;&lt;/b&gt;Etienne M. Gagnon&lt;br&gt;
&lt;b&gt;&lt;span style='font-weight:bold'&gt;Sent:&lt;/span&gt;&lt;/b&gt; Friday, November 13, 2009
11:29 AM&lt;br&gt;
&lt;b&gt;&lt;span style='font-weight:bold'&gt;To:&lt;/span&gt;&lt;/b&gt; Discussion mailing list for
the SableCC project.&lt;br&gt;
&lt;b&gt;&lt;span style='font-weight:bold'&gt;Subject:&lt;/span&gt;&lt;/b&gt; Linear-approximate
LALR(K) and ambiguity resolution for expressions&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=3 color=black face=&quot;Times New Roman&quot;&gt;&lt;span style='font-size:12.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;font size=3 color=black face=&quot;Times New Roman&quot;&gt;&lt;span style='font-size:12.0pt'&gt;Hi!&lt;br&gt;
&lt;br&gt;
I've just released SableCC 4-beta.2. This version is a major milestone as it
generates a complete framework: lexer, parser, syntax tree, and tree walker.
Among the most interesting features is the new linear-approximate LALR(K)
engine which also support safe ambiguity resolution for expressions (i.e. left
and right directly-recursive productions). Yes, you can now write the simple
expression grammar as:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;Language exp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;Lexer&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp; num = digit+;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp; digit = '0'..'9';&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp; Ignored&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp; ' ', #9, #10, #13;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;Parser&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp; exp =&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {add:} exp '+' exp |&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {mul:} exp '*' exp |&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {num:} num;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Priority&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // highest priority first&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Left mul;&amp;nbsp; // &amp;quot;Left&amp;quot; associative &lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Left add;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p class=MsoNormal&gt;&lt;font size=3 color=black face=&quot;Times New Roman&quot;&gt;&lt;span style='font-size:12.0pt'&gt;SableCC is very precise in resolving an &lt;i&gt;&lt;span style='font-style:italic'&gt;ambiguity&lt;/span&gt;&lt;/i&gt; according to a priority
specification. It will not accidentally resolve unrelated &lt;i&gt;&lt;span style='font-style:italic'&gt;conflicts&lt;/span&gt;&lt;/i&gt;. The &lt;i&gt;&lt;span style='font-style:
italic'&gt;language&lt;/span&gt;&lt;/i&gt; (i.e. the set of syntactically valid programs)
accepted by the grammar is not changed by the priority specification. This
differs from traditional &lt;i&gt;&lt;span style='font-style:italic'&gt;conflict-resolution&lt;/span&gt;&lt;/i&gt;
mechanisms found in other tools that can change the language and
unintentionally resolve unrelated conflicts.&lt;br&gt;
&lt;br&gt;
It would be fun if you helped testing this version by rewriting some of your
SableCC 2&amp;nbsp; and 3 grammars into SableCC 4 syntax, in order to test the
generated parser and report back on it.&lt;br&gt;
&lt;br&gt;
Please be indulgent with me... The parser grammar does not, at this point,
support any lexical operators (*, +, ?, etc.). So, you'll have to manually
write your lists as recursive productions. This is temporary as I first need to
implement the tree transformation engine before supporting these operators.&lt;br&gt;
&lt;br&gt;
You'll notice that I have somewhat simplified the tree walker class and related
classes. It is now simply called &amp;quot;Walker&amp;quot; (instead of
DepthFirstAdapter).&lt;br&gt;
&lt;br&gt;
You can download it from &lt;a href=&quot;http://sablecc.org/wiki/DownloadPage&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org/wiki/DownloadPage&lt;/a&gt;
.&lt;br&gt;
&lt;br&gt;
I hope you'll have as much fun as I am starting to have with the new syntax and
lexer/parser engines.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;-- &lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;Etienne M. Gagnon, Ph.D.&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre&gt;&lt;font size=2 color=black face=&quot;Courier New&quot;&gt;&lt;span style='font-size:10.0pt'&gt;SableCC:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/body&gt;

&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26369692&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26369692.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26363008</id>
	<title>Re: Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-15T12:24:06Z</published>
	<updated>2009-11-15T12:24:06Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta content=&quot;text/html;charset=ISO-8859-1&quot; http-equiv=&quot;Content-Type&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi Niklas,&lt;br&gt;
&lt;br&gt;
See below.&lt;br&gt;
&lt;br&gt;
Niklas Matthies wrote:
&lt;blockquote cite=&quot;mid:20091115000538.GA18266@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;Hi,

On Thu 2009-11-12 at 21:29h, Etienne M. Gagnon wrote on sablecc-discussion:
:
  &lt;/pre&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt;I've just released SableCC 4-beta.2. This version is a major milestone 
as it generates a complete framework: lexer, parser, syntax tree, and 
tree walker. Among the most interesting features is the new 
linear-approximate LALR(K) engine which also support safe ambiguity 
resolution for expressions (i.e. left and right directly-recursive 
productions).
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;:
  &lt;/pre&gt;
  &lt;blockquote type=&quot;cite&quot;&gt;
    &lt;pre wrap=&quot;&quot;&gt; exp =
   {add:} exp '+' exp |
   {mul:} exp '*' exp |
   {num:} num;

   Priority     // highest priority first
     Left mul;  // &quot;Left&quot; associative 
     Left add;
    &lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;pre wrap=&quot;&quot;&gt;&lt;!----&gt;
That really sounds great! Unfortunately I'm not sure if and when I
will have the spare time to do some real testing. Anyway, some
questions:

- How would one define groups of operators (productions) having the
same priority (and associativity)?
Like for example '+' and '-' having the same precedence.
(By the way, isn't &quot;precedence&quot; the more customary term for this than
&quot;priority&quot;?)

  &lt;/pre&gt;
&lt;/blockquote&gt;
You would write:&lt;br&gt;
&lt;pre&gt;  Left add, sub;&lt;/pre&gt;
The keyword &quot;Priority&quot; is also used in the lexer. We could change the
keyword to &quot;Precedence&quot;, as long as we also use it to determine token
priority. I just don't want distinct keywords. Priority seems shorter
and as clear as Precedence (that's would be one point in favor of
keeping
it).&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091115000538.GA18266@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;- For one-sided operators (like unary operators), associativity isn't
applicable, but one still wants to specify precedence. Is this
supported? By &quot;one-sided&quot; I mean operators like

    'if' expr 'then' expr 'else' expr
    
as opposed to &quot;two-sided&quot; operators like
    
    expr '?' expr ':' expr

Are there maybe better terms for this distinction?
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Actually, with unary operators you still have to decide whether you
want to give left or right priority, e.g.:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;++ a - b  (assuming ++ and - have the same precedence level) =&amp;gt;
&amp;nbsp;left  : (++ a) - b
&amp;nbsp;right : ++ (a - b)
&lt;/pre&gt;
So, of course, you simply specify them using the same syntax:&lt;br&gt;
&lt;pre&gt; Right unop1, otherop, unop2;
&lt;/pre&gt;
This allows for binary, left-unary, and right-unary operators at the
same priority level. So, it is simpler to keep &quot;Left&quot; and &quot;Right&quot;
specifications for each priority level.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091115000538.GA18266@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;
- Sometimes there are two-sided operators that you don't want to be
associative, either because it would be ill-typed, or because it would
be prone to misunderstandings, so you want users to use parentheses to
be explicit. An example would be an expression like &quot;a &amp;lt; b &amp;lt; c&quot;, where
'&amp;lt;' is a less-than operator that doesn't take booleans, or if it does
could then be misunderstood as meaning &quot;a &amp;lt; b and b &amp;lt; c&quot;. I know, in
general this is better handled at the analysis level, but sometimes
it's convenient to just let the grammar take care of it.
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
This would change the accepted language. So, given that SableCC 4
guarantees that expression priorities does not change the language, you
have two
choices:&lt;br&gt;
&lt;ol&gt;
  &lt;li&gt;Detect invalid constructs at the semantic level, as you proposed,
or&lt;/li&gt;
  &lt;li&gt;Add distinct productions for non-associative operators.&lt;/li&gt;
&lt;/ol&gt;
Of course, 2 requires a little grammar rewriting, but my experience is
that it is relatively easy to accomplish. As for 1, it has the
advantage of leading to clearer semantic error messages.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091115000538.GA18266@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;
- Are n-ary operators with n &amp;gt; 2 supported? For example I have a
grammar which includes these operators (the last three are list
comprehension expressions):

    expr =
    ...
    {cond:}         'if' expr 'then' expr 'else' expr
    {filter:}       id 'in' expr 'where' expr
    {map:}          expr 'for' id 'in' expr
    {map_filter:}   expr 'for' id 'in' expr 'where' expr

with the following precedence/associativity table:

    associativity       operator
    ------------------------------------------------
        n/a             cond, filter
        left            map, map_filter

I.e. cond and filter have the same precedence and aren't associative,
but have higher precedence than map and map_filter, which again have
the same precedence and are left associative. Is the ambiguity
resolution able to handle such more complex scenarios?
(It took me quite a while to write a correct SableCC 3 grammar for it
back then. ;))
  &lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br&gt;
I would write:&amp;nbsp;&amp;nbsp; &lt;br&gt;
&lt;pre wrap=&quot;&quot;&gt;expr =
&amp;nbsp;{cond:}         'if' subexpr 'then' subexpr 'else' subexpr |
 {filter:}       id 'in' subexpr 'where' subexpr |
 {simple:}       subexpr;

subexpr
 {map:}          subexpr 'for' id 'in' subexpr |
 {map_filter:}   subexpr 'for' id 'in' subexpr 'where' subexpr |
 {parenthesis:}  '(' expr ')'
 ...  

 Precedence
   Left map, map_filter; 
&lt;/pre&gt;
In the cond and filter alternatives, you can put the internal recursion
on &quot;expr&quot; instead of &quot;subexpr&quot;; this would give you the same result as
you would get with a &quot;non-associative&quot; specification. Yet, I wouldn't
be surprised
if your intentions were actually to disallow : &lt;tt&gt;if if a else if b
else c else if d else e&lt;/tt&gt;. The above grammar disallows it; you
would have to use parentheses to express it. A &quot;non-associative&quot;
precedence
simply disallows left and right recursion, it does not affect internal
recursion.&lt;br&gt;
&lt;br&gt;
&lt;blockquote cite=&quot;mid:20091115000538.GA18266@nmhq.net&quot; type=&quot;cite&quot;&gt;
  &lt;pre wrap=&quot;&quot;&gt;
Thanks,

-- Niklas Matthies

  &lt;/pre&gt;
&lt;/blockquote&gt;
Thanks for the feedback!&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26363008&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26363008.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26330405</id>
	<title>Linear-approximate LALR(K) and ambiguity resolution for expressions</title>
	<published>2009-11-12T18:29:03Z</published>
	<updated>2009-11-12T18:29:03Z</updated>
	<author>
		<name>Etienne M. Gagnon</name>
	</author>
	<content type="html">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
Hi!&lt;br&gt;
&lt;br&gt;
I've just released SableCC 4-beta.2. This version is a major milestone
as it generates a complete framework: lexer, parser, syntax tree, and
tree walker. Among the most interesting features is the new
linear-approximate LALR(K) engine which also support safe ambiguity
resolution for expressions (i.e. left and right directly-recursive
productions). Yes, you can now write the simple expression grammar as:&lt;br&gt;
&lt;pre&gt;Language exp;

Lexer

  num = digit+;
  digit = '0'..'9';

  Ignored

   ' ', #9, #10, #13;

Parser

  exp =
    {add:} exp '+' exp |
    {mul:} exp '*' exp |
    {num:} num;

    Priority     // highest priority first
      Left mul;  // &quot;Left&quot; associative 
      Left add;
&lt;/pre&gt;
SableCC is very precise in resolving an &lt;i&gt;ambiguity&lt;/i&gt; according to
a priority specification. It will not accidentally resolve unrelated &lt;i&gt;conflicts&lt;/i&gt;.
The &lt;i&gt;language&lt;/i&gt; (i.e. the set of syntactically valid programs)
accepted by the grammar is not changed by the priority specification.
This differs from traditional &lt;i&gt;conflict-resolution&lt;/i&gt; mechanisms
found in other tools that can change the language and unintentionally
resolve unrelated conflicts.&lt;br&gt;
&lt;br&gt;
It would be fun if you helped testing this version by rewriting some of
your SableCC 2  and 3 grammars into SableCC 4 syntax, in order to test
the generated parser and report back on it.&lt;br&gt;
&lt;br&gt;
Please be indulgent with me... The parser grammar does not, at this
point, support any lexical operators (*, +, ?, etc.). So, you'll have
to manually write your lists as recursive productions. This is
temporary as I first need to implement the tree transformation engine
before supporting these operators.&lt;br&gt;
&lt;br&gt;
You'll notice that I have somewhat simplified the tree walker class and
related classes. It is now simply called &quot;Walker&quot; (instead of
DepthFirstAdapter).&lt;br&gt;
&lt;br&gt;
You can download it from &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org/wiki/DownloadPage&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org/wiki/DownloadPage&lt;/a&gt; .&lt;br&gt;
&lt;br&gt;
I hope you'll have as much fun as I am starting to have with the new
syntax and lexer/parser engines.&lt;br&gt;
&lt;br&gt;
Etienne&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;moz-signature&quot; cols=&quot;72&quot;&gt;-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://sablecc.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://sablecc.org&lt;/a&gt;
&lt;/pre&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26330405&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Linear-approximate-LALR%28K%29-and-ambiguity-resolution-for-expressions-tp26330405p26330405.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-25836432</id>
	<title>Re: Fixing Parser Weirdness</title>
	<published>2009-10-10T09:18:13Z</published>
	<updated>2009-10-10T09:18:13Z</updated>
	<author>
		<name>twashing</name>
	</author>
	<content type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div style=&quot;font-family:arial,helvetica,sans-serif;font-size:10pt&quot;&gt;&lt;div&gt;Ok great. I got this problem sorted out. A long haul, but looking at the token stream definitely helped. &lt;br&gt;&lt;br&gt;Thanks a bunch Chris&lt;br&gt;Tim&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;font-family: arial,helvetica,sans-serif; font-size: 10pt;&quot;&gt;&lt;br&gt;&lt;div style=&quot;font-family: times new roman,new york,times,serif; font-size: 12pt;&quot;&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;hr size=&quot;1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;From:&lt;/span&gt;&lt;/b&gt; Christopher Van Kirk &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;chris.vankirk@...&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;To:&lt;/span&gt;&lt;/b&gt; Discussion mailing list for the SableCC project &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sent:&lt;/span&gt;&lt;/b&gt; Thu, October 8, 2009 10:39:39 PM&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subject:&lt;/span&gt;&lt;/b&gt; RE: Fixing Parser Weirdness&lt;br&gt;&lt;/font&gt;&lt;br&gt;


 


 





&lt;div class=&quot;Section1&quot;&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;This is a useful gem from
Indrek Mandre that prints out the lexer stream (my version is for .net but you
can translate easily). Use this then analyse the lexer output and see if you
can match it to your syntax. I suspect you’re getting tokens you don’t expect.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font color=&quot;blue&quot; face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;&quot;&gt;class&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt; &lt;font color=&quot;#2b91af&quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;TestLexer&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;/font&gt; &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;/font&gt; &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;/font&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Main&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;(&lt;font color=&quot;#2b91af&quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;String&lt;/span&gt;&lt;/font&gt;[] args)&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lexer l = &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;/font&gt; Lexer(&lt;font color=&quot;#2b91af&quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;Console&lt;/span&gt;&lt;/font&gt;.In);&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt;&lt;/font&gt; (&lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;/font&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Token token =
l.Next();&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;#2b91af&quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175);&quot;&gt;Console&lt;/span&gt;&lt;/font&gt;.WriteLine (&lt;font color=&quot;#a31515&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;Read token '&quot;&lt;/span&gt;&lt;/font&gt; +
token.GetType().Name +&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;#a31515&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;', Text = [&quot;&lt;/span&gt;&lt;/font&gt;
+ token.Text + &lt;font color=&quot;#a31515&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;] at
[&quot;&lt;/span&gt;&lt;/font&gt; + token.Line +&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;#a31515&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;/font&gt; +
token.Pos + &lt;font color=&quot;#a31515&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;]&quot;&lt;/span&gt;&lt;/font&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;/font&gt; ( token &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;is&lt;/span&gt;&lt;/font&gt; EOF ) &lt;font color=&quot;blue&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;&lt;/font&gt;;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;&quot;&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;-----Original Message-----&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;From:&lt;/span&gt;&lt;/b&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;]
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;On Behalf Of &lt;/span&gt;&lt;/b&gt;Timothy Washington&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sent:&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;Friday, October
 09, 2009&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;5:37 AM&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;To:&lt;/span&gt;&lt;/b&gt; Discussion mailing list for
the SableCC project&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subject:&lt;/span&gt;&lt;/b&gt; Re: Fixing Parser
Weirdness&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;

&lt;div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12pt;&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Hey there, thanks for the feedback.
Agreed, I think that if I solve 'A', thenthe rest will fall into place. What I
am spitting out, the stream as you put it, is the &quot;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;action array / lexer.peek() / state&lt;/span&gt;&lt;/b&gt;&quot;
as seen from the Parser's point of view. The output was in bold red in fig. 2
(logs). Line 98 in fig. 1 was what generated that error (everything works if I
remove 98). And see line 166 from the Parser.parse method below. That's where
I'm putting the debug information. But there's probably a better way of
isolating the error. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Parser.java (client won't let me attach java file) &lt;br&gt;
...&lt;br&gt;
&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&amp;nbsp;112&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
@SuppressWarnings(&quot;unchecked&quot;)&lt;br&gt;
&amp;nbsp;113&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Start parse() throws ParserException,
LexerException, IOException&lt;br&gt;
&amp;nbsp;114&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;115&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; push(0, null, true);&lt;br&gt;
&amp;nbsp;116&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;Node&amp;gt; ign
= null;&lt;br&gt;
&amp;nbsp;117&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(true)&lt;br&gt;
&amp;nbsp;118&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;119&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
while(index(this.lexer.peek()) == -1)&lt;br&gt;
&amp;nbsp;120&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;121&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if(ign == null)&lt;br&gt;
&amp;nbsp;122&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ign = new LinkedList&amp;lt;Node&amp;gt;();&lt;br&gt;
&amp;nbsp;124&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;125 &lt;br&gt;
&amp;nbsp;126&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ign.add(this.lexer.next());&lt;br&gt;
&amp;nbsp;127&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;128 &lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;&quot;&gt;&amp;nbsp;129&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if(ign != null)&lt;/span&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&lt;br&gt;
&amp;nbsp;130&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;131&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.ignoredTokens.setIn(this.lexer.peek(), ign);&lt;br&gt;
&amp;nbsp;132&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ign = null;&lt;br&gt;
&amp;nbsp;133&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;&quot;&gt;&amp;nbsp;134 &lt;/span&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&lt;br&gt;
&amp;nbsp;135&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.last_pos = this.lexer.peek().getPos();&lt;br&gt;
&amp;nbsp;136&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.last_line = this.lexer.peek().getLine();&lt;br&gt;
&amp;nbsp;137&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.last_token = this.lexer.peek();&lt;br&gt;
&amp;nbsp;138 &lt;br&gt;
&amp;nbsp;139&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int index = index(this.lexer.peek());&lt;br&gt;
&amp;nbsp;140&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.action[0] = Parser.actionTable[state()][0][1];&lt;br&gt;
&amp;nbsp;141&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.action[1] = Parser.actionTable[state()][0][2];&lt;br&gt;
&amp;nbsp;142 &lt;br&gt;
&amp;nbsp;143&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int low = 1;&lt;br&gt;
&amp;nbsp;144&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int high = Parser.actionTable[state()].length - 1;&lt;/span&gt;&lt;/font&gt;&lt;br style=&quot;&quot;&gt;
&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&amp;nbsp;145 &lt;br&gt;
&amp;nbsp;146&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
while(low &amp;lt;= high)&lt;br&gt;
&amp;nbsp;147&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;148&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int middle = (low + high) / 2;&lt;br&gt;
&amp;nbsp;149 &lt;br&gt;
&amp;nbsp;150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if(index &amp;lt; Parser.actionTable[state()][middle][0])&lt;br&gt;
&amp;nbsp;151&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;152&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
high = middle - 1;&lt;br&gt;
&amp;nbsp;153&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;154&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
else if(index &amp;gt; Parser.actionTable[state()][middle][0])&lt;br&gt;
&amp;nbsp;155&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;156&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
low = middle + 1;&lt;br&gt;
&amp;nbsp;157&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;158&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
else&lt;br&gt;
&amp;nbsp;159&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;160&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.action[0] = Parser.actionTable[state()][middle][1];&lt;br&gt;
&amp;nbsp;161&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this.action[1] = Parser.actionTable[state()][middle][2];&lt;br&gt;
&amp;nbsp;162&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
break;&lt;br&gt;
&amp;nbsp;163&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;164&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;165 &lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;black&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;nbsp;166&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println(&quot;debugging... action[&quot;+this.action[0]+&quot;] /
lexer.peek[&quot;+this.lexer.peek()+&quot;] /
state[&quot;+state()+&quot;]&quot;);&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&amp;nbsp;167 &lt;br&gt;
&amp;nbsp;168&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
switch(this.action[0])&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;&quot;&gt;&amp;nbsp;169&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&lt;br&gt;
&amp;nbsp;170&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
case SHIFT:&lt;br&gt;
&amp;nbsp;171&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/span&gt;&lt;/font&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
Tim&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/div&gt;

&lt;div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot; align=&quot;center&quot;&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;1&quot; width=&quot;100%&quot;&gt;

&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12pt;&quot;&gt;&lt;b&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma; font-weight: bold;&quot;&gt;From:&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;
Christopher Van Kirk &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;chris.vankirk@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;To:&lt;/span&gt;&lt;/b&gt; Discussion mailing list for
the SableCC project &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sent:&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;Wed, October 7,
 2009&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;8:18:22 PM&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subject:&lt;/span&gt;&lt;/b&gt; RE: Fixing Parser
Weirdness&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;Have you tried the approach to solving ‘A’
that I suggested in my last posting? If you have and you’re still confused then
post the token stream emitted by your lexer and we can go from there.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;In solving A you may acquire the skills
you need to solve B, so I think you should just let B slide for the moment. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font color=&quot;navy&quot; face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial; color: navy;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;-----Original Message-----&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;From:&lt;/span&gt;&lt;/b&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;
[mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...&lt;/a&gt;]
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;On Behalf Of &lt;/span&gt;&lt;/b&gt;Timothy Washington&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sent:&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;Thursday,
 October 08, 2009&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;7:50 AM&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Tahoma;&quot;&gt;&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;To:&lt;/span&gt;&lt;/b&gt; Discussion mailing list for
the SableCC project&lt;br&gt;
&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subject:&lt;/span&gt;&lt;/b&gt; Re: Fixing Parser
Weirdness&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 12pt;&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Hey Chris, thanks for
responding to this problem thus far. I've been tied up on other projects, but
have come back to these problems. Right now I want to do 2 things: &lt;br&gt;
&lt;br&gt;
A) Be able to add a new token (that provides an extra option in the language,
-returninput). &lt;br&gt;
B) Allow special characters in an XML block (&amp;lt;mytag value='&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;twashing@...&lt;/a&gt;' /&amp;gt;). &lt;br&gt;
&lt;br&gt;
So looking at problem A), I actually was printing out the characters the Parser
was picking from the Lexer. If I add the token on line 98 (see fig. 1), I get
the error in fig. 2. Normally, using the expression &quot;&lt;i&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115); font-style: italic;&quot;&gt;login ( user
-username root -password password );&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&quot; works fine. But
just with line 98, I get the error that the Parser / Lexer is expecting an
opening bracket &quot;(&quot;, which is obviously there. So now the question is
i) what does it think the &quot;&lt;b&gt;&lt;i&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115); font-weight: bold; font-style: italic;&quot;&gt;login&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;b&gt;&lt;i&gt;&lt;font color=&quot;black&quot; size=&quot;4&quot;&gt;&lt;span style=&quot;font-size: 13.5pt; color: black; font-weight: bold; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;font color=&quot;#737373&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: rgb(115, 115, 115); font-weight: bold; font-style: italic;&quot;&gt;...&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/b&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&quot; is and ii) how does line 98 change
a working token to this broken state? I've also re-attached my sablecc file. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;i&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115); font-style: italic;&quot;&gt;97&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currency_opt = '-currency' ws+ ( lowercase | uppercase |
dash | colon_helper | ats | underscore | digit | dot )*;&lt;br&gt;
98&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; returninput_opt = '-returninput' ws+ ( lowercase
| uppercase | dash | colon_helper | ats | underscore | digit | dot )*;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;br&gt;
fig. 1 - bkeeping.cc sablecc file &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;i&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115); font-style: italic;&quot;&gt;login (
user -username root -password password ); &lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;red&quot;&gt;&lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;debugging...
action[0] / lexer.peek[login ] / state[0]&lt;br&gt;
debugging... action[3] / lexer.peek[( ] / state[12]&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#737373&quot;&gt;&lt;span style=&quot;color: rgb(115, 115, 115);&quot;&gt;&lt;br&gt;
ERROR [Thread-3] (Bkell.java:187) - [14,7] expecting: lbracket&lt;br&gt;
com.interrupt.bookkeeping.cc.parser.ParserException: [14,7] expecting: lbracket&lt;br&gt;
&amp;nbsp; &amp;nbsp; at com.interrupt.bookkeeping.cc.parser.Parser.parse(Parser.java:1024)&lt;br&gt;
&amp;nbsp; &amp;nbsp; at com.interrupt.bookkeeping.cc.bkell.Bkell.run(Bkell.java:146)&lt;br&gt;
&amp;nbsp; &amp;nbsp; at java.lang.Thread.run(Thread.java:637)&lt;br&gt;
ERROR [Thread-3] (Util.java:96) - generateBkellException CALLED&lt;br&gt;
ERROR [Thread-3] (Util.java:102) - TOP error message[[14,7] expecting:
lbracket]&lt;br&gt;
ERROR [Thread-3] (Util.java:103) - ROOT error message[[14,7] expecting:
lbracket]&lt;br&gt;
ERROR [Thread-3] (Bkell.java:189) - &amp;lt;logs xmlns='com/interrupt/logs' id=''
&amp;gt;&amp;lt;log xmlns='com/interrupt/logs' level='ERROR' id='' &amp;gt;&amp;lt;logMessages
xmlns='com/interrupt/logs' id='' &amp;gt;&amp;lt;logMessage xmlns='com/interrupt/logs'
id='' &amp;gt;[14,7] expecting: lbracket&amp;lt;/logMessage&amp;gt;&lt;br&gt;
&amp;lt;/logMessages&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&amp;lt;/log&amp;gt;&lt;/i&gt;&lt;br&gt;
&amp;lt;/logs&amp;gt;&lt;br&gt;
fig. 2 - logs &lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;br&gt;
&lt;br&gt;
&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Thanks&lt;br&gt;
Tim&lt;br&gt;
&lt;/span&gt;&lt;/font&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
----- Original Message ----&lt;br&gt;
From: Christopher Van Kirk &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;chris.vankirk@...&lt;/a&gt;&amp;gt;&lt;br&gt;
To: Discussion mailing list for the SableCC project &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&amp;gt;&lt;br&gt;
Sent: Thu, September 3, 2009 10:47:11 PM&lt;br&gt;
Subject: Re: Fixing Parser Weirdness&lt;br&gt;
&lt;br&gt;
When I have a problem like this, generally I'll print out the token stream for
the affected area and try to match it to the production I think the parser
should choose. When I say print out the token stream, I mean print out the
actual stream as generated by the lexer.&lt;br&gt;
&lt;br&gt;
If you do that, I think you will find that you either have grammatical or
lexical problems (either the token stream isn't what you think it is, or the
syntax isn't what you want it to be). It's good to get into practice doing this
sort of thing because this will come up from time to time and it's best to be
able to resolve it by yourself.&lt;br&gt;
&lt;br&gt;
Also note that SableCC is telling you what token it thinks should come next. From
that you can deduce what production is actually being selected, which again
should help you identify the problem.&lt;br&gt;
&lt;br&gt;
--- On Thu, 9/3/09, Timothy Washington &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;timothyjwashington@...&lt;/a&gt;&amp;gt;
wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; From: Timothy Washington &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;timothyjwashington@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt; Subject: Re: Fixing Parser Weirdness&lt;br&gt;
&amp;gt; To: &quot;Discussion mailing list for the SableCC project&quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=13&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt; Date: Thursday, September 3, 2009, 11:49 PM&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That's actually a really good point - I made that&lt;br&gt;
&amp;gt; change. But the parser is still breaking with the error in&lt;br&gt;
&amp;gt; fig. 1 when &lt;br&gt;
&amp;gt; I do a simple command ( see fig. 0 ). Ultimately I want to&lt;br&gt;
&amp;gt; make a command like in fig. 2. To remove the error, all I&lt;br&gt;
&amp;gt; have to &lt;br&gt;
&amp;gt; do is remove the &quot;returninput_opt&quot; parts ( lines&lt;br&gt;
&amp;gt; 98 &amp;amp; 288 ). This is what I meant by a sensitive parser,&lt;br&gt;
&amp;gt; because I can't see &lt;br&gt;
&amp;gt; how those 2 lines would break an unrelated token /&lt;br&gt;
&amp;gt; production. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; login ( user -username root -password password ); &lt;br&gt;
&amp;gt; fig. 0 &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; login ( user -username root -password password ); &lt;br&gt;
&amp;gt; ERROR [Thread-3] (Bkell.java:186) - [4,7] expecting:&lt;br&gt;
&amp;gt; lbracket&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.ParserException:&lt;br&gt;
&amp;gt; [4,7] expecting:&lt;br&gt;
&amp;gt;&amp;nbsp; lbracket&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.Parser.parse(Parser.java:1022)&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.bkell.Bkell.run(Bkell.java:145)&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; java.lang.Thread.run(Thread.java:637)&lt;br&gt;
&amp;gt; ERROR [Thread-3] (Bkell.java:188) - &amp;lt;logs&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' id='' &amp;gt;&amp;lt;log&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' level='ERROR'&lt;br&gt;
&amp;gt; id='' &amp;gt;&amp;lt;logMessages&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' id=''&lt;br&gt;
&amp;gt; &amp;gt;&amp;lt;logMessage xmlns='com/interrupt/logs'&lt;br&gt;
&amp;gt; id='' &amp;gt;[4,7] expecting:&lt;br&gt;
&amp;gt; lbracket&amp;lt;/logMessage&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/logMessages&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/log&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/logs&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ERROR [Thread-3] (Bkell.java:186) - [1,2] expecting:&lt;br&gt;
&amp;gt; 'var', 'create', 'add',&lt;br&gt;
&amp;gt; 'update', 'remove', 'reverse',&lt;br&gt;
&amp;gt; 'find', 'list', 'print',&lt;br&gt;
&amp;gt; 'commit', 'load', 'login',&lt;br&gt;
&amp;gt; 'logout', 'exit'&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.ParserException:&lt;br&gt;
&amp;gt; [1,2] expecting: 'var', 'create',&lt;br&gt;
&amp;gt; 'add', 'update', 'remove',&lt;br&gt;
&amp;gt;&amp;nbsp; 'reverse', 'find', 'list',&lt;br&gt;
&amp;gt; 'print', 'commit', 'load',&lt;br&gt;
&amp;gt; 'login', 'logout',&lt;br&gt;
&amp;gt; 'exit'&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.Parser.parse(Parser.java:1022)&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.bkell.Bkell.run(Bkell.java:145)&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; java.lang.Thread.run(Thread.java:637)&lt;br&gt;
&amp;gt; ERROR [Thread-3] (Bkell.java:188) - &amp;lt;logs&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' id='' &amp;gt;&amp;lt;log&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' level='ERROR'&lt;br&gt;
&amp;gt; id='' &amp;gt;&amp;lt;logMessages&lt;br&gt;
&amp;gt; xmlns='com/interrupt/logs' id=''&lt;br&gt;
&amp;gt; &amp;gt;&amp;lt;logMessage xmlns='com/interrupt/logs'&lt;br&gt;
&amp;gt; id='' &amp;gt;[1,2] expecting: 'var',&lt;br&gt;
&amp;gt; 'create', 'add', 'update',&lt;br&gt;
&amp;gt; 'remove', 'reverse', 'find',&lt;br&gt;
&amp;gt; 'list', 'print', 'commit',&lt;br&gt;
&amp;gt; 'load', 'login', 'logout',&lt;br&gt;
&amp;gt; 'exit'&amp;lt;/logMessage&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/logMessages&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/log&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;/logs&amp;gt;&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 1 &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; var aauthUsers = add ( ( load ( `/system[&lt;br&gt;
&amp;gt; @id='main.system' ]` ) )&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;lt;user xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='seven' username='seven'&lt;br&gt;
&amp;gt; password='seven' logintimeout='600000' &amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;profileDetails&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='user.details' &amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='firstname' name='first.name'&lt;br&gt;
&amp;gt; value='seven' /&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='lastname' name='last.name'&lt;br&gt;
&amp;gt; value='seven' /&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='email' name='email'&lt;br&gt;
&amp;gt; value='&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=14&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;twashing@...&lt;/a&gt;'&lt;br&gt;
&amp;gt;&amp;nbsp; /&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='country' name='country'&lt;br&gt;
&amp;gt; value='U.S.A' /&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;/profileDetails&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;/user&amp;gt;&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,&lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; -returninput&lt;br&gt;
&amp;gt; true &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 2 &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Tim&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; From: Christopher Van Kirk&lt;br&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=15&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;chris.vankirk@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt; To:&lt;br&gt;
&amp;gt; Discussion mailing list for the SableCC project&lt;br&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=16&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&amp;gt;&lt;br&gt;
&amp;gt; Sent:&lt;br&gt;
&amp;gt; Thursday, September 3, 2009 12:08:21 AM&lt;br&gt;
&amp;gt; Subject: RE:&lt;br&gt;
&amp;gt; Fixing Parser Weirdness&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is&lt;br&gt;
&amp;gt; probably your problem:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; dash = '-';&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; .&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; .&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; .&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; entry_opt = '-entry' ws+ (&lt;br&gt;
&amp;gt; lowercase | uppercase | dash | colon_helper |&amp;nbsp; ats |&lt;br&gt;
&amp;gt; underscore | digit | dot&lt;br&gt;
&amp;gt; )*; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You’ve&lt;br&gt;
&amp;gt; defined a dash token in the lexer&lt;br&gt;
&amp;gt; section, but you’re expecting to see it joined to a word&lt;br&gt;
&amp;gt; in the parser,&lt;br&gt;
&amp;gt; Remember that what comes out of the Tokens section is a&lt;br&gt;
&amp;gt; stream of tokens you&lt;br&gt;
&amp;gt; have defined there, so what your parser will see&lt;br&gt;
&amp;gt; is&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; dash&lt;br&gt;
&amp;gt; entry …&lt;br&gt;
&amp;gt; not -entry&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Try&lt;br&gt;
&amp;gt; changing your production to something&lt;br&gt;
&amp;gt; like:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; entry_opt = dash&lt;br&gt;
&amp;gt; 'entry' ws+ (&lt;br&gt;
&amp;gt; lowercase | uppercase | dash | colon_helper |&amp;nbsp; ats |&lt;br&gt;
&amp;gt; underscore | digit | dot&lt;br&gt;
&amp;gt; )*; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Cheers,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Chris…&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -----Original&lt;br&gt;
&amp;gt; Message-----&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; From:&lt;br&gt;
&amp;gt; sablecc-discussion-bounces+chris.vankirk=&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=17&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;fdcjapan.com@...&lt;/a&gt;&lt;br&gt;
&amp;gt; [mailto:sablecc-discussion-bounces+chris.vankirk=&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=18&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;fdcjapan.com@...&lt;/a&gt;]&lt;br&gt;
&amp;gt; On Behalf Of&lt;br&gt;
&amp;gt; Timothy Washington&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Sent:&lt;br&gt;
&amp;gt; Wednesday,&lt;br&gt;
&amp;gt;&amp;nbsp; September 02, 2009&lt;br&gt;
&amp;gt; 11:43&lt;br&gt;
&amp;gt; PM&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; To:&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=19&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sablecc-discussion@...&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Subject:&lt;br&gt;
&amp;gt; Fixing Parser Weirdness&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hey&lt;br&gt;
&amp;gt; all, I've implemented a language using sablecc that&lt;br&gt;
&amp;gt; looks like in fig. 1. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; command( &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; ( &amp;lt;context/&amp;gt; ) &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input/&amp;gt;, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; `/input[&lt;br&gt;
&amp;gt; @att='value' ]`, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -inputoption value &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ); &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A) I'm trying to implement an input option, &quot;&lt;br&gt;
&amp;gt; -inputoption value &quot;,&lt;br&gt;
&amp;gt; but if I try to implement the command in fig. 2, I get the&lt;br&gt;
&amp;gt; error &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; seen in fig. 4. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; var removedE = remove ( ( load( `/system[&lt;br&gt;
&amp;gt; @id=&quot;main.system&quot; ]/groups[&lt;br&gt;
&amp;gt; @id=&quot;main.groups&quot; ]/group[&lt;br&gt;
&amp;gt; @id=&quot;seven.group&quot; ]/bookkeeping[&lt;br&gt;
&amp;gt; @id=&quot;main.bookkeeping&quot; ]/journals[&lt;br&gt;
&amp;gt; @id=&quot;main.journals&quot;&lt;br&gt;
&amp;gt; ]/journal[ @id=&quot;generalledger&quot; ]/entries[&lt;br&gt;
&amp;gt; @id=&quot;main.entries&quot; ]` ) ) &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;entry&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/journal'&lt;br&gt;
&amp;gt; id='qwer' entrynum='' state=''&lt;br&gt;
&amp;gt; journalid='' date='02022006'&lt;br&gt;
&amp;gt; currency='CDN' &amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;debit&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/account'&lt;br&gt;
&amp;gt; id='asdf' amount='11.00' entryid=''&lt;br&gt;
&amp;gt; accountid='1' account='office equipment'&lt;br&gt;
&amp;gt; currency='CDN' /&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;debit&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/account'&lt;br&gt;
&amp;gt; id='zxcv' amount='1.50' entryid=''&lt;br&gt;
&amp;gt; accountid='2' account='tax'&lt;br&gt;
&amp;gt; currency='CDN' /&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;credit&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/account'&lt;br&gt;
&amp;gt; id='tyui' amount='12.50' entryid=''&lt;br&gt;
&amp;gt; accountid='3' account='bank'&lt;br&gt;
&amp;gt; currency='CDN' /&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/entry&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; -returninput&lt;br&gt;
&amp;gt; true &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; );&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 2&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; B) I'm also trying to get SableCC to ignore special&lt;br&gt;
&amp;gt; characters between single&lt;br&gt;
&amp;gt; and double quotes ( ' &quot; ). So for example, I want&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; to be able to say &amp;lt;profileDetail&lt;br&gt;
&amp;gt; value='&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=20&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;twashing@...&lt;/a&gt;' /&amp;gt;, but the&lt;br&gt;
&amp;gt; parser dies with the error in fig. 5. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; var aauthUsers = add ( ( load ( `/system[&lt;br&gt;
&amp;gt; @id='main.system' ]` ) )&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;user&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='seven' username='seven'&lt;br&gt;
&amp;gt; password='seven' logintimeout='600000'&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;profileDetails&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='user.details'&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='firstname' name='first.name'&lt;br&gt;
&amp;gt; value='seven' /&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='lastname' name='last.name'&lt;br&gt;
&amp;gt; value='seven' /&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='email' name='email'&lt;br&gt;
&amp;gt; value='&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=21&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;twashing@...&lt;/a&gt;' /&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;profileDetail&lt;br&gt;
&amp;gt; xmlns='com/interrupt/bookkeeping/users'&lt;br&gt;
&amp;gt; id='country' name='country'&lt;br&gt;
&amp;gt; value='U.S.A' /&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;lt;/profileDetails&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; &amp;lt;/user&amp;gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It feels like Sablecc is very sensitive in the order of&lt;br&gt;
&amp;gt; tokens. Can anyone help&lt;br&gt;
&amp;gt; me isolate and fix this problem. I've attached &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; my sablecc file.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Tim &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.ParserException: [1,1]&lt;br&gt;
&amp;gt; expecting: 'var',&lt;br&gt;
&amp;gt; 'create', 'add', 'update',&lt;br&gt;
&amp;gt; 'remove', 'reverse', 'find',&lt;br&gt;
&amp;gt; 'list', 'print',&lt;br&gt;
&amp;gt; 'commit', 'load', 'login',&lt;br&gt;
&amp;gt; 'logout', 'exit'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.Parser.parse(Parser.java:1028)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.bkell.Bkell.run(Bkell.java:145)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; java.lang.Thread.run(Thread.java:637)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 4&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.ParserException: [19,3]&lt;br&gt;
&amp;gt; expecting:&lt;br&gt;
&amp;gt; 'create', 'add', 'update',&lt;br&gt;
&amp;gt; 'remove', 'reverse', 'find',&lt;br&gt;
&amp;gt; 'list', 'print',&lt;br&gt;
&amp;gt; 'commit', 'load', 'login',&lt;br&gt;
&amp;gt; 'logout', 'exit', 'system',&lt;br&gt;
&amp;gt; 'debit', 'credit',&lt;br&gt;
&amp;gt; 'entry', 'entries', 'journal',&lt;br&gt;
&amp;gt; 'journals', 'transaction',&lt;br&gt;
&amp;gt; 'account',&lt;br&gt;
&amp;gt; 'accounts', 'user', 'users',&lt;br&gt;
&amp;gt; 'group', 'groups', 'allowedActions',&lt;br&gt;
&amp;gt; 'command',&lt;br&gt;
&amp;gt; 'profileDetails', 'profileDetail',&lt;br&gt;
&amp;gt; 'userSession', '&amp;lt;', rbracket, atsign,&lt;br&gt;
&amp;gt; '`'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.parser.Parser.parse(Parser.java:1022)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; com.interrupt.bookkeeping.cc.bkell.Bkell.run(Bkell.java:145)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; at&lt;br&gt;
&amp;gt; java.lang.Thread.run(Thread.java:637)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fig. 5&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Looking for the&lt;br&gt;
&amp;gt; perfect gift? Give the gift of&lt;br&gt;
&amp;gt; Flickr!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br&gt;
&amp;gt; Looking for the perfect gift? Give&lt;br&gt;
&amp;gt; the gift of Flickr!&lt;br&gt;
&amp;gt; -----Inline Attachment Follows-----&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; _______________________________________________&lt;br&gt;
&amp;gt; SableCC-Discussion mailing list&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=22&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
_______________________________________________&lt;br&gt;
SableCC-Discussion mailing list&lt;br&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=23&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;/p&gt;

&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot; align=&quot;center&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;1&quot; width=&quot;100%&quot;&gt;

&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;img src=&quot;http://us.i1.yimg.com/us.yimg.com/i/ca/iotg_search.jpg&quot; align=&quot;absbottom&quot; border=&quot;0&quot; height=&quot;25&quot; hspace=&quot;4&quot; width=&quot;25&quot;&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://ca.toolbar.yahoo.com/&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot; lang=&quot;NO-BOK&quot;&gt;Yahoo! Canada
Toolbar :&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;NO-BOK&quot;&gt; Search from anywhere on the web and
bookmark your favourite sites. Download it now! &lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;No
virus found in this incoming message.&lt;br&gt;
Checked by AVG - &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.avg.com&quot;&gt;www.avg.com&lt;/a&gt;&lt;br&gt;
Version: 8.5.421 / Virus Database: 270.14.3/2414 - Release Date: &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;10/07/09&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt; 20:49:00&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/div&gt;

&lt;/div&gt;

&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot; align=&quot;center&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;1&quot; width=&quot;100%&quot;&gt;

&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;

&lt;p class=&quot;MsoNormal&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;img src=&quot;http://us.i1.yimg.com/us.yimg.com/i/ca/iotg_search.jpg&quot; align=&quot;absbottom&quot; border=&quot;0&quot; height=&quot;25&quot; hspace=&quot;4&quot; width=&quot;25&quot;&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://ca.toolbar.yahoo.com/&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot; lang=&quot;NO-BOK&quot;&gt;Yahoo! Canada Toolbar :&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;NO-BOK&quot;&gt; Search from anywhere on the web and bookmark your favourite sites.
Download it now! &lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/div&gt; 

&lt;p&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;No virus found in this incoming message.&lt;br&gt;&lt;span&gt;
Checked by AVG - &lt;a target=&quot;_blank&quot; href=&quot;http://www.avg.com&quot; rel=&quot;nofollow&quot;&gt;www.avg.com&lt;/a&gt;&lt;/span&gt;&lt;br&gt;
Version: 8.5.421 / Virus Database: 270.14.3/2414 - Release Date: 10/08/09 18:33:00&lt;br&gt;
&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt; &lt;/font&gt; &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;
      &lt;hr size=1&gt; &lt;a href=&quot;http://ca.promos.yahoo.com/jacko/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Get the name you&amp;#39;ve always wanted &lt;/a&gt;! &lt;strong&gt;@ymail.com &lt;/strong&gt;or &lt;strong&gt;@rocketmail.com&lt;/strong&gt;.&lt;/body&gt;&lt;/html&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;SableCC-Discussion mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=25836432&amp;i=24&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;SableCC-Discussion@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://lists.sablecc.org/listinfo/sablecc-discussion&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://lists.sablecc.org/listinfo/sablecc-discussion&lt;/a&gt;&lt;br&gt;&lt;p&gt;From forum: &lt;a href=&quot;http://old.nabble.com/SableCC---User-f12281.html&quot; embed=&quot;fixTarget[12281]&quot; target=&quot;_top&quot; &gt;SableCC - User&lt;/a&gt;&lt;/p&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Re%3A-Fixing-Parser-Weirdness-tp25796062p25836432.html" />
</entry>

</feed>
