Move Token class to lexer module and rename main file

This commit is contained in:
Pavle Portic 2019-04-26 16:38:31 +02:00
parent 0457e29e6f
commit 95edb52c87
Signed by: TheEdgeOfRage
GPG Key ID: 6758ACE46AA2A849
3 changed files with 11 additions and 19 deletions

View File

@ -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

View File

@ -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()

View File

@ -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)