vivjson.lexer (2025-03-20) | index https://github.com/benesult/vivjson-python/tree/main/vivjson/lexer.py |
Lexer for VivJson
- Lexer: Constructor. Its argument is source code as string.
- Lexer#get_token: Extract a token from the current position of source
code.
For example, the given source code is extracted as below.
GT NUMBER ASSIGN PLUS NUMBER
| | | | |
while ( i > 3 ) { i = i + 1 }
| | | | | | | |
IDENTIFIER | IDENTIFIER | | IDENTIFIER |
| | | |
LEFT_PARENTHESIS | LEFT_CURLY_BRACKET |
| |
RIGHT_PARENTHESIS RIGHT_CURLY_BRACKET
Refer to:
- "Let's make a Teeny Tiny compiler"
https://austinhenley.com/blog/teenytinycompiler1.html
- "Crafting Interpreters"
https://craftinginterpreters.com/
Note that this code is made from scratch. The source code
of the above WEB sites is not used.
Environment:
- Python 3.9 or later
License:
Copyright 2025 benesult
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Modules | ||||||
|
Classes | ||||||||||
|
Author | ||
Fumiaki Motegi <motegi@benesult.com> |