lex rules

"Blake Stone" <brian@NOSPAMibc.com.au>
30 Nov 2000 13:46:27 -0500

          From comp.compilers

Related articles
lex rules brian@NOSPAMibc.com.au (Blake Stone) (2000-11-30)
Re: lex rules fjh@cs.mu.OZ.AU (2000-12-01)
Re: lex rules esmond.pitt@bigpond.com (Esmond Pitt) (2000-12-01)
| List of all articles for this month |

From: "Blake Stone" <brian@NOSPAMibc.com.au>
Newsgroups: comp.compilers
Date: 30 Nov 2000 13:46:27 -0500
Organization: Customer of Telstra Big Pond Direct
Keywords: lex, question
Posted-Date: 30 Nov 2000 13:46:27 EST

Hi All,


        Sorry if this isn't the right place. Are there any lex/yacc specific
forums?


I have some lex code below:


ws [ \t\r\n]+
eq {ws}?"="{ws}?
dq "\""
sq "'"


VersionNum [a-zA-Z0-9_.:]+
EncName [A-Za-z][A-Za-z0-9._]*


VersionInfo {ws}"version"{eq}({dq}|{sq}){VersionNum}({dq}|{sq})
EncodingDecl {ws}"encoding"{eq}({dq}|{sq}){EncName}({dq}|{sq})
StandaloneDecl {ws}"standalone"{eq}({dq}|{sq})("yes"|"no")({dq}|{sq})
XmlDecl "<?xml"{VersionInfo}{EncodingDecl}?{StandaloneDecl}?{ws}?"?>"


%%
{XmlDecl} { return XMLDECL; }


Note that the EncodingDecl and StandaloneDecl should be optional. Yet, when
I have
<?xml version="1.0" ?> as input it does not match {XmlDecl}. If I
remove{EncodingDecl} and {StandaloneDecl} then it works fine (or if I expand
the input to use them). Why is this and how do I fix it?




Cheers,


Blake
[I think I've seen bugs before in nested named patterns. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.