Class: Antlr4Native::Generator
- Inherits:
-
Object
- Object
- Antlr4Native::Generator
show all
- Includes:
- StringHelpers
- Defined in:
- lib/antlr4-native/generator.rb
Constant Summary
collapse
- ANTLR_VERSION =
'4.10.1'.freeze
- ANTLR_JAR =
File.expand_path(
File.join('..', '..', 'vendor', "antlr-#{ANTLR_VERSION}-complete.jar"), __dir__
).freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
#capitalize, #dasherize, #underscore
Constructor Details
#initialize(grammar_files:, output_dir:, parser_root_method:) ⇒ Generator
Returns a new instance of Generator.
15
16
17
18
19
20
|
# File 'lib/antlr4-native/generator.rb', line 15
def initialize(grammar_files:, output_dir:, parser_root_method:)
@grammar_files = grammar_files
@output_dir = output_dir
@parser_root_method = parser_root_method
end
|
Instance Attribute Details
#grammar_files ⇒ Object
Returns the value of attribute grammar_files.
13
14
15
|
# File 'lib/antlr4-native/generator.rb', line 13
def grammar_files
@grammar_files
end
|
#output_dir ⇒ Object
Returns the value of attribute output_dir.
13
14
15
|
# File 'lib/antlr4-native/generator.rb', line 13
def output_dir
@output_dir
end
|
#parser_root_method ⇒ Object
Returns the value of attribute parser_root_method.
13
14
15
|
# File 'lib/antlr4-native/generator.rb', line 13
def parser_root_method
@parser_root_method
end
|
Instance Method Details
#antlr_ns ⇒ Object
31
32
33
|
# File 'lib/antlr4-native/generator.rb', line 31
def antlr_ns
grammar_names['parser'] || grammar_names['default']
end
|
#ext_name ⇒ Object
43
44
45
|
# File 'lib/antlr4-native/generator.rb', line 43
def ext_name
@ext_name ||= underscore(parser_ns)
end
|
#gem_name ⇒ Object
27
28
29
|
# File 'lib/antlr4-native/generator.rb', line 27
def gem_name
@gem_name ||= underscore(parser_ns)
end
|
#generate ⇒ Object
22
23
24
25
|
# File 'lib/antlr4-native/generator.rb', line 22
def generate
generate_antlr_code
write_interop_file
end
|
#lexer_ns ⇒ Object
39
40
41
|
# File 'lib/antlr4-native/generator.rb', line 39
def lexer_ns
@lexer_ns ||= grammar_names['lexer'] || "#{grammar_names['default']}Lexer"
end
|
#parser_ns ⇒ Object
35
36
37
|
# File 'lib/antlr4-native/generator.rb', line 35
def parser_ns
@parser_ns ||= grammar_names['parser'] || "#{grammar_names['default']}Parser"
end
|