RPA Toolkit
Added modified version of the XML bnf.
[rpatk.git] / tests / datapatterns / xml2.rpa
1 #!emitall
2 #!emit STag
3 #!emit ETag
4 #!emit Attribute
5 #!abort ETag
6
7 # BNF productsions from the XML spcification.
8
9 Char            ::= [#x9] | [#xA] | [#xD] | [#x20-#xD7FF] | 
10                     [#xE000-#xFFFD] | [#x10000-#x10FFFF]                                                                                # [2]
11 S               ::= ( [#x20] | [#x9] | [#xD] | [#xA] )*                                                                                 # [3]
12 NameStartChar   ::= [:] | [A-Z] | [_] | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
13                     [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
14                     [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | 
15                     [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]                                                                                 # [4]
16 NameChar        ::= <NameStartChar> | [\-\.]|[0-9]|[#xB7]|[#x0300-#x036F]|[#x203F-#x2040]       # [4a]
17 Name            ::= <NameStartChar><NameChar>*                                                                                          # [5]
18 Names           ::= <Name>([#x20]<Name>)*                                                                                                       # [6]
19 Nmtoken         ::= <NameChar>+                                                                                                                         # [7]
20 Nmtokens        ::= <Nmtoken>([#x20]<Nmtoken>)*                                                                                         # [8]
21
22 # Literals
23 EntityValue     ::= ( '"' ( ^[%&"] | <PEReference> | <Reference> )* '"' ) | 
24                     ( "'" ( ^[%&'] | <PEReference> | <Reference> )* "'" )                                               # [9]
25 AttValue        ::= '"' (^[<&"] | <Reference>)* '"' |  "'" (^[<&'] | <Reference>)* "'"          # [10]
26 SystemLiteral   ::= ('"' ^["]* '"') | ("'" ^[']* "'")                                                                   # [11]
27 PubidLiteral    ::= ('"' <PubidChar>* '"' ) | ("'" (<PubidChar> - "'")* "'")                    # [12]
28 PubidChar       ::= [#x20] | [#xD] | [#xA] | [a-zA-Z0-9] | '-' | '#' | ['()+,./::=?;!*@$_%]     # [13]
29
30 # Character Data
31 CharData        ::= ^[<&]
32 Comment         ::= '<!--' ((<Char> - '-') | ('-' (<Char> - '-')))* '-->'                                       # [15]
33
34 # Processing Instructions
35 PI              ::= '<?' <PITarget> (<S> ((<Char> - '?>')*))? '?>'                                                              # [16]
36 PITarget        ::= <Name> - [Xx][Mm][Ll]                                                                                                       # [17]
37
38
39 # CDATA Section
40 CDSect          ::= <CDStart> <CData> <CDEnd>                                                                                           # [18]
41 CDStart         ::= '<![CDATA['                                                                                                                         # [19]
42 CData           ::= (<Char> - ']]>')*                                                                                                           # [20]
43 CDEnd           ::= ']]>'                                                                                                                                       # [21]
44
45 # Prolog
46 XMLDecl         ::= '<?xml' <VersionInfo> <EncodingDecl>? <SDDecl>? <S>? '?>'                           # [23]
47 VersionInfo     ::= <S> 'version' <Eq> ("'" <VersionNum> "'" | '"' <VersionNum> '"')            # [24]
48 Eq              ::= <S>? '=' <S>?                                                                                                                               # [25]
49 VersionNum      ::= '1.' [0-9]+                                                                                                                         # [26]
50 Misc            ::= <Comment> | <PI> | <S>                                                                                                      # [27]  
51 doctypedecl     ::= '<!DOCTYPE'<S><Name>(<S><ExternalID>)?<S>?('['<intSubset>']'<S>?)?'>'       # [28]
52 DeclSep         ::= <PEReference> | <S>                                                                                                         # [28a]
53 intSubset       ::= ( <markupdecl> | <DeclSep> )*                                                                                       # [28b]
54
55 markupdecl      ::= <elementdecl> | <AttlistDecl> | 
56                     <EntityDecl> | <NotationDecl> | <PI> | <Comment>                                                    # [29]
57 prolog          ::= (<XMLDecl> | <doctypedecl>)<Misc>* (<doctypedecl> <Misc>*)?                         # [22]
58
59 # External Subset
60 extSubset       ::= <TextDecl>? <extSubsetDecl>                                                                                         # [30]
61 extSubsetDecl   ::= (<markupdecl> | <conditionalSect> | <DeclSep>)*                                             # [31]
62 SDDecl          ::= <S> 'standalone' <Eq>(("'" ('yes' | 'no') "'") |
63                     ('"' ('yes' | 'no') '"'))                                                                                                   # [32]
64
65 #Start-tag
66 STag            ::= '<' <Name> (<S><Attribute>)* <S>? '>'                                                                       # [40]
67 Attribute       ::= <Name> <Eq> <AttValue>                                                                                                      # [41]
68 ETag            ::= '</' <Name> <S>? '>'                                                                                                        # [42]
69 content         ::= <CharData>?((<element>|<Reference>|<CDSect>|<PI>|
70                     <Comment>)<CharData>?)*                                                                                                             # [43]
71 EmptyElemTag    ::= '<' <Name> (<S><Attribute>)* <S>? '/>'                                                              # [44]
72
73 # Element
74 element         ::= <EmptyElemTag> | (<STag> <content>* (<ETag>))                                                       # [39]
75
76 elementdecl     ::= '<!ELEMENT'<S><Name><S><contentspec><S>? '>'                                                        # [45]
77 contentspec     ::= 'EMPTY' | 'ANY' | <Mixed> | <children>                                                                      # [46]
78 children        ::= (<choice> | <seq>) ('?' | '*' | '+')?                                                                       # [47]
79 cp              ::= (<Name>|<choice>|<seq>) ('?' | '*' | '+')?                                                                  # [48]
80 choice          ::= '(' <S>? <cp> (<S>? '|' <S>? <cp>)+ <S>? ')'                                                        # [49]
81 seq             ::= '(' <S>? <cp> (<S>? ',' <S>? <cp>)* <S>? ')'                                                                # [50]
82 Mixed           ::= '(' <S>? '#PCDATA' (<S>? '|' <S>? <Name>)* <S>? ')*'|
83                     '(' <S>? '#PCDATA' <S>? ')'                                                                                                 # [51]
84
85 AttlistDecl     ::= '<!ATTLIST' <S>  <Name> <AttDef>* <S>? '>'                                                          # [52]
86 AttDef          ::= <S> <Name> <S> <AttType> <S> <DefaultDecl>                                                          # [53]
87 AttType         ::= <StringType> | <TokenizedType> | <EnumeratedType>                                           # [54]
88 StringType      ::= 'CDATA'                                                                                                                     # [55]
89 TokenizedType   ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' 
90                                 | 'NMTOKEN' | 'NMTOKENS'                                                                                                # [56]
91 EnumeratedType  ::= <NotationType> | <Enumeration>                                                                              # [57]
92 NotationType    ::= 'NOTATION' <S> '(' <S>? <Name>(<S>? '|' <S>?<Name>)*<S>? ')'                # [58]
93 Enumeration     ::= '(' <S>? <Nmtoken> (<S>? '|' <S>? <Nmtoken>)* <S>? ')'                                      # [59]
94 DefaultDecl     ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' <S>)? <AttValue>)                                     # [60]
95 conditionalSect ::= <includeSect> | <ignoreSect>                                                                                # [61]
96 includeSect     ::= '<![' <S>? 'INCLUDE' <S>? '[' <extSubsetDecl> ']]>'                                         # [62]
97 ignoreSect      ::= '<![' <S>? 'IGNORE' <S>? '[' <ignoreSectContents>* ']]>'                            # [63]
98 ignoreSectContents ::= <Ignore>? ('<![' <ignoreSectContents> ']]>' <Ignore>? )*                 # [64]
99 Ignore          ::= (<Char> - ('<![' | ']]>'))+
100
101
102 CharRef         ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'                                                            # [66]
103 Reference       ::= <EntityRef> | <CharRef>                                                                                                     # [67]
104 EntityRef       ::= '&' <Name> ';'                                                                                                                      # [68]
105 PEReference     ::= '%' <Name> ';'                                                                                                                      # [69]
106 EntityDecl      ::= <GEDecl> | <PEDecl>                                                                                                         # [70]
107 GEDecl          ::= '<!ENTITY' <S> <Name> <S> <EntityDef> <S>? '>'                                                      # [71]
108 PEDecl          ::= '<!ENTITY' <S> '%' <S> <Name> <S> <PEDef> <S>? '>'                                          # [72]
109 EntityDef       ::= <EntityValue> | (<ExternalID> <NDataDecl>?)                                                 # [73]
110 PEDef           ::= <EntityValue> | <ExternalID>                                                                                        # [74]
111 ExternalID      ::= 'SYSTEM' <S>  <SystemLiteral> | 
112                     'PUBLIC' <S> <PubidLiteral> <S> <SystemLiteral>                                                             # [75]
113 NDataDecl       ::= <S> 'NDATA' <S> <Name>                                                                                              # [76]
114 TextDecl        ::= '<?xml' <VersionInfo>? <EncodingDecl>  <S>? '?>'                                            # [77]
115 extParsedEnt    ::= <TextDecl>? <content>                                                                               # [78]
116 EncName         ::= [A-Za-z] ([A-Za-z0-9._] | '-')*                                                             # [81]
117 NotationDecl    ::= '<!NOTATION' <S> <Name> <S> (<ExternalID> | <PublicID>)<S>? '>'     # [82]
118 PublicID        ::= 'PUBLIC' <S> <PubidLiteral>                                                 # [83]
119 EncodingDecl    ::= <S> 'encoding' <Eq> ('"' <EncName> '"' | "'" <EncName> "'" )                # [80]
120
121 document        ::= <prolog>? <element> <Misc>*                                                                                         # [1]
122 exec            ::= <document>