Class: Antlr4ruby::Lexer Abstract

Inherits:
Recognizer show all
Defined in:
lib/antlr4ruby/lexer.rb

Overview

This class is abstract.

Direct Known Subclasses

LexerInterpreter

Constant Summary collapse

DEFAULT_MODE =
0
MORE =
-2
SKIP =
-3
DEFAULT_TOKEN_CHANNEL =
Token::DEFAULT_CHANNEL
HIDDEN =
Token::HIDDEN_CHANNEL
MIN_CHAR_VALUE =
0x0000
MAX_CHAR_VALUE =
0x10ffff

Constants inherited from Recognizer

Recognizer::EOF

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Recognizer

#action, #add_error_listener, #get_atn, #get_error_header, #get_error_listener_dispatch, #get_error_listeners, #get_grammar_file_name, #get_interpreter, #get_parse_info, #get_rule_index_map, #get_rule_names, #get_serialized_atn, #get_state, #get_token_names, #get_token_type, #get_token_type_map, #get_vocabulary, #precpred, #remove_error_listener, #remove_error_listeners, #sempred, #set_interpreter, #set_state

Constructor Details

#initialize(input) ⇒ Lexer

Returns a new instance of Lexer.



21
22
23
24
25
26
27
28
29
30
# File 'lib/antlr4ruby/lexer.rb', line 21

def initialize(input)
  super()
  @token_start_char_index = -1
  @mode = Lexer.DEFAULT_MODE
  @mode_stack = IntegerStack.new
  if input
    @input = input
    @token_factory_source_pair = Pair.new(self, input)
  end
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def channel
  @channel
end

#hit_eofObject

Returns the value of attribute hit_eof.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def hit_eof
  @hit_eof
end

#inputObject

Returns the value of attribute input.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def input
  @input
end

#modeObject

Returns the value of attribute mode.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def mode
  @mode
end

#mode_stackObject

Returns the value of attribute mode_stack.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def mode_stack
  @mode_stack
end

#textObject

Returns the value of attribute text.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def text
  @text
end

#tokenObject

Returns the value of attribute token.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def token
  @token
end

#token_start_char_indexObject

Returns the value of attribute token_start_char_index.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def token_start_char_index
  @token_start_char_index
end

#token_start_lineObject

Returns the value of attribute token_start_line.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def token_start_line
  @token_start_line
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'lib/antlr4ruby/lexer.rb', line 17

def type
  @type
end

Instance Method Details

#emit(token) ⇒ Object



63
64
65
# File 'lib/antlr4ruby/lexer.rb', line 63

def emit(token)
  # todo

end

#emit_eofObject



67
68
69
# File 'lib/antlr4ruby/lexer.rb', line 67

def emit_eof
  # todo

end

#get_all_tokensObject



123
124
125
# File 'lib/antlr4ruby/lexer.rb', line 123

def get_all_tokens
  # todo

end

#get_channelObject



111
112
113
# File 'lib/antlr4ruby/lexer.rb', line 111

def get_channel
  @channel
end

#get_channel_namesObject



115
116
117
# File 'lib/antlr4ruby/lexer.rb', line 115

def get_channel_names
  []
end

#get_char_error_display(c) ⇒ Object



139
140
141
# File 'lib/antlr4ruby/lexer.rb', line 139

def get_char_error_display(c)
  # todo

end

#get_char_indexObject



79
80
81
# File 'lib/antlr4ruby/lexer.rb', line 79

def get_char_index
  # todo

end

#get_char_position_in_lineObject



172
173
174
# File 'lib/antlr4ruby/lexer.rb', line 172

def get_char_position_in_line
  # todo

end

#get_error_display(s) ⇒ Object



135
136
137
# File 'lib/antlr4ruby/lexer.rb', line 135

def get_error_display(s)
  # todo

end

#get_input_streamObject



164
165
166
# File 'lib/antlr4ruby/lexer.rb', line 164

def get_input_stream
  # todo

end

#get_lineObject



168
169
170
# File 'lib/antlr4ruby/lexer.rb', line 168

def get_line
  # todo

end

#get_mode_namesObject



119
120
121
# File 'lib/antlr4ruby/lexer.rb', line 119

def get_mode_names
  []
end

#get_source_nameObject



160
161
162
# File 'lib/antlr4ruby/lexer.rb', line 160

def get_source_name
  # todo

end

#get_textObject



83
84
85
# File 'lib/antlr4ruby/lexer.rb', line 83

def get_text
  # todo

end

#get_tokenObject



91
92
93
# File 'lib/antlr4ruby/lexer.rb', line 91

def get_token
  @token
end

#get_token_factoryObject



152
153
154
# File 'lib/antlr4ruby/lexer.rb', line 152

def get_token_factory
  # todo

end

#get_typeObject



103
104
105
# File 'lib/antlr4ruby/lexer.rb', line 103

def get_type
  @type
end

#moreObject



45
46
47
# File 'lib/antlr4ruby/lexer.rb', line 45

def more
  @type = more
end

#next_tokenObject



144
145
146
# File 'lib/antlr4ruby/lexer.rb', line 144

def next_token
  # todo

end

#notify_listeners(e) ⇒ Object



131
132
133
# File 'lib/antlr4ruby/lexer.rb', line 131

def notify_listeners(e)
  # todo

end

#pop_modeObject

不能定义 mode 函数,会覆盖掉 attr_accessor def mode(m)

@mode = m

end



54
55
56
# File 'lib/antlr4ruby/lexer.rb', line 54

def pop_mode
  # todo

end

#push_mode(m) ⇒ Object



58
59
60
61
# File 'lib/antlr4ruby/lexer.rb', line 58

def push_mode(m)
  p "push_mode #{m}" if LexerATNSimulator.debug
  # todo

end

#recover(e) ⇒ Object



127
128
129
# File 'lib/antlr4ruby/lexer.rb', line 127

def recover(e)
  # todo

end

#resetObject



37
38
39
# File 'lib/antlr4ruby/lexer.rb', line 37

def reset
  # todo

end

#set_channel(channel) ⇒ Object



107
108
109
# File 'lib/antlr4ruby/lexer.rb', line 107

def set_channel(channel)
  @channel = channel
end

#set_char_position_in_line(position) ⇒ Object



75
76
77
# File 'lib/antlr4ruby/lexer.rb', line 75

def set_char_position_in_line(position)
  # todo

end

#set_input_stream(input) ⇒ Object



156
157
158
# File 'lib/antlr4ruby/lexer.rb', line 156

def set_input_stream(input)
  # todo

end

#set_line(line) ⇒ Object



71
72
73
# File 'lib/antlr4ruby/lexer.rb', line 71

def set_line(line)
  # todo

end

#set_text(text) ⇒ Object



87
88
89
# File 'lib/antlr4ruby/lexer.rb', line 87

def set_text(text)
  @text = text
end

#set_token(token) ⇒ Object



95
96
97
# File 'lib/antlr4ruby/lexer.rb', line 95

def set_token(token)
  @token = token
end

#set_token_factory(factory) ⇒ Object



148
149
150
# File 'lib/antlr4ruby/lexer.rb', line 148

def set_token_factory(factory)
  # todo

end

#set_type(token_type) ⇒ Object



99
100
101
# File 'lib/antlr4ruby/lexer.rb', line 99

def set_type(token_type)
  @type = token_type
end

#skipObject



41
42
43
# File 'lib/antlr4ruby/lexer.rb', line 41

def skip
  @type = SKIP
end