[erlang-questions] yecc subpattern issue

Phil Pirozhkov <>
Sun Dec 28 00:26:49 CET 2008


Thank you for helping me out again, Robert!

The point was that adding elements to matched list doesn't work.

This one works fine:
blocks -> blocks block : '$1' ++ ['$2'].

And this one (i used before):
blocks -> block blocks : ['$1' | '$2'].
(yes, blocks and block reverted here compared to the first example,
because of $2 (blocks) should be a list, and $1 (block) - a value).

This is odd, because [H|T] seems to be more erlang'ish (and more optimal i suggest?)
than ++.

Just rolled back TokenLine changes, they doesn't affect parser at all, i.e.
it works perfectly fine with leex provided tuples of the following format:

[{'{'},{forc},{identifier,a},{in},{identifier,b},{'}'},{'{'},
     {identifier,a},{'}'},{text," kg"},{'{'},{endc},{'}'}].

Just to notice, '$end' is not required too, works fine without it.
Maybe line numbers and '$end' should be marked as optional in yecc docs.
I agree that line numbers are very helpful when it comes to seek for issues
in the data provided to parser, but this only eats up memory when is not required.

> A quick comment without really studying everything in detail: yecc generated
> grammers expect the tokens to have the format:
> 
> {Type,TokenLine} or {Type,TokenLine,TokenValue}
> 
> So for example some erlang tokens would be {':-', 53}, {atom,46,name} and
> {var,32,'Name'}.
> 
> From what I could see in the .xrl file the tokens you returned don't have
> that format. This may be the cause of your errors.

Cheers, Phil



More information about the erlang-questions mailing list