ruby-ll 1.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
data/lib/ll/token.rb ADDED
@@ -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
data/lib/ll/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module LL
2
+ VERSION = '1.0.0'
3
+ end # LL
data/lib/ll.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'pathname'
2
+ require 'erb'
3
+ require 'set'
4
+ require 'optparse'
5
+
6
+ require 'ast'
7
+ require 'ansi/code'
8
+
9
+ require_relative 'll/setup'
10
+ require_relative 'll/source_line'
11
+ require_relative 'll/lexer'
12
+ require_relative 'll/token'
13
+ require_relative 'll/parser'
14
+ require_relative 'll/grammar_compiler'
15
+ require_relative 'll/code_generator'
16
+ require_relative 'll/compiled_grammar'
17
+ require_relative 'll/rule'
18
+ require_relative 'll/branch'
19
+ require_relative 'll/terminal'
20
+ require_relative 'll/epsilon'
21
+ require_relative 'll/message'
22
+ require_relative 'll/ast/node'
23
+ require_relative 'll/erb_context'
24
+ require_relative 'll/configuration_compiler'
25
+ require_relative 'll/compiled_configuration'
26
+ require_relative 'll/cli'
data/ruby-ll.gemspec ADDED
@@ -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: java
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
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: ansi
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.0'
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: kramdown
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ prerelease: false
110
+ type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: benchmark-ips
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '2.0'
123
+ prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake-compiler
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ prerelease: false
138
+ type: :development
139
+ description: An LL(1) parser generator for Ruby.
140
+ email: yorickpeterse@gmail.com
141
+ executables:
142
+ - ruby-ll
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".yardopts"
147
+ - LICENSE
148
+ - README.md
149
+ - bin/ruby-ll
150
+ - doc/DCO.md
151
+ - doc/changelog.md
152
+ - doc/css/common.css
153
+ - ext/c/driver.c
154
+ - ext/c/driver.h
155
+ - ext/c/driver_config.c
156
+ - ext/c/driver_config.h
157
+ - ext/c/extconf.rb
158
+ - ext/c/khash.h
159
+ - ext/c/kvec.h
160
+ - ext/c/libll.c
161
+ - ext/c/libll.h
162
+ - ext/c/macros.h
163
+ - ext/java/Libll.java
164
+ - ext/java/org/libll/Driver.java
165
+ - ext/java/org/libll/DriverConfig.java
166
+ - lib/libll.jar
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