ruby-ll 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ module LL
2
+ ##
3
+ # Class containing data of a lexer token's source line source as the raw data,
4
+ # column, line number, etc.
5
+ #
6
+ class SourceLine
7
+ attr_reader :file, :data, :line, :column
8
+
9
+ ##
10
+ # @return [String]
11
+ #
12
+ DEFAULT_FILE = '(ruby)'
13
+
14
+ ##
15
+ # @param [String] data
16
+ # @param [Fixnum] line
17
+ # @param [Fixnum] column
18
+ # @param [String] file
19
+ #
20
+ def initialize(data, line = 1, column = 1, file = DEFAULT_FILE)
21
+ @file = file
22
+ @data = data
23
+ @line = line
24
+ @column = column
25
+ end
26
+
27
+ ##
28
+ # @return [String]
29
+ #
30
+ def source
31
+ return data.lines.to_a[line - 1].chomp
32
+ end
33
+
34
+ ##
35
+ # @return [TrueClass|FalseClass]
36
+ #
37
+ def ==(other)
38
+ return false unless other.class == self.class
39
+
40
+ return file == other.file &&
41
+ data == other.data &&
42
+ line == other.line &&
43
+ column == other.column
44
+ end
45
+ end # SourceLine
46
+ end # LL
@@ -0,0 +1,29 @@
1
+ module LL
2
+ ##
3
+ # Class containing details of a single terminal in a grammar.
4
+ #
5
+ class Terminal
6
+ attr_reader :name, :source_line, :references
7
+
8
+ ##
9
+ # @param [String] name
10
+ # @param [LL::SourceLine] source_line
11
+ #
12
+ def initialize(name, source_line)
13
+ @name = name
14
+ @source_line = source_line
15
+ @references = 0
16
+ end
17
+
18
+ def increment_references
19
+ @references += 1
20
+ end
21
+
22
+ ##
23
+ # @return [String]
24
+ #
25
+ def inspect
26
+ return "Terminal(name: #{name.inspect})"
27
+ end
28
+ end # Terminal
29
+ end # LL
@@ -0,0 +1,30 @@
1
+ module LL
2
+ ##
3
+ # A Token contains the data of a single lexer token.
4
+ #
5
+ class Token
6
+ attr_reader :type, :value, :source_line
7
+
8
+ ##
9
+ # @param [Symbol] type
10
+ # @param [String] value
11
+ # @param [LL::SourceLine] source_line
12
+ #
13
+ def initialize(type, value, source_line)
14
+ @type = type
15
+ @value = value
16
+ @source_line = source_line
17
+ end
18
+
19
+ ##
20
+ # @return [TrueClass|FalseClass]
21
+ #
22
+ def ==(other)
23
+ return false unless other.class == self.class
24
+
25
+ return type == other.type &&
26
+ value == other.value &&
27
+ source_line == other.source_line
28
+ end
29
+ end # Token
30
+ end # LL
@@ -0,0 +1,3 @@
1
+ module LL
2
+ VERSION = '1.0.0'
3
+ end # LL
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../lib/ll/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'ruby-ll'
5
+ s.version = LL::VERSION
6
+ s.authors = ['Yorick Peterse']
7
+ s.email = 'yorickpeterse@gmail.com'
8
+ s.summary = 'An LL(1) parser generator for Ruby.'
9
+ s.homepage = 'https://github.com/yorickpeterse/ruby-ll'
10
+ s.description = s.summary
11
+ s.license = 'MIT'
12
+
13
+ s.files = Dir.glob([
14
+ 'checkum/**/*',
15
+ 'doc/**/*',
16
+ 'lib/**/*.{rb,erb}',
17
+ 'ext/**/*',
18
+ 'README.md',
19
+ 'LICENSE',
20
+ '*.gemspec',
21
+ '.yardopts'
22
+ ]).select { |path| File.file?(path) }
23
+
24
+ s.executables = ['ruby-ll']
25
+
26
+ if RUBY_PLATFORM == 'java'
27
+ s.files << 'lib/libll.jar'
28
+
29
+ s.platform = 'java'
30
+ else
31
+ s.extensions = ['ext/c/extconf.rb']
32
+ end
33
+
34
+ s.has_rdoc = 'yard'
35
+ s.required_ruby_version = '>= 1.9.3'
36
+
37
+ s.add_dependency 'ast'
38
+ s.add_dependency 'ansi'
39
+
40
+ s.add_development_dependency 'rake'
41
+ s.add_development_dependency 'rspec', ['~> 3.0']
42
+ s.add_development_dependency 'yard'
43
+ s.add_development_dependency 'simplecov'
44
+ s.add_development_dependency 'kramdown'
45
+ s.add_development_dependency 'benchmark-ips', '~> 2.0'
46
+ s.add_development_dependency 'rake-compiler'
47
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-ll
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yorick Peterse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ast
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ansi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: kramdown
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: benchmark-ips
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake-compiler
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: An LL(1) parser generator for Ruby.
140
+ email: yorickpeterse@gmail.com
141
+ executables:
142
+ - ruby-ll
143
+ extensions:
144
+ - ext/c/extconf.rb
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".yardopts"
148
+ - LICENSE
149
+ - README.md
150
+ - bin/ruby-ll
151
+ - doc/DCO.md
152
+ - doc/changelog.md
153
+ - doc/css/common.css
154
+ - ext/c/driver.c
155
+ - ext/c/driver.h
156
+ - ext/c/driver_config.c
157
+ - ext/c/driver_config.h
158
+ - ext/c/extconf.rb
159
+ - ext/c/khash.h
160
+ - ext/c/kvec.h
161
+ - ext/c/libll.c
162
+ - ext/c/libll.h
163
+ - ext/c/macros.h
164
+ - ext/java/Libll.java
165
+ - ext/java/org/libll/Driver.java
166
+ - ext/java/org/libll/DriverConfig.java
167
+ - lib/ll.rb
168
+ - lib/ll/ast/node.rb
169
+ - lib/ll/branch.rb
170
+ - lib/ll/cli.rb
171
+ - lib/ll/code_generator.rb
172
+ - lib/ll/compiled_configuration.rb
173
+ - lib/ll/compiled_grammar.rb
174
+ - lib/ll/configuration_compiler.rb
175
+ - lib/ll/driver.rb
176
+ - lib/ll/driver_config.rb
177
+ - lib/ll/driver_template.erb
178
+ - lib/ll/epsilon.rb
179
+ - lib/ll/erb_context.rb
180
+ - lib/ll/grammar_compiler.rb
181
+ - lib/ll/lexer.rb
182
+ - lib/ll/message.rb
183
+ - lib/ll/parser.rb
184
+ - lib/ll/parser_error.rb
185
+ - lib/ll/rule.rb
186
+ - lib/ll/setup.rb
187
+ - lib/ll/source_line.rb
188
+ - lib/ll/terminal.rb
189
+ - lib/ll/token.rb
190
+ - lib/ll/version.rb
191
+ - ruby-ll.gemspec
192
+ homepage: https://github.com/yorickpeterse/ruby-ll
193
+ licenses:
194
+ - MIT
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: 1.9.3
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.4.5
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: An LL(1) parser generator for Ruby.
216
+ test_files: []
217
+ has_rdoc: yard