Created
August 4, 2009 19:19
-
-
Save ruoso/161467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar XML::SAX; | |
token TOP { | |
^ | |
<startDocument> | |
<element> | |
<endDocument> | |
$ | |
} | |
token startDocument { | |
<prolog> | |
{*} | |
} | |
token prolog { | |
<xmlDecl>? | |
<Misc>* | |
[ <doctypeDecl> | |
<Misc>* ]? | |
{*} | |
} | |
token endDocument { | |
<Misc>* | |
{*} | |
} | |
token Misc { | |
<S> | |
| <processingInstruction> | |
| <comment> | |
} | |
token whitespace { | |
["\x20" | "\x9" | "\xD" | "\xA"] | |
} | |
token S { | |
<whitespace> <ignorableWhitespace>? | |
} | |
token ignorableWhitespace { | |
<whitespace>+ {*} | |
} | |
token processingInstruction { | |
'<?' <PITarget> [<S> <char>*? ]? '?>' {*} | |
} | |
token PITarget { | |
<!before [['X'|'x']['M'|'m']['L'|'l']]> | |
<char*> | |
} | |
token xmlDecl { | |
'<?xml' <VersionInfo> <EncodingDecl>? <SDDecl>? <S>? '?>' {*} | |
} | |
token VersionInfo { | |
<S> 'version' <Eq> [ '"' <VersionNum> '"' | "'" <VersionNum> "'" ] | |
} | |
token Eq { | |
<S>? '=' <S>? | |
} | |
token VersionNum { | |
'1.' <[0..9]>+ | |
} | |
token SDDecl { | |
<S> 'standalone' <Eq> [["'" ['yes' | 'no'] "'"] | ['"' ['yes' | 'no'] '"']] | |
} | |
token EncodingDecl { | |
<S> 'encoding' <Eq> ['"' <EncName> '"' | "'" <EncName> "'" ] | |
} | |
token EncName { | |
<[A..Z a..z '.' '_']> <[A..Z a..z 0..9 '.' '_' '-']>* | |
} | |
token doctypeDecl { | |
'<!DOCTYPE' # die "NYI!" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment