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.8'.freeze
- ANTLR_JAR =
File.expand_path(
File.join('..', '..', 'vendor', 'antlr4-4.8-1-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
|
# 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
30
31
32
|
# File 'lib/antlr4-native/generator.rb', line 30
def antlr_ns
grammar_names['parser'] || grammar_names['default']
end
|
#ext_name ⇒ Object
42
43
44
|
# File 'lib/antlr4-native/generator.rb', line 42
def ext_name
@ext_name ||= underscore(parser_ns)
end
|
#gem_name ⇒ Object
26
27
28
|
# File 'lib/antlr4-native/generator.rb', line 26
def gem_name
@gem_name ||= dasherize(parser_ns)
end
|
#generate ⇒ Object
21
22
23
24
|
# File 'lib/antlr4-native/generator.rb', line 21
def generate
generate_antlr_code
write_interop_file
end
|
#lexer_ns ⇒ Object
38
39
40
|
# File 'lib/antlr4-native/generator.rb', line 38
def lexer_ns
@lexer_ns ||= grammar_names['lexer'] || "#{grammar_names['default']}Lexer"
end
|
#parser_ns ⇒ Object
34
35
36
|
# File 'lib/antlr4-native/generator.rb', line 34
def parser_ns
@parser_ns ||= grammar_names['parser'] || "#{grammar_names['default']}Parser"
end
|