lexer
¶
Module for handling the lexer analysis.
Classes:
-
Lexer
–Lexer class for tokenizing known variables.
-
Token
–Token class store the kind and the value of the token.
-
TokenKind
–TokenKind enumeration for known variables returned by the lexer.
-
TokenList
–Class for handle a List of tokens.
Lexer
¶
Lexer()
Lexer class for tokenizing known variables.
Attributes:
-
cur_loc
(SourceLocation
) –Current source location.
-
lex_loc
(SourceLocation
) –Source location for lexer.
Methods:
-
advance
–Advance the token from the buffer.
-
clean
–Reset the Lexer attributes.
-
get_token
–Get the next token.
-
lex
–Create a list of tokens from input source.
Source code in src/arx/lexer.py
236 237 238 239 240 241 242 243 244 |
|
advance
¶
advance() -> str
Advance the token from the buffer.
Returns:
-
int
–TokenKind in integer form.
Source code in src/arx/lexer.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
clean
¶
clean() -> None
Reset the Lexer attributes.
Source code in src/arx/lexer.py
246 247 248 249 250 251 |
|
get_token
¶
get_token() -> Token
Get the next token.
Returns:
-
int
–The next token from standard input.
Source code in src/arx/lexer.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
lex
¶
lex() -> TokenList
Create a list of tokens from input source.
Source code in src/arx/lexer.py
360 361 362 363 364 365 366 367 368 |
|
Token
dataclass
¶
Token class store the kind and the value of the token.
Methods:
-
get_display_value
–Return the string representation of a token value.
-
get_name
–Get the name of the specified token.
Source code in src/arx/lexer.py
99 100 101 102 103 104 105 106 107 |
|
get_display_value
¶
get_display_value() -> str
Return the string representation of a token value.
Returns:
-
str: The string representation of the token value.
–
Source code in src/arx/lexer.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
get_name
¶
get_name() -> str
Get the name of the specified token.
Parameters:
-
tok
(int
) –TokenKind value.
Returns:
-
str
–Name of the token.
Source code in src/arx/lexer.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
TokenList
¶
Class for handle a List of tokens.
Methods:
-
get_next_token
–Provide a simple token buffer.
-
get_token
–Get the next token.
Source code in src/arx/lexer.py
162 163 164 165 166 |
|
get_next_token
¶
get_next_token() -> Token
Provide a simple token buffer.
Returns:
-
int
–The current token the parser is looking at. Reads another token from the lexer and updates cur_tok with its results.
Source code in src/arx/lexer.py
192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
get_token
¶
get_token() -> Token
Get the next token.
Returns:
-
int
–The next token from standard input.
Source code in src/arx/lexer.py
179 180 181 182 183 184 185 186 187 188 189 190 |
|