From ffc3e3423897d77b5e43af8ed567b544f00cf526 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 6 May 2015 06:00:26 +0300 Subject: initial commit --- src/tokens.py | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/tokens.py (limited to 'src/tokens.py') diff --git a/src/tokens.py b/src/tokens.py new file mode 100644 index 0000000..3c04668 --- /dev/null +++ b/src/tokens.py @@ -0,0 +1,105 @@ +# Copyright 2015 Egor Tensin +# This file is licensed under the terms of the MIT License. +# See LICENSE.txt for details. + +class Token: + pass + +class AdditionOpToken(Token): + def __str__(self): + return '+' + +class SubtractionOpToken(Token): + def __str__(self): + return '-' + +class MultiplicationOpToken(Token): + def __str__(self): + return '*' + +class DivisionOpToken(Token): + def __str__(self): + return '/' + +class AssignmentOpToken(Token): + def __str__(self): + return ':=' + +class SemicolonToken(Token): + def __str__(self): + return ';' + +class PrintToken(Token): + def __str__(self): + return 'print' + +class OpeningParenToken(Token): + def __str__(self): + return '(' + +class ClosingParenToken(Token): + def __str__(self): + return ')' + +class OpeningBraceToken(Token): + def __str__(self): + return '{' + +class ClosingBraceToken(Token): + def __str__(self): + return '}' + +class IdentifierToken(Token): + def __init__(self, i): + self._i = i + + def __str__(self): + return str(self._i) + +class FloatingPointNumberToken(Token): + def __init__(self, n): + self._n = n + + def __float__(self): + return float(self._n) + + def __str__(self): + return str(self._n) + +class IntegerNumberToken(Token): + def __init__(self, n): + self._n = n + + def __int__(self): + return int(self._n) + + def __str__(self): + return str(self._n) + +class TrueToken(Token): + def __str__(self): + return 'True' + +class FalseToken(Token): + def __str__(self): + return 'False' + +class AndOpToken(Token): + def __str__(self): + return '&&' + +class OrOpToken(Token): + def __str__(self): + return '||' + +class IfToken(Token): + def __str__(self): + return 'if' + +class EqualsOpToken(Token): + def __str__(self): + return '==' + +class NotEqualsOpToken(Token): + def __str__(self): + return '!=' -- cgit v1.2.3