Class: Antlr4Native::ContextMethod
- Inherits:
-
Object
- Object
- Antlr4Native::ContextMethod
- Defined in:
- lib/antlr4-native/context_method.rb
Constant Summary collapse
- RULE_METHODS =
%w(enterRule exitRule getRuleIndex).freeze
- META_METHODS =
%w(accept copyFrom).freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#raw_args ⇒ Object
readonly
Returns the value of attribute raw_args.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
Instance Method Summary collapse
- #args ⇒ Object
- #constructor? ⇒ Boolean
-
#context_method? ⇒ Boolean
@TODO: consider revising this.
- #cpp_name ⇒ Object
-
#initialize(name, raw_args, return_type, context) ⇒ ContextMethod
constructor
A new instance of ContextMethod.
- #meta_method? ⇒ Boolean
- #returns_vector? ⇒ Boolean
- #rule_method? ⇒ Boolean
- #token_method? ⇒ Boolean
Constructor Details
#initialize(name, raw_args, return_type, context) ⇒ ContextMethod
Returns a new instance of ContextMethod.
8 9 10 11 12 13 |
# File 'lib/antlr4-native/context_method.rb', line 8 def initialize(name, raw_args, return_type, context) @name = name @raw_args = raw_args @return_type = return_type @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/antlr4-native/context_method.rb', line 6 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/antlr4-native/context_method.rb', line 6 def name @name end |
#raw_args ⇒ Object (readonly)
Returns the value of attribute raw_args.
6 7 8 |
# File 'lib/antlr4-native/context_method.rb', line 6 def raw_args @raw_args end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
6 7 8 |
# File 'lib/antlr4-native/context_method.rb', line 6 def return_type @return_type end |
Instance Method Details
#args ⇒ Object
25 26 27 28 29 |
# File 'lib/antlr4-native/context_method.rb', line 25 def args @args ||= raw_args.split(',').map do |arg| ContextMethodArg.new(arg.strip) end end |
#constructor? ⇒ Boolean
55 56 57 |
# File 'lib/antlr4-native/context_method.rb', line 55 def constructor? name == context.name end |
#context_method? ⇒ Boolean
@TODO: consider revising this
36 37 38 39 40 41 |
# File 'lib/antlr4-native/context_method.rb', line 36 def context_method? !token_method? && !rule_method? && ! && !constructor? end |
#cpp_name ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/antlr4-native/context_method.rb', line 15 def cpp_name @cpp_name ||= if args.size == 1 && args.first.name == 'i' # special case "#{name}At" else [name, *args.map(&:name)].join('_') end end |
#meta_method? ⇒ Boolean
51 52 53 |
# File 'lib/antlr4-native/context_method.rb', line 51 def META_METHODS.include?(name) end |
#returns_vector? ⇒ Boolean
31 32 33 |
# File 'lib/antlr4-native/context_method.rb', line 31 def returns_vector? return_type.start_with?('std::vector') end |
#rule_method? ⇒ Boolean
47 48 49 |
# File 'lib/antlr4-native/context_method.rb', line 47 def rule_method? RULE_METHODS.include?(name) end |
#token_method? ⇒ Boolean
43 44 45 |
# File 'lib/antlr4-native/context_method.rb', line 43 def token_method? name[0].upcase == name[0] end |