[erlang-questions] a question on leex and yacc usage

simon00 gotothere00@REDACTED
Mon Jan 19 05:29:43 CET 2009


I am a newbie to erlang, trying to write a parser for an ip list file as my
study excercise as follows:

192.168.1.2;
124.123.4.4;

The leex file is as follows:
------------------------------------
Definitions.

Dig = [0-9]

Rules.

({Dig}{Dig}*)	: {token, {integer, YYline, list_to_integer(YYtext)}}.

\.  : {token, {'.', YYline}}.
\;  : {token, {';', YYline}}.

\s  : skip_token.
\r  : skip_token.
\t  : skip_token.
\n  : skip_token.
------------------------------------

The yecc file is as follows:
------------------------------------
Nonterminals iplist ipentry ip.

Terminals '/' '-' '.' 'atom' ';'.

Rootsymbol iplist.
iplist -> 
    ipentry ';' : ['$1'].

iplist -> 
    ipentry ';' iplist : ['$1', '$3'].

ipentry -> 
    ip : {ip, '$1'}.

ipentry ->
    ip '-' ip : {span, '$1', '$2'}.

ipentry ->
    ip '/' 'atom' : {cidr, '$1', '$2'}.   

ip -> 
    'atom' '.' 'atom' '.' 'atom' '.' 'atom' 
	: {'$1', '$2', '$3', '$4'}.
-----------------------------------

However, the excution always reports an error as follows:

------------------------------------
22> parser:file("ip.txt").
** 1 syntax error before: 192
{error,1}
------------------------------------

Could anybody kindly inform me of this problem? I cannot find any
documentation on such like problems. Many thanks!




-- 
View this message in context: http://www.nabble.com/a-question-on-leex-and-yacc-usage-tp21536268p21536268.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list