ebnf 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YmExODQ4Njc3ZmYwMTI5YTk2MDg5N2M3M2UyZGViOTkzYzM5OTM3Yg==
5
- data.tar.gz: !binary |-
6
- ODljMTFmZDY1NWM5Njg5N2ZiMTBkNmEzODJjOGJhY2RkNTM5ZjQ3MA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZDJjNjlmYjZhZWQ5OGIwZTgwMjNlYzc0NWZlMzA3NDExYTI3N2M3YTJiNjFj
10
- MDAyOGQxMjUzYjkwNGM0NmQxZjdjMDVkNDU2MWE5MjE3OWEwZmRhN2ViYjQy
11
- ZTE4NDM1MGUxOTNhZGU0OTJjNzEzOTlkMzEzYjQ2OWJmODBjMTM=
12
- data.tar.gz: !binary |-
13
- OTk3MzAzMzY4MGU0NjBhYjM4YWNkNDJhNDEwYTM2YzM5NDZiZGM0ZjZjZDA0
14
- YTM4YTMyYzUyYmE0MjFkYTJmZjE2MDYyZjI2ZTAyMzI4NTMwNTI5ZThiOTcx
15
- ZGQzMTdkMjdlM2Y0NTFjNTI1YTM0YjMxNjlhZWYwZTQ3ODMxNTE=
2
+ SHA1:
3
+ metadata.gz: 3c3b6668384bfe503728e795abf4350ec4a327c9
4
+ data.tar.gz: d2b8ed718f483766f3e7756dd2feaac637d29dbe
5
+ SHA512:
6
+ metadata.gz: 0271fdc7808467c76a0c95a66982e6d97efdd9bcac52b5bcfde66fb1b763fab7a82eea344a98bd4fd81ef95de5a7865b88a2b912876ef69ed4814ba05cdbe635
7
+ data.tar.gz: 47e4b1314eb8068da0a4802d04206d47cfa2d52fe46b8b740cc00cd6187fea9b3e658441af3c2848d3b1a3bccfc614b31f95ffa3130f88cc42ade09aca0e86df
data/README.md CHANGED
@@ -24,7 +24,7 @@ Output rules and terminals as S-Expressions, Turtle or EBNF
24
24
  puts ebnf.to_ttl
25
25
  puts ebnf.to_ebnf
26
26
 
27
- Transform EBNF to BNF (generates `alt` or `seq` from `plus`, `star` or `opt`)
27
+ Transform EBNF to BNF (generates sub-productions using `alt` or `seq` from `plus`, `star` or `opt`)
28
28
 
29
29
  ebnf.make_bnf
30
30
 
@@ -81,63 +81,11 @@ to each `terminal` and `production`. A trivial parser loop can be described as f
81
81
  end
82
82
 
83
83
  ## EBNF Grammar
84
- The [EBNF][] variant used here is based on [W3C][] [EBNF][] as defined in the
84
+ The [EBNF][] variant used here is based on [W3C](http://w3.org/) [EBNF][] (see {file:etc/ebnf.ebnf EBNF grammar}) as defined in the
85
85
  [XML 1.0 recommendation](http://www.w3.org/TR/REC-xml/), with minor extensions.
86
86
 
87
- /* An EBNF grammar for EBNF */
88
- [1] ebnf ::= (declaration | rule)*
89
-
90
- [2] declaration ::= '@terminals' | '@pass'
91
-
92
- [3] rule ::= lhs '::=' expression
93
-
94
- [4] lhs ::= '[' (SYMBOL | '.')+ ']' SYMBOL
95
-
96
- [5] expression ::= alt
97
-
98
- [6] alt ::= seq ('|' seq)*
99
-
100
- [7] seq ::= diff+
101
-
102
- [8] diff ::= postfix ('-' postfix)*
103
-
104
- [9] postfix ::= primary ( [?*+] )?
105
-
106
- [10] primary ::= HEX
107
- | RANGE
108
- | ENUM
109
- | O_RANGE
110
- | O_ENUM
111
- | STRING1
112
- | STRING2
113
- | '(' expression ')'
114
-
115
- @terminals
116
-
117
- [11] SYMBOL ::= ([a-z] | [A-Z] | [0-9] | "_")+
118
-
119
- [12] HEX ::= '#x' ([0-9] | [a-f] | [A-F])+
120
-
121
- [13] RANGE ::= '[' CHAR '-' CHAR ']'
122
-
123
- [14] ENUM ::= '[' CHAR+ ']'
124
-
125
- [15] O_RANGE ::= '[^' CHAR '-' CHAR ']'
126
-
127
- [16] OENUM ::= '[^' CHAR+ ']'
128
-
129
- [17] STRING1 ::= '"' (CHAR - '"')* '"'
130
-
131
- [18] STRING2 ::= "'" (CHAR - "'")* "'"
132
-
133
- [19] CHAR ::= HEX
134
- | ('\\' [\\trn'"])
135
- | [^\t\r\n'"]
136
-
137
- @pass ::= (
138
- [#x20\t\r\n]
139
- |
140
- )+
87
+ ## Example parser
88
+ For an example parser built using this gem, see {file:examples/ebnf-parser/README EBNF Parser example}. This example creates a parser for the [EBNF][] grammar which generates the same Abstract Syntax Tree as the built-in parser in the gem.
141
89
 
142
90
  ## Acknowledgements
143
91
  Much of this work, particularly the generic parser, is inspired by work originally done by
@@ -148,7 +96,6 @@ The EBNF parser was inspired by Dan Connolly's
148
96
  [EBNF to BNF Notation-3 rules](http://www.w3.org/2000/10/swap/grammar/ebnf2bnf.n3),
149
97
  and [First Follow Notation-3 rules](http://www.w3.org/2000/10/swap/grammar/first_follow.n3).
150
98
 
151
-
152
99
  ## Documentation
153
100
  Full documentation available on [Rubydoc.info][EBNF doc].
154
101
 
@@ -177,6 +124,8 @@ Full documentation available on [Rubydoc.info][EBNF doc].
177
124
  This is free and unencumbered public domain software. For more information,
178
125
  see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
179
126
 
127
+ A copy of the [Turtle EBNF][] and derived parser files are included in the repository, which are not covered under the UNLICENSE. These files are covered via the [W3C Document License](http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231).
128
+
180
129
  [Ruby]: http://ruby-lang.org/
181
130
  [YARD]: http://yardoc.org/
182
131
  [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
@@ -186,4 +135,5 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
186
135
  [First/Follow]: http://en.wikipedia.org/wiki/LL_parser#Constructing_an_LL.281.29_parsing_table
187
136
  [LL(1)]: http://www.csd.uwo.ca/~moreno//CS447/Lectures/Syntax.html/node14.html
188
137
  [LL(1) Parser]: http://en.wikipedia.org/wiki/LL_parser
189
- [Tokenizer]: http://en.wikipedia.org/wiki/Lexical_analysis#Tokenizer
138
+ [Tokenizer]: http://en.wikipedia.org/wiki/Lexical_analysis#Tokenizer
139
+ [Turtle EBNF]: http://dvcs.w3.org/hg/rdf/file/default/rdf-turtle/turtle.bnf
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/bin/ebnf CHANGED
@@ -10,7 +10,6 @@ require "bundler/setup"
10
10
  require 'rubygems'
11
11
  require 'getoptlong'
12
12
  require 'ebnf'
13
- require 'sxp'
14
13
 
15
14
  def dump_tables(grammarFile, ebnf, output, options)
16
15
  ebnf.build_tables
@@ -29,6 +28,7 @@ def dump_tables(grammarFile, ebnf, output, options)
29
28
  ebnf.outputTable(output, 'TERMINALS', ebnf.terminals, 1)
30
29
  ebnf.outputTable(output, 'FIRST', ebnf.first, 1)
31
30
  ebnf.outputTable(output, 'FOLLOW', ebnf.follow, 1)
31
+ ebnf.outputTable(output, 'PASS', [ebnf.pass], 1) if ebnf.pass
32
32
  unless output == STDOUT
33
33
  output.puts "end"
34
34
  end
@@ -36,7 +36,7 @@ def dump_tables(grammarFile, ebnf, output, options)
36
36
  end
37
37
 
38
38
  options = {
39
- :format => :sxp,
39
+ :output_format => :sxp,
40
40
  :prefix => "ttl",
41
41
  :namespace => "http://www.w3.org/ns/formats/Turtle#",
42
42
  }
@@ -49,6 +49,7 @@ OPT_ARGS = [
49
49
  ["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as a JSON-LD document"],
50
50
  ["--ll1", GetoptLong::REQUIRED_ARGUMENT,"Generate First/Follow rules, argument is start symbol"],
51
51
  ["--format", "-f", GetoptLong::REQUIRED_ARGUMENT,"Specify output format one of ttl, sxp, or rb"],
52
+ ["--input-format", GetoptLong::REQUIRED_ARGUMENT,"Specify input format one of ebnf or sxp"],
52
53
  ["--mod-name", GetoptLong::REQUIRED_ARGUMENT,"Module name used when creating ruby tables"],
53
54
  ["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
54
55
  ["--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT,"Prefix to use when generating Turtle"],
@@ -79,7 +80,8 @@ opts.each do |opt, arg|
79
80
  when '--dbg' then options[:debug] = true
80
81
  when '--bnf' then options[:bnf] = true
81
82
  when '--evaluate' then input = arg
82
- when '--format' then options[:format] = arg.to_sym
83
+ when '--input-format' then options[:format] = arg.to_sym
84
+ when '--format' then options[:output_format] = arg.to_sym
83
85
  when '--ll1' then options[:ll1] = arg.to_sym
84
86
  when '--mod-name' then options[:mod_name] = arg
85
87
  when '--output' then out = File.open(arg, "w")
@@ -90,7 +92,7 @@ opts.each do |opt, arg|
90
92
  end
91
93
  end
92
94
 
93
- if options[:format] == :rb && !options[:ll1]
95
+ if options[:output_format] == :rb && !options[:ll1]
94
96
  STDERR.puts "outputing in .rb format requires -ll"
95
97
  exit(1)
96
98
  end
@@ -101,7 +103,7 @@ ebnf = EBNF.parse(input || STDIN, options)
101
103
  ebnf.make_bnf if options[:bnf] || options[:ll1]
102
104
  ebnf.first_follow(options[:ll1]) if options[:ll1]
103
105
 
104
- res = case options[:format]
106
+ res = case options[:output_format]
105
107
  when :sxp then ebnf.to_sxp
106
108
  when :ttl then ebnf.to_ttl(options[:prefix], options[:namespace])
107
109
  when :rb then dump_tables(ARGV[0], ebnf, out, options)
@@ -7,27 +7,26 @@
7
7
  @prefix ex: <http://example.org/> .
8
8
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9
9
 
10
- <http://rubygems.org/gems/rdf-turtle> a doap:Project, earl:TestSubject, earl:Software ;
11
- doap:name "RDF::Turtle" ;
12
- doap:homepage <http://ruby-rdf.github.com/rdf-turtle> ;
10
+ <http://rubygems.org/gems/ebnf> a doap:Project, earl:TestSubject, earl:Software ;
11
+ doap:name "ebnf" ;
12
+ doap:homepage <http://gkellogg.github.com/ebnf> ;
13
13
  doap:license <http://creativecommons.org/licenses/publicdomain/> ;
14
- doap:shortdesc "Turtle reader/writer for Ruby."@en ;
15
- doap:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
14
+ doap:shortdesc "EBNF parser and parser generator"@en ;
15
+ doap:description "EBNF is a Ruby parser for W3C EBNF and a parser generator for compliant LL(1) grammars."@en ;
16
16
  doap:created "2011-08-29"^^xsd:date ;
17
17
  doap:programming-language "Ruby" ;
18
- doap:implements <http://www.w3.org/TR/turtle/> ;
18
+ doap:implements <http://dbpedia.org/resource/Compiler-compiler> ;
19
19
  doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
20
20
  <http://dbpedia.org/resource/Ruby_(programming_language)> ;
21
- doap:download-page <http://rubygems.org/gems/rdf-turtle> ;
21
+ doap:download-page <http://rubygems.org/gems/ebnf> ;
22
22
  doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
23
- doap:bug-database <http://github.com/ruby-rdf/rdf-turtle/issues> ;
23
+ doap:bug-database <http://github.com/gkellogg/ebnf/issues> ;
24
24
  doap:blog <http://greggkellogg.net/> ;
25
25
  doap:developer <http://greggkellogg.net/foaf#me> ;
26
26
  doap:maintainer <http://greggkellogg.net/foaf#me> ;
27
27
  doap:documenter <http://greggkellogg.net/foaf#me> ;
28
28
  foaf:maker <http://greggkellogg.net/foaf#me> ;
29
- dc:title "RDF::Turtle" ;
30
- dc:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
29
+ dc:title "ebnf" ;
30
+ dc:description "EBNF is a Ruby parser for W3C EBNF and a parser generator for compliant LL(1) grammars."@en ;
31
31
  dc:date "2011-08-29"^^xsd:date ;
32
- dc:creator <http://greggkellogg.net/foaf#me> ;
33
- dc:isPartOf <http://rubygems.org/gems/rdf> .
32
+ dc:creator <http://greggkellogg.net/foaf#me> .
@@ -1,62 +1,66 @@
1
- /* An EBNF grammar for EBNF */
2
- [1] ebnf ::= (declaration | rule)*
1
+ /* An EBNF grammar for EBNF */
2
+ [1] ebnf ::= (declaration | rule)*
3
3
 
4
- [2] declaration ::= '@terminals' | pass
4
+ [2] declaration ::= '@terminals' | pass
5
5
 
6
- [3] rule ::= lhs '::=' expression
6
+ [3] rule ::= LHS expression
7
7
 
8
- [4] lhs ::= '[' SYMBOL ']' SYMBOL
8
+ # Use a terminal to match the identifier, rule name and assignment due to
9
+ # confusion between the identifier ENUM
9
10
 
10
- [5] expression ::= alt
11
+ [4] expression ::= alt
11
12
 
12
- [6] alt ::= seq ('|' seq)*
13
+ [5] alt ::= seq ('|' seq)*
13
14
 
14
- [7] seq ::= diff+
15
+ [6] seq ::= diff+
15
16
 
16
- [8] diff ::= postfix ('-' postfix)*
17
+ [7] diff ::= postfix ('-' postfix)?
17
18
 
18
- [9] postfix ::= primary ( [?*+] )?
19
+ [8] postfix ::= primary POSTFIX?
19
20
 
20
- [10] primary ::= HEX
21
- | RANGE
22
- | ENUM
23
- | O_RANGE
24
- | O_ENUM
25
- | STRING1
26
- | STRING2
27
- | '(' expression ')'
21
+ [9] primary ::= HEX
22
+ | SYMBOL
23
+ | RANGE
24
+ | ENUM
25
+ | O_RANGE
26
+ | O_ENUM
27
+ | STRING1
28
+ | STRING2
29
+ | '(' expression ')'
28
30
 
29
- [11] pass ::= '@pass'
30
- (
31
- [#x20\t\r\n]
32
- | ( '#' | '//' ) [^\r\n]*
33
- | ('/*' ([^*] | '*' [^/])* '*/')
34
- )+
31
+ [10] pass ::= '@pass' expression
35
32
 
36
- @terminals
33
+ @terminals
37
34
 
38
- [12] SYMBOL ::= ([a-z] | [A-Z] | [0-9] | "_" | ".")+
35
+ [11] LHS ::= ENUM SYMBOL "::="
39
36
 
40
- [13] HEX ::= '#x' ([0-9] | [a-f] | [A-F])+
37
+ [12] SYMBOL ::= ([a-z] | [A-Z] | [0-9] | "_" | ".")+
41
38
 
42
- [14] RANGE ::= '[' CHAR '-' CHAR ']'
39
+ [13] HEX ::= '#x' ([0-9]|[a-f]|[A-F]) ([0-9]|[a-f]|[A-F])
43
40
 
44
- [15] ENUM ::= '[' CHAR+ ']'
41
+ [14] RANGE ::= '[' CHAR '-' CHAR ']'
45
42
 
46
- [16] O_RANGE ::= '[^' CHAR '-' CHAR ']'
43
+ [15] ENUM ::= '[' CHAR+ ']'
47
44
 
48
- [17] O_ENUM ::= '[^' CHAR+ ']'
45
+ [16] O_RANGE ::= '[^' CHAR '-' CHAR ']'
49
46
 
50
- [18] STRING1 ::= '"' (CHAR - '"')* '"'
47
+ [17] O_ENUM ::= '[^' CHAR+ ']'
51
48
 
52
- [19] STRING2 ::= "'" (CHAR - "'")* "'"
49
+ [18] STRING1 ::= '"' (CHAR | [\t\'\[\]\(\)\-])* '"'
53
50
 
54
- [20] CHAR ::= HEX
55
- | ('\\' [\\trn'"])
56
- | [^\t\r\n'"]
51
+ [19] STRING2 ::= "'" (CHAR | [\t\"\[\]\(\)\-])* "'"
57
52
 
58
- @pass ::= (
59
- [#x20\t\r\n]
60
- #| ( '#' | '//' ) [^\r\n]*
61
- #| '/*' (( '*' [^/] )? | [^*] )* '*/'
62
- )+
53
+ [20] CHAR ::= HEX
54
+ | ('\\' [\\trn\'\"\[\]\(\)\-])
55
+ | [^\t\r\n\'\"\[\]\(\)\-]
56
+
57
+ # Should be able to do this inline, but not until terminal regular expressions are created automatically
58
+ [21] POSTFIX ::= [?*+]
59
+
60
+ [22] PASS ::= ( [#x20\t\r\n]
61
+ | ( '#' | '//' ) [^\r\n]*
62
+ | '/*' (( '*' [^/] )? | [^*] )* '*/'
63
+ )+
64
+
65
+ # Should be able to do this inline, but not until terminal regular expressions are created automatically
66
+ @pass PASS
@@ -1,247 +1,164 @@
1
-
2
- (
1
+ (
3
2
  (rule _empty "0" (first _eps) (seq))
3
+ (pass (seq PASS))
4
4
  (rule ebnf "1"
5
5
  (start #t)
6
- (first "@pass" "@terminals" "[" _eps)
6
+ (first "@pass" "@terminals" LHS _eps)
7
7
  (follow _eof)
8
8
  (alt _empty _ebnf_2))
9
9
  (rule _ebnf_1 "1.1"
10
- (first "@pass" "@terminals" "[")
11
- (follow "@pass" "@terminals" "[" _eof)
10
+ (first "@pass" "@terminals" LHS)
11
+ (follow "@pass" "@terminals" LHS _eof)
12
12
  (alt declaration rule))
13
- (rule _ebnf_2 "1.2" (first "@pass" "@terminals" "[") (follow _eof) (seq _ebnf_1 ebnf))
14
- (rule _ebnf_3 "1.3" (first "@pass" "@terminals" "[" _eps) (follow _eof) (seq ebnf))
13
+ (rule _ebnf_2 "1.2" (first "@pass" "@terminals" LHS) (follow _eof) (seq _ebnf_1 ebnf))
14
+ (rule _ebnf_3 "1.3" (first "@pass" "@terminals" LHS _eps) (follow _eof) (seq ebnf))
15
15
  (rule declaration "2"
16
16
  (first "@pass" "@terminals")
17
- (follow "@pass" "@terminals" "[" _eof)
17
+ (follow "@pass" "@terminals" LHS _eof)
18
18
  (alt "@terminals" pass))
19
- (rule rule "3"
20
- (first "[")
21
- (follow "@pass" "@terminals" "[" _eof)
22
- (seq lhs "::=" expression))
19
+ (rule rule "3" (first LHS) (follow "@pass" "@terminals" LHS _eof) (seq LHS expression))
23
20
  (rule _rule_1 "3.1"
24
- (first "::=")
25
- (follow "@pass" "@terminals" "[" _eof)
26
- (seq "::=" expression))
27
- (rule _rule_2 "3.2"
28
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
29
- (follow "@pass" "@terminals" "[" _eof)
21
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
22
+ (follow "@pass" "@terminals" LHS _eof)
30
23
  (seq expression))
31
- (rule lhs "4" (first "[") (follow "::=") (seq "[" SYMBOL "]" SYMBOL))
32
- (rule _lhs_1 "4.1" (first SYMBOL) (follow "::=") (seq SYMBOL "]" SYMBOL))
33
- (rule _lhs_2 "4.2" (first "]") (follow "::=") (seq "]" SYMBOL))
34
- (rule _lhs_3 "4.3" (first SYMBOL) (follow "::=") (seq SYMBOL))
35
- (rule expression "5"
36
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
37
- (follow ")" "@pass" "@terminals" "[" _eof)
24
+ (rule expression "4"
25
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
26
+ (follow ")" "@pass" "@terminals" LHS _eof)
38
27
  (seq alt))
39
- (rule alt "6"
40
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
41
- (follow ")" "@pass" "@terminals" "[" _eof)
28
+ (rule alt "5"
29
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
30
+ (follow ")" "@pass" "@terminals" LHS _eof)
42
31
  (seq seq _alt_1))
43
- (rule _alt_1 "6.1"
32
+ (rule _alt_1 "5.1"
44
33
  (first _eps "|")
45
- (follow ")" "@pass" "@terminals" "[" _eof)
34
+ (follow ")" "@pass" "@terminals" LHS _eof)
46
35
  (alt _empty _alt_3))
47
- (rule _alt_2 "6.2"
36
+ (rule _alt_2 "5.2"
48
37
  (first "|")
49
- (follow ")" "@pass" "@terminals" "[" _eof "|")
38
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
50
39
  (seq "|" seq))
51
- (rule _alt_3 "6.3"
40
+ (rule _alt_3 "5.3"
52
41
  (first "|")
53
- (follow ")" "@pass" "@terminals" "[" _eof)
42
+ (follow ")" "@pass" "@terminals" LHS _eof)
54
43
  (seq _alt_2 _alt_1))
55
- (rule _alt_4 "6.4"
44
+ (rule _alt_4 "5.4"
56
45
  (first _eps "|")
57
- (follow ")" "@pass" "@terminals" "[" _eof)
46
+ (follow ")" "@pass" "@terminals" LHS _eof)
58
47
  (seq _alt_1))
59
- (rule _alt_5 "6.5"
48
+ (rule _alt_5 "5.5"
60
49
  (first _eps "|")
61
- (follow ")" "@pass" "@terminals" "[" _eof)
50
+ (follow ")" "@pass" "@terminals" LHS _eof)
62
51
  (seq _alt_1))
63
- (rule _alt_6 "6.6"
64
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
65
- (follow ")" "@pass" "@terminals" "[" _eof "|")
52
+ (rule _alt_6 "5.6"
53
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
54
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
66
55
  (seq seq))
67
- (rule seq "7"
68
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
69
- (follow ")" "@pass" "@terminals" "[" _eof "|")
56
+ (rule seq "6"
57
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
58
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
70
59
  (seq diff _seq_1))
71
- (rule _seq_1 "7.1"
72
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 _eps)
73
- (follow ")" "@pass" "@terminals" "[" _eof "|")
60
+ (rule _seq_1 "6.1"
61
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL _eps)
62
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
74
63
  (alt _empty _seq_2))
75
- (rule _seq_2 "7.2"
76
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
77
- (follow ")" "@pass" "@terminals" "[" _eof "|")
64
+ (rule _seq_2 "6.2"
65
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
66
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
78
67
  (seq diff _seq_1))
79
- (rule _seq_3 "7.3"
80
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 _eps)
81
- (follow ")" "@pass" "@terminals" "[" _eof "|")
68
+ (rule _seq_3 "6.3"
69
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL _eps)
70
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
82
71
  (seq _seq_1))
83
- (rule _seq_4 "7.4"
84
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 _eps)
85
- (follow ")" "@pass" "@terminals" "[" _eof "|")
72
+ (rule _seq_4 "6.4"
73
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL _eps)
74
+ (follow ")" "@pass" "@terminals" LHS _eof "|")
86
75
  (seq _seq_1))
87
- (rule diff "8"
88
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
89
- (follow
90
- "(" ")" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
76
+ (rule diff "7"
77
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
78
+ (follow "(" ")" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
79
+ STRING1 STRING2 SYMBOL _eof "|" )
91
80
  (seq postfix _diff_1))
92
- (rule _diff_1 "8.1"
81
+ (rule _diff_1 "7.1"
93
82
  (first "-" _eps)
94
- (follow
95
- "(" ")" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
96
- (alt _empty _diff_3))
97
- (rule _diff_2 "8.2"
83
+ (follow "(" ")" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
84
+ STRING1 STRING2 SYMBOL _eof "|" )
85
+ (alt _empty _diff_2))
86
+ (rule _diff_2 "7.2"
98
87
  (first "-")
99
- (follow
100
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
88
+ (follow "(" ")" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
89
+ STRING1 STRING2 SYMBOL _eof "|" )
101
90
  (seq "-" postfix))
102
- (rule _diff_3 "8.3"
103
- (first "-")
104
- (follow
105
- "(" ")" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
106
- (seq _diff_2 _diff_1))
107
- (rule _diff_4 "8.4"
108
- (first "-" _eps)
109
- (follow
110
- "(" ")" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
111
- (seq _diff_1))
112
- (rule _diff_5 "8.5"
91
+ (rule _diff_3 "7.3"
113
92
  (first "-" _eps)
114
- (follow
115
- "(" ")" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
93
+ (follow "(" ")" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
94
+ STRING1 STRING2 SYMBOL _eof "|" )
116
95
  (seq _diff_1))
117
- (rule _diff_6 "8.6"
118
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
119
- (follow
120
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
96
+ (rule _diff_4 "7.4"
97
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
98
+ (follow "(" ")" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
99
+ STRING1 STRING2 SYMBOL _eof "|" )
121
100
  (seq postfix))
122
- (rule postfix "9"
123
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
124
- (follow
125
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
101
+ (rule postfix "8"
102
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
103
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
104
+ STRING1 STRING2 SYMBOL _eof "|" )
126
105
  (seq primary _postfix_1))
127
- (rule _postfix_1 "9.1"
128
- (first _eps _postfix_2)
129
- (follow
130
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
131
- (alt _empty _postfix_2))
132
- (terminal _postfix_2 "9.2" (range "?*+"))
133
- (rule _postfix_3 "9.3"
134
- (first _eps _postfix_2)
135
- (follow
136
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof "|" )
106
+ (rule _postfix_1 "8.1"
107
+ (first POSTFIX _eps)
108
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
109
+ STRING1 STRING2 SYMBOL _eof "|" )
110
+ (alt _empty POSTFIX))
111
+ (rule _postfix_2 "8.2"
112
+ (first POSTFIX _eps)
113
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE RANGE
114
+ STRING1 STRING2 SYMBOL _eof "|" )
137
115
  (seq _postfix_1))
138
- (rule primary "10"
139
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
140
- (follow
141
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof _postfix_2 "|" )
142
- (alt HEX RANGE ENUM O_RANGE O_ENUM STRING1 STRING2 _primary_1))
143
- (rule _primary_1 "10.1"
116
+ (rule primary "9"
117
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
118
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE POSTFIX
119
+ RANGE STRING1 STRING2 SYMBOL _eof "|" )
120
+ (alt HEX SYMBOL RANGE ENUM O_RANGE O_ENUM STRING1 STRING2 _primary_1))
121
+ (rule _primary_1 "9.1"
144
122
  (first "(")
145
- (follow
146
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof _postfix_2 "|" )
123
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE POSTFIX
124
+ RANGE STRING1 STRING2 SYMBOL _eof "|" )
147
125
  (seq "(" expression ")"))
148
- (rule _primary_2 "10.2"
149
- (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2)
150
- (follow
151
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof _postfix_2 "|" )
126
+ (rule _primary_2 "9.2"
127
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
128
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE POSTFIX
129
+ RANGE STRING1 STRING2 SYMBOL _eof "|" )
152
130
  (seq expression ")"))
153
- (rule _primary_3 "10.3"
131
+ (rule _primary_3 "9.3"
154
132
  (first ")")
155
- (follow
156
- "(" ")" "-" "@pass" "@terminals" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 "[" _eof _postfix_2 "|" )
133
+ (follow "(" ")" "-" "@pass" "@terminals" ENUM HEX LHS O_ENUM O_RANGE POSTFIX
134
+ RANGE STRING1 STRING2 SYMBOL _eof "|" )
157
135
  (seq ")"))
158
- (rule pass "11"
136
+ (rule pass "10"
159
137
  (first "@pass")
160
- (follow "@pass" "@terminals" "[" _eof)
161
- (seq "@pass" _pass_1))
162
- (terminal _pass_10 "11.10" (range "^\\r\\n"))
163
- (rule _pass_1 "11.1"
164
- (first "#" "/*" "//" _pass_5)
165
- (follow "@pass" "@terminals" "[" _eof)
166
- (seq _pass_2 _pass_3))
167
- (rule _pass_11 "11.11"
168
- (first _pass_10)
169
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
170
- (seq _pass_10 _pass_9))
171
- (rule _pass_12 "11.12" (first "*" _eps _pass_15) (follow "*/") (alt _empty _pass_14))
172
- (rule _pass_13 "11.13"
173
- (first "*" _pass_15)
174
- (follow "*" "*/" _pass_15)
175
- (alt _pass_15 _pass_16))
176
- (rule _pass_14 "11.14" (first "*" _pass_15) (follow "*/") (seq _pass_13 _pass_12))
177
- (terminal _pass_15 "11.15" (range "^*"))
178
- (rule _pass_16 "11.16" (first "*") (follow "*" "*/" _pass_15) (seq "*" _pass_17))
179
- (terminal _pass_17 "11.17" (range "^/"))
180
- (rule _pass_18 "11.18"
181
- (first "#" "/*" "//" _pass_5)
182
- (follow "@pass" "@terminals" "[" _eof)
183
- (seq _pass_1))
184
- (rule _pass_19 "11.19"
185
- (first "#" "/*" "//" _eps _pass_5)
186
- (follow "@pass" "@terminals" "[" _eof)
187
- (seq _pass_3))
188
- (rule _pass_20 "11.20"
189
- (first "#" "/*" "//" _eps _pass_5)
190
- (follow "@pass" "@terminals" "[" _eof)
191
- (seq _pass_3))
192
- (rule _pass_2 "11.2"
193
- (first "#" "/*" "//" _pass_5)
194
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
195
- (alt _pass_5 _pass_6 _pass_7))
196
- (rule _pass_21 "11.21"
197
- (first _eps _pass_10)
198
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
199
- (seq _pass_9))
200
- (rule _pass_22 "11.22"
201
- (first _eps _pass_10)
202
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
203
- (seq _pass_9))
204
- (rule _pass_23 "11.23"
205
- (first "*" "*/" _pass_15)
206
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
207
- (seq _pass_12 "*/"))
208
- (rule _pass_24 "11.24" (first "*" _eps _pass_15) (follow "*/") (seq _pass_12))
209
- (rule _pass_25 "11.25" (first _pass_17) (follow "*" "*/" _pass_15) (seq _pass_17))
210
- (rule _pass_26 "11.26"
211
- (first "*/")
212
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
213
- (seq "*/"))
214
- (rule _pass_3 "11.3"
215
- (first "#" "/*" "//" _eps _pass_5)
216
- (follow "@pass" "@terminals" "[" _eof)
217
- (alt _empty _pass_4))
218
- (rule _pass_4 "11.4"
219
- (first "#" "/*" "//" _pass_5)
220
- (follow "@pass" "@terminals" "[" _eof)
221
- (seq _pass_2 _pass_3))
222
- (terminal _pass_5 "11.5" (range "#x20\\t\\r\\n"))
223
- (rule _pass_6 "11.6"
224
- (first "#" "//")
225
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
226
- (seq _pass_8 _pass_9))
227
- (rule _pass_7 "11.7"
228
- (first "/*")
229
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
230
- (seq "/*" _pass_12 "*/"))
231
- (rule _pass_8 "11.8"
232
- (first "#" "//")
233
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_10 _pass_5)
234
- (alt "#" "//"))
235
- (rule _pass_9 "11.9"
236
- (first _eps _pass_10)
237
- (follow "#" "/*" "//" "@pass" "@terminals" "[" _eof _pass_5)
238
- (alt _empty _pass_11))
138
+ (follow "@pass" "@terminals" LHS _eof)
139
+ (seq "@pass" expression))
140
+ (rule _pass_1 "10.1"
141
+ (first "(" ENUM HEX O_ENUM O_RANGE RANGE STRING1 STRING2 SYMBOL)
142
+ (follow "@pass" "@terminals" LHS _eof)
143
+ (seq expression))
144
+ (terminal LHS "11" (seq ENUM SYMBOL "::="))
239
145
  (terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") "_" ".")))
240
- (terminal HEX "13" (seq "#x" (plus (alt (range "0-9") (range "a-f") (range "A-F")))))
146
+ (terminal HEX "13"
147
+ (seq "#x"
148
+ (alt (range "0-9") (range "a-f") (range "A-F"))
149
+ (alt (range "0-9") (range "a-f") (range "A-F"))) )
241
150
  (terminal RANGE "14" (seq "[" CHAR "-" CHAR "]"))
242
151
  (terminal ENUM "15" (seq "[" (plus CHAR) "]"))
243
152
  (terminal O_RANGE "16" (seq "[^" CHAR "-" CHAR "]"))
244
153
  (terminal O_ENUM "17" (seq "[^" (plus CHAR) "]"))
245
- (terminal STRING1 "18" (seq "\"" (star (diff CHAR "\"")) "\""))
246
- (terminal STRING2 "19" (seq "'" (star (diff CHAR "'")) "'"))
247
- (terminal CHAR "20" (alt HEX (seq "\\\\" (range "\\\\trn'\"")) (range "^\\t\\r\\n'\""))))
154
+ (terminal STRING1 "18" (seq "\"" (star (alt CHAR (range "\t'[]()-"))) "\""))
155
+ (terminal STRING2 "19" (seq "'" (star (alt CHAR (range "\t\"[]()-"))) "'"))
156
+ (terminal CHAR "20"
157
+ (alt HEX (seq "\\" (range "\\trn'\"[]()-")) (range "^\t\r\n'\"[]()-")))
158
+ (terminal POSTFIX "21" (range "?*+"))
159
+ (terminal PASS "22"
160
+ (plus
161
+ (alt
162
+ (range "#x20\t\r\n")
163
+ (seq (alt "#" "//") (star (range "^\r\n")))
164
+ (seq "/*" (star (alt (opt (seq "*" (range "^/"))) (range "^*"))) "*/")) )) )