Permalink
Browse files

updated to ll2

  • Loading branch information...
1 parent 7da74ff commit 291478f8d650dcd70c65af898aa79580da3b6f55 @xquery committed Sep 27, 2012
Showing with 645 additions and 2,549 deletions.
  1. +88 −35 grammar/microxml.ebnf
  2. +40 −49 grammar/microxml.xml
  3. +122 −542 parsers/microxml.hpp
  4. +124 −538 parsers/microxml.java
  5. +124 −538 parsers/microxml.js
  6. +147 −847 parsers/microxml.xquery
View
@@ -1,39 +1,92 @@
-document ::= byteOrderMark? (comment | s)* element (comment | s)*
-element ::= startTag content endTag | emptyElementTag
-startTag ::= '<' name attributeList s* '>'
-endTag ::= '</' name s* '>'
-content ::= (element | comment | dataChar | charRef)*
-emptyElementTag ::= '<' name attributeList s* '/>'
-attributeList ::= (s+ attribute)*
-attribute ::= attributeName s* '=' s* attributeValue
+document ::= byteOrderMark? ( comment | s )* element ( comment | s )* eof
+element ::= '<' name attributeList s? ( '>' content endTag | '/>' )
+endTag ::= '</' name s? '>'
+content ::= ( element | comment | dataChar | charRef )*
+attributeList
+ ::= ( s attribute )*
+attribute
+ ::= attributeName s? '=' s? attributeValue
<?TOKENS?>
-byteOrderMark ::= #xFEFF
-attributeValue ::= '"' ((attributeValueChar - '"') | charRef)* '"'
- | "'" ((attributeValueChar - "'") | charRef)* "'"
-attributeValueChar ::= char - ('<'|'>'|'&')
-attributeName ::= name - 'xmlns'
-comment ::= '<!--' ((char - '-') | ('-' (char - '-')))* '-->'
-charRef ::= numericCharRef | namedCharRef
-numericCharRef ::= '&#x' charNumber ';'
-
-dataChar ::= char - ('<'|'&'|'>')
-charNumber ::= [0-9a-fA-F]+
-namedCharRef ::= '&' charName ';'
-charName ::= 'amp' | 'lt' | 'gt' | 'quot' | 'apos'
-name ::= nameStartChar nameChar*
-nameStartChar ::= [A-Z] | [a-z] | "_" | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | ([#xF900-#xEFFFF] - nonCharacterCodePoint)
-nameChar ::= nameStartChar | [0-9] | "-" | "." | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
-char ::= s | ([#0-#x10FFFF] - forbiddenCodePoint)
-s ::= #x9 | #xA | #x20
-forbiddenCodePoint ::= controlCodePoint | surrogateCodePoint |
+byteOrderMark
+ ::= #xFEFF
+attributeValue
+ ::= '"' ( ( attributeValueChar - '"' ) | charRef )* '"'
+ | "'" ( ( attributeValueChar - "'" ) | charRef )* "'"
+attributeValueChar
+ ::= char - ( '<' | '>' | '&' )
+attributeName
+ ::= name - 'xmlns'
+comment ::= '<!--' ( ( char - '-' ) | '-' ( char - '-' ) )* '-->'
+charRef ::= numericCharRef
+ | namedCharRef
+numericCharRef
+ ::= '&#x' charNumber ';'
+dataChar ::= char - ( '<' | '&' | '>' )
+charNumber
+ ::= [0-9a-fA-F]+
+namedCharRef
+ ::= '&' charName ';'
+charName ::= 'amp'
+ | 'lt'
+ | 'gt'
+ | 'quot'
+ | 'apos'
+name ::= nameStartChar nameChar*
+nameStartChar
+ ::= [A-Z]
+ | [a-z]
+ | '_'
+ | [#x00C0-#x00D6]
+ | [#x00D8-#x00F6]
+ | [#x00F8-#x02FF]
+ | [#x0370-#x037D]
+ | [#x037F-#x1FFF]
+ | [#x200C-#x200D]
+ | [#x2070-#x218F]
+ | [#x2C00-#x2FEF]
+ | [#x3001-#xD7FF]
+ | ( [#xF900-#xEFFFF] - nonCharacterCodePoint )
+nameChar ::= nameStartChar
+ | [0-9]
+ | '-'
+ | '.'
+ | #x00B7
+ | [#x0300-#x036F]
+ | [#x203F-#x2040]
+char ::= space
+ | ( [#0-#x10FFFF] - forbiddenCodePoint )
+space ::= #x0009
+ | #x000A
+ | #x0020
+s ::= space+
+forbiddenCodePoint
+ ::= controlCodePoint
+ | surrogateCodePoint
+ | nonCharacterCodePoint
+controlCodePoint
+ ::= [#x0000-#x001F]
+ | [#x007F-#x009F]
+surrogateCodePoint
+ ::= [#xD800-#xDFFF]
nonCharacterCodePoint
-controlCodePoint ::= [#x0-#1F] | [#7F-#9F]
-surrogateCodePoint ::= [#xD800-#xDFFF]
-nonCharacterCodePoint ::= [#xFDD0-#xFDEF] | [#xFFFE-#xFFFF] | [#x1FFFE-#x1FFFF]
- | [#x2FFFE-#x2FFFF] | [#x3FFFE-#x3FFFF] | [#x4FFFE-#x4FFFF]
- | [#x5FFFE-#x5FFFF] | [#x6FFFE-#x6FFFF] | [#x7FFFE-#x7FFFF]
- | [#x8FFFE-#x8FFFF] | [#x9FFFE-#x9FFFF] | [#xAFFFE-#xAFFFF]
- | [#xBFFFE-#xBFFFF] | [#xCFFFE-#xCFFFF] | [#xDFFFE-#xDFFFF]
- | [#xEFFFE-#xEFFFF] | [#xFFFFE-#xFFFFF] | [#x10FFFE-#x10FFFF]
+ ::= [#xFDD0-#xFDEF]
+ | [#xFFFE-#xFFFF]
+ | [#x1FFFE-#x1FFFF]
+ | [#x2FFFE-#x2FFFF]
+ | [#x3FFFE-#x3FFFF]
+ | [#x4FFFE-#x4FFFF]
+ | [#x5FFFE-#x5FFFF]
+ | [#x6FFFE-#x6FFFF]
+ | [#x7FFFE-#x7FFFF]
+ | [#x8FFFE-#x8FFFF]
+ | [#x9FFFE-#x9FFFF]
+ | [#xAFFFE-#xAFFFF]
+ | [#xBFFFE-#xBFFFF]
+ | [#xCFFFE-#xCFFFF]
+ | [#xDFFFE-#xDFFFF]
+ | [#xEFFFE-#xEFFFF]
+ | [#xFFFFE-#xFFFFF]
+ | [#x10FFFE-#x10FFFF]
+eof ::= $
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- This file was generated on Mon Sep 24, 2012 10:35 (UTC+02) by REx v5.16 which is Copyright (c) 1979-2012 by Gunther Rademacher <grd@gmx.net> -->
-<!-- REx command line: microxml.ebnf -tree -xml -backtrack -->
+<!-- This file was generated on Thu Sep 27, 2012 11:24 (UTC+02) by REx v5.16 which is Copyright (c) 1979-2012 by Gunther Rademacher <grd@gmx.net> -->
+<!-- REx command line: microxml.ebnf -ll 2 -tree -xml -->
<g:grammar xmlns:g="http://www.w3.org/2001/03/XPath/grammar">
<g:production name="document">
<g:optional>
@@ -14,38 +14,36 @@
</g:zeroOrMore>
<g:ref queued="1" name="element"/>
<g:zeroOrMore>
- <g:choice ifnot="END" queued="1">
+ <g:choice ifnot="eof" queued="1">
<g:ref if="comment" queued="1" name="comment"/>
<g:ref default="" queued="1" name="s"/>
</g:choice>
</g:zeroOrMore>
+ <g:ref queued="1" name="eof"/>
</g:production>
<g:production queued="1" name="element">
- <g:choice LL1-conflict="&lt;" LL2-conflict="&lt;~name" LL3-conflict="&lt;~name~s" queued="1">
- <g:sequence if="&lt;~name~&gt;" queued="1+">
- <g:ref queued="1+" name="startTag"/>
+ <g:string queued="1">&lt;</g:string>
+ <g:ref name="name"/>
+ <g:ref name="attributeList"/>
+ <g:optional>
+ <g:ref if="s" queued="1" name="s"/>
+ </g:optional>
+ <g:choice>
+ <g:sequence if="&gt;" queued="1">
+ <g:string queued="1">&gt;</g:string>
<g:ref name="content"/>
<g:ref name="endTag"/>
</g:sequence>
- <g:ref default="" queued="1+" name="emptyElementTag"/>
+ <g:string default="" queued="1">/&gt;</g:string>
</g:choice>
</g:production>
- <g:production queued="1+" name="startTag">
- <g:string queued="1+">&lt;</g:string>
- <g:ref name="name"/>
- <g:ref name="attributeList"/>
- <g:zeroOrMore>
- <g:ref if="s" queued="1" name="s"/>
- </g:zeroOrMore>
- <g:string queued="1">&gt;</g:string>
- </g:production>
<g:production name="endTag">
<g:string>&lt;/</g:string>
<g:ref name="name"/>
- <g:zeroOrMore>
+ <g:optional>
<g:ref if="s" queued="1" name="s"/>
- </g:zeroOrMore>
- <g:string queued="1">&gt;</g:string>
+ </g:optional>
+ <g:string>&gt;</g:string>
</g:production>
<g:production name="content">
<g:zeroOrMore>
@@ -57,33 +55,22 @@
</g:choice>
</g:zeroOrMore>
</g:production>
- <g:production queued="1+" name="emptyElementTag">
- <g:string queued="1+">&lt;</g:string>
- <g:ref name="name"/>
- <g:ref name="attributeList"/>
- <g:zeroOrMore>
- <g:ref if="s" queued="1" name="s"/>
- </g:zeroOrMore>
- <g:string queued="1">/&gt;</g:string>
- </g:production>
<g:production name="attributeList">
- <g:zeroOrMore LL1-conflict="s" LL2-conflict="s~s" LL3-conflict="s~s~s">
- <g:oneOrMore if="s~attributeName s~s~attributeName">
- <g:ref if="s" queued="1+" name="s"/>
- </g:oneOrMore>
- <g:ref queued="1" name="attribute"/>
+ <g:zeroOrMore LL1-conflict="s">
+ <g:ref if="s~attributeName" queued="1+" name="s"/>
+ <g:ref name="attribute"/>
</g:zeroOrMore>
</g:production>
- <g:production queued="1" name="attribute">
- <g:ref queued="1" name="attributeName"/>
- <g:zeroOrMore>
+ <g:production name="attribute">
+ <g:ref name="attributeName"/>
+ <g:optional>
<g:ref if="s" queued="1" name="s"/>
- </g:zeroOrMore>
- <g:string queued="1">=</g:string>
- <g:zeroOrMore>
+ </g:optional>
+ <g:string>=</g:string>
+ <g:optional>
<g:ref if="s" queued="1" name="s"/>
- </g:zeroOrMore>
- <g:ref queued="1" name="attributeValue"/>
+ </g:optional>
+ <g:ref name="attributeValue"/>
</g:production>
<?TOKENS?>
<g:production name="byteOrderMark">
@@ -267,7 +254,7 @@
</g:production>
<g:production name="char">
<g:choice>
- <g:ref name="s"/>
+ <g:ref name="space"/>
<g:subtract>
<g:charClass>
<g:charCodeRange minValue="0" maxValue="10FFFF"/>
@@ -276,13 +263,18 @@
</g:subtract>
</g:choice>
</g:production>
- <g:production name="s">
+ <g:production name="space">
<g:charClass>
<g:charCode value="9"/>
<g:charCode value="A"/>
<g:charCode value="20"/>
</g:charClass>
</g:production>
+ <g:production name="s">
+ <g:oneOrMore>
+ <g:ref name="space"/>
+ </g:oneOrMore>
+ </g:production>
<g:production name="forbiddenCodePoint">
<g:choice>
<g:ref name="controlCodePoint"/>
@@ -292,12 +284,8 @@
</g:production>
<g:production name="controlCodePoint">
<g:charClass>
- <g:charCodeRange minValue="0" maxValue="1"/>
- <g:char>F</g:char>
- <g:charCode value="7"/>
- <g:charRange minChar="F" maxChar="#"/>
- <g:char>9</g:char>
- <g:char>F</g:char>
+ <g:charCodeRange minValue="0" maxValue="1F"/>
+ <g:charCodeRange minValue="7F" maxValue="9F"/>
</g:charClass>
</g:production>
<g:production name="surrogateCodePoint">
@@ -327,4 +315,7 @@
<g:charCodeRange minValue="10FFFE" maxValue="10FFFF"/>
</g:charClass>
</g:production>
+ <g:production name="eof">
+ <g:endOfFile/>
+ </g:production>
</g:grammar>
Oops, something went wrong.

0 comments on commit 291478f

Please sign in to comment.