Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [TCS] Multiple "operatored" templates conflict
[TCS] Multiple "operatored" templates conflict [message #596062] Tue, 08 May 2007 09:45
Lorenzo Dalla Vecchia is currently offline Lorenzo Dalla VecchiaFriend
Messages: 58
Registered: July 2009
Member
Hello again.

Either I found a bug or I am doing something wrong.
In the language I'm trying to parse using TCS there are two kinds of
expressions, arithmetical and logical, that should never mix. I implemented
them in TCS in the following way.

For arithmetical expressions

- A primary "Value" non-terminal
- An abstract Expression nonterminal, "operatored", extended in three ways:
- an ActualValue, itself containing a Value
- an OperatorExpression (operatorTemplate) with operators + - * /
- a SubExpression, an Expression encolsed in parenthesis
(operatorTemplate again, because it is left recursive)

For logical expressions:

- A primary "Term" non-terminal
- An abstract LogicalExpression nonterminal, "operatored", extended in three
ways:
- an ActualTerm, itself containing a Term
- an OperatorLogicalExpression (operatorTemplate) with operators "or"
"and"
- a SubLogicalExpression, a LogicalExpression encolsed in parenthesis
(operatorTemplate again, see above)

Now, if I test those two parts of the grammar (by setting Expression or
LogicalExpression as the main template) the parsing goes well. However, if I
have a non-ambiguous rule producing either an Expression or a
LogicalExpression, in both cases there are problems parsing the expression.

I tried tracing the parser and found out that it is expecting the correct
type of expression (so this is not an ambiguity problem), but for some
reason when it reaches the point of parsing the "primary" expression
non-terminals, it always expects one of the two types, never the other,
regardless of the expression type it had started expanding in the first
place.
For example, it may start expanding an Expression and ending up expectng
Terms (LogicalExpression primaries) or vice versa. Oddly enough, it seems to
depend on the ANTLR compilation that randomly produces parsers recognizing
either Terms only or Values only, regardless of the expression nonterminal
expanded.

The compiler does not issue any error or warning, so I am clueless. Is this
a bug?
Thanks.

--
Lorenzo
Previous Topic:[TCS] Storing operators as enumeration values
Next Topic:[TCS] How to do a substring ?
Goto Forum:
  


Current Time: Wed Apr 24 20:52:03 GMT 2024

Powered by FUDForum. Page generated in 0.03031 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top