ebnf 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/VERSION +1 -1
- data/etc/ebnf.ll1.sxp +243 -1032
- data/etc/ebnf.rb +344 -136
- data/etc/ebnf.sxp +23 -106
- data/etc/turtle.ll1.sxp +410 -1659
- data/etc/turtle.sxp +95 -410
- data/lib/ebnf/base.rb +1 -6
- data/lib/ebnf/ll1/lexer.rb +7 -7
- data/lib/ebnf/ll1/parser.rb +0 -1
- data/lib/ebnf/rule.rb +12 -10
- metadata +5 -20
data/lib/ebnf/base.rb
CHANGED
@@ -158,12 +158,7 @@ module EBNF
|
|
158
158
|
# Write out parsed syntax string as an S-Expression
|
159
159
|
# @return [String]
|
160
160
|
def to_sxp
|
161
|
-
|
162
|
-
require 'sxp'
|
163
|
-
SXP::Generator.string(ast.sort)
|
164
|
-
rescue LoadError
|
165
|
-
ast.sort_by{|r| r.num.to_f}.to_sxp
|
166
|
-
end
|
161
|
+
SXP::Generator.string(ast.sort_by{|r| r.id.to_f}.map(&:for_sxp))
|
167
162
|
end
|
168
163
|
def to_s; to_sxp; end
|
169
164
|
|
data/lib/ebnf/ll1/lexer.rb
CHANGED
@@ -42,15 +42,15 @@ module EBNF::LL1
|
|
42
42
|
'\\"' => '"', # \u0022 (quotation mark, double quote mark)
|
43
43
|
"\\'" => '\'', # \u0027 (apostrophe-quote, single quote mark)
|
44
44
|
'\\\\' => '\\' # \u005C (backslash)
|
45
|
-
}
|
46
|
-
ESCAPE_CHAR4 = /\\u(?:[0-9A-Fa-f]{4,4})
|
47
|
-
ESCAPE_CHAR8 = /\\U(?:[0-9A-Fa-f]{8,8})
|
45
|
+
}.freeze
|
46
|
+
ESCAPE_CHAR4 = /\\u(?:[0-9A-Fa-f]{4,4})/.freeze # \uXXXX
|
47
|
+
ESCAPE_CHAR8 = /\\U(?:[0-9A-Fa-f]{8,8})/.freeze # \UXXXXXXXX
|
48
48
|
ECHAR = /\\./ # More liberal unescaping
|
49
|
-
UCHAR = /#{ESCAPE_CHAR4}|#{ESCAPE_CHAR8}
|
50
|
-
COMMENT =
|
51
|
-
WS = / |\t|\r|\n/m
|
49
|
+
UCHAR = /#{ESCAPE_CHAR4}|#{ESCAPE_CHAR8}/.freeze
|
50
|
+
COMMENT = /#.*/.freeze
|
51
|
+
WS = / |\t|\r|\n/m.freeze
|
52
52
|
|
53
|
-
ML_START = /\'\'\'|\"\"\"
|
53
|
+
ML_START = /\'\'\'|\"\"\"/.freeze # Beginning of terminals that may span lines
|
54
54
|
|
55
55
|
##
|
56
56
|
# @!attribute whitespace
|
data/lib/ebnf/ll1/parser.rb
CHANGED
data/lib/ebnf/rule.rb
CHANGED
@@ -82,22 +82,24 @@ module EBNF
|
|
82
82
|
}.merge(options))
|
83
83
|
end
|
84
84
|
|
85
|
-
#
|
86
|
-
# @return [
|
87
|
-
def
|
85
|
+
# Return representation for building S-Expressions
|
86
|
+
# @return [Array]
|
87
|
+
def for_sxp
|
88
88
|
elements = [kind, sym, id]
|
89
89
|
elements << [:start, true] if start
|
90
90
|
elements << first.sort_by(&:to_s).unshift(:first) if first
|
91
91
|
elements << follow.sort_by(&:to_s).unshift(:follow) if follow
|
92
92
|
elements << expr
|
93
|
-
|
94
|
-
require 'sxp'
|
95
|
-
SXP::Generator.string(elements)
|
96
|
-
rescue LoadError
|
97
|
-
elements.to_sxp
|
98
|
-
end
|
93
|
+
elements
|
99
94
|
end
|
100
|
-
|
95
|
+
|
96
|
+
# Return SXP representation of this rule
|
97
|
+
# @return [String]
|
98
|
+
def to_sxp
|
99
|
+
for_sxp.to_sxp
|
100
|
+
end
|
101
|
+
|
102
|
+
alias_method :to_s, :to_sxp
|
101
103
|
|
102
104
|
# Serializes this rule to an Turtle
|
103
105
|
# @return [String]
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gregg Kellogg
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: sxp
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rdf
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: yard
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -127,30 +116,26 @@ files:
|
|
127
116
|
homepage: http://github.com/gkellogg/ebnf
|
128
117
|
licenses:
|
129
118
|
- Public Domain
|
119
|
+
metadata: {}
|
130
120
|
post_install_message:
|
131
121
|
rdoc_options: []
|
132
122
|
require_paths:
|
133
123
|
- lib
|
134
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
125
|
requirements:
|
137
126
|
- - ! '>='
|
138
127
|
- !ruby/object:Gem::Version
|
139
128
|
version: 1.8.7
|
140
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
130
|
requirements:
|
143
131
|
- - ! '>='
|
144
132
|
- !ruby/object:Gem::Version
|
145
133
|
version: '0'
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
hash: -4479271649691547126
|
149
134
|
requirements: []
|
150
135
|
rubyforge_project:
|
151
|
-
rubygems_version:
|
136
|
+
rubygems_version: 2.0.3
|
152
137
|
signing_key:
|
153
|
-
specification_version:
|
138
|
+
specification_version: 4
|
154
139
|
summary: EBNF parser and parser generator.
|
155
140
|
test_files: []
|
156
141
|
has_rdoc: false
|