Move Token class to lexer module and rename main file
This commit is contained in:
parent
0457e29e6f
commit
95edb52c87
10
lexer.py
10
lexer.py
|
@ -9,7 +9,6 @@
|
|||
import math
|
||||
import operator
|
||||
|
||||
from token import Token
|
||||
from constants import (
|
||||
NUMBER, EOF,
|
||||
PLUS, MINUS, MUL, DIV, IDIV, MOD, POW, SQRT,
|
||||
|
@ -19,6 +18,15 @@ from constants import (
|
|||
)
|
||||
|
||||
|
||||
class Token():
|
||||
def __init__(self, type, value):
|
||||
self.type = type
|
||||
self.value = value
|
||||
|
||||
def __repr__(self):
|
||||
return "<{} {}>".format(self.type, self.value)
|
||||
|
||||
|
||||
class Lexer():
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
|
|
|
@ -19,7 +19,7 @@ def print_stack(interpreter, stack):
|
|||
print(interpreter.mode_func(item))
|
||||
|
||||
|
||||
def main():
|
||||
def rpncalc():
|
||||
interpreter = Interpreter()
|
||||
|
||||
while True:
|
||||
|
@ -44,5 +44,5 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
rpncalc()
|
||||
|
16
token.py
16
token.py
|
@ -1,16 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim:fenc=utf-8
|
||||
#
|
||||
# Copyright © 2019 pavle <pavle.portic@tilda.center>
|
||||
#
|
||||
# Distributed under terms of the BSD-3-Clause license.
|
||||
|
||||
class Token():
|
||||
def __init__(self, type, value):
|
||||
self.type = type
|
||||
self.value = value
|
||||
|
||||
def __repr__(self):
|
||||
return "<{} {}>".format(self.type, self.value)
|
||||
|
Loading…
Reference in New Issue