Posted By:
Nikhil_Deshpande
Posted On:
Friday, January 12, 2001 04:46 AM
I am building a lexer+parser for sendmail aliases file. The part of the grammar I'm having problem with is: (this is a just a small part) anAlias ::= aliasName ':' aliasTarget and the aliasTarget non-term can take following forms(and also other forms but not given here) aliasTarget ::= ":include:" FILEPATH | LOCALUSER (where FILEPATH is like /path/to/a/file and LOCALUSER is a simple [a-zA-Z]+ and also aliasName is LOCALUSER). The problem is with my lexer spec. I have in my lexer spec: COLON : ':' ; INCLUDE : ":include:" (WS)* FILEPATH ;
More>>
I am building a lexer+parser for sendmail aliases file.
The part of the grammar I'm having problem with is:
(this is a just a small part)
anAlias ::= aliasName ':' aliasTarget
and the aliasTarget non-term can take following forms(and
also other forms but not given here)
aliasTarget ::= ":include:" FILEPATH
| LOCALUSER
(where FILEPATH is like /path/to/a/file and
LOCALUSER is a simple [a-zA-Z]+ and also
aliasName is LOCALUSER).
The problem is with my lexer spec.
I have in my lexer spec:
COLON : ':'
;
INCLUDE : ":include:" (WS)* FILEPATH
;
And my parser spec says:
anAlias : LOCALUSER (WS)* COLON (WS)* aliasTarget
;
aliasTarget : ( LOCALUSER
| INCLUDE)
;
The problem comes for the following input:
myalias:issoft
which is of the grammar form
aliasName COLON LOCALUSER
The lexer tries to match ":issoft" to INCLUDE
and not divide it into COLON followed by LOCALUSER.
How can I use the syntactic predicate here?
<<Less