aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tokens.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-05-06 06:00:26 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-05-06 06:00:26 +0300
commitffc3e3423897d77b5e43af8ed567b544f00cf526 (patch)
tree8d42c3bff0d6de4b8f32c9f97dfd5137563f5325 /src/tokens.py
downloadsimple-interpreter-ffc3e3423897d77b5e43af8ed567b544f00cf526.tar.gz
simple-interpreter-ffc3e3423897d77b5e43af8ed567b544f00cf526.zip
initial commit
Diffstat (limited to 'src/tokens.py')
-rw-r--r--src/tokens.py105
1 files changed, 105 insertions, 0 deletions
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 <Egor.Tensin@gmail.com>
+# 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 '!='