[Mumps2Py:] [138] added two more tokens and restructured how I assign values to token constants .

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 138
Author:   pgallot
Date:     2008-02-28 20:20:01 +0000 (Thu, 28 Feb 2008)

Log Message:
-----------
added two more tokens and restructured how I assign values to token constants.

Modified Paths:
--------------
    trunk/mumps2py/tokens.py


Modified: trunk/mumps2py/tokens.py
===================================================================
--- trunk/mumps2py/tokens.py	2008-02-27 19:04:48 UTC (rev 137)
+++ trunk/mumps2py/tokens.py	2008-02-28 20:20:01 UTC (rev 138)
@@ -18,54 +18,146 @@
 from types import *
 import re
 
-# IMPORTANT: Add a Token Type Constant, update the relevant dictionaries.
+# token type constants:
+# IMPORTANT: when Adding a token constant, update the relevant dictionaries.
+FCC_MASK = 32
+SSV_MASK = 64
+V_MASK = 128
+F_MASK = 256
+OP_MASK = 512
+CMD_MASK = 1024
 
-# Token Type constants:
-# NOTE : each type of comand should have its own token.
-COMMENT, LABEL, BREAKCMD, CLOSECMD = 1, 2, 3, 4
-DOCMD, ELSECMD, FORCMD, GOTOCMD = 5, 6, 7, 8
-HANGCMD, IFCMD, JOBCMD, KILLCMD = 9, 10, 11, 12
-LOCKCMD, MERGECMD, NEWCMD, OPENCMD = 13, 14, 15, 16
-QUITCMD, READCMD, SETCMD, USECMD = 17, 18, 19, 20
-VIEWCMD, WRITECMD, XECUTECMD = 21, 22, 23
-EXPR, LOCALVAR, GLOBALVAR, ENTRYREF = 26, 27, 28, 29
-STRINGLITERAL, NUMLITERAL, INDIRECTION = 33, 34, 35
-UNKNOWNITEM, UNKNOWNCMD, USERFUNC = 36, 37, 38
-FCC_NEWLINE, FCC_NEWPAGE, FCC_MOV, FCC_CHARVAL = 40, 41, 42, 43
-EMPTYLINE, ZWRITECMD, ROUTINEHEAD, TEXTVAL = 45, 46, 47, 48
+UNKNOWNITEM = 0
+COMMENT = 1
+LABEL = 2
+EXPR = 3
+LOCALVAR = 4
+GLOBALVAR = 5
+EXTGLOBALVAR = 6
+ENTRYREF = 7
+STRINGLITERAL = 8
+NUMLITERAL = 9
+INDIRECTION = 10
+EMPTYLINE = 11
+ROUTINEHEAD = 12
+TEXTVAL = 13
 
-# NOTE: OPERATORS have token values starting at 50.
-OPADD, OPSUB, OPMULT, OPEXP = 50, 51, 52, 53 # +,-,*, **
-OPFRACDIV, OPINTDIV, OPMODULO = 54, 55, 56 # \,/, #
-OPNOT, OPAND, OPOR = 57, 58, 59 # ',&, !
-OPCONCAT, OPGT, OPLT, OPNGT, OPNLT = 60, 61, 62, 63, 64 # _,>,<,'>,'<
-OPEQ, OPNEQ = 65, 66 # =, '=
-OPCONTAINS, OPFOLLOWS, OPSORTS = 67, 68, 69 # [,], ]]
-OPPATMATCH, OPINDIRECT = 70, 71 # ?, @
-OPPATATOM, OPNAKEDREF = 72, 73
+FCC_NEWLINE = FCC_MASK + 1
+FCC_NEWPAGE = FCC_MASK + 2
+FCC_MOV = FCC_MASK + 3
+FCC_CHARVAL = FCC_MASK +  4
 
-#NOTE: INTRINSIC FUNCs and VARs have values starting at 100,150 respectively.
-F_ASCII, F_CHAR, F_DATA, F_EXTRACT = 100, 101, 102, 103
-F_FIND, F_FNUMBER, F_GET, F_JUSTIFY = 104, 105, 106, 107
-F_LENGTH, F_NAME, F_NEXT, F_ORDER = 108, 109, 110, 111
-F_PIECE, F_QLENGTH, F_QSUBSCRIPT, F_QUERY = 112, 113, 114, 115
-F_RANDOM, F_REVERSE, F_SELECT, F_STACK = 116, 117, 118, 119
-F_TEXT, F_TRANSLATE, F_VIEW = 120, 121, 122
-F_UNKNOWN = 123
+SSV_UNKNOWN = SSV_MASK + 0
+SSV_CHARACTER = SSV_MASK + 1
+SSV_DEVICE = SSV_MASK + 2
+SSV_DISPLAY = SSV_MASK + 3
+SSV_EVENT = SSV_MASK +  4
+SSV_GLOBAL = SSV_MASK + 5
+SSV_JOB = SSV_MASK + 6
+SSV_LIBRARY = SSV_MASK + 7
+SSV_LOCK = SSV_MASK + 8
+SSV_ROUTINE = SSV_MASK + 9
+SSV_SYSTEM = SSV_MASK + 10
+SSV_WINDOW = SSV_MASK + 11
+SSV_Y = SSV_MASK + 12
 
-V_DEVICE, V_ECODE, V_ESTACK, V_ETRAP = 150, 151, 152, 153
-V_HOROLOG, V_IO, V_JOB, V_KEY = 154, 155, 156, 157
-V_PRINCIPAL, V_QUIT, V_REFERENCE, V_STACK = 158, 159, 160, 161
-V_STORAGE, V_SYSTEM, V_TEST, V_X, V_Y = 162, 163, 164, 165, 166
-V_UNKNOWN = 167
+V_UNKNOWN = V_MASK + 0
+V_DEVICE = V_MASK + 1
+V_ECODE = V_MASK + 2
+V_ESTACK = V_MASK + 3
+V_ETRAP = V_MASK + 4
+V_HOROLOG = V_MASK + 5
+V_IO = V_MASK + 6
+V_JOB = V_MASK + 7
+V_KEY = V_MASK + 8
+V_PRINCIPAL = V_MASK + 9
+V_QUIT = V_MASK + 10
+V_REFERENCE = V_MASK + 11
+V_STACK = V_MASK + 12
+V_STORAGE = V_MASK + 13
+V_SYSTEM = V_MASK + 14
+V_TEST = V_MASK + 15
+V_X = V_MASK + 16
+V_Y = V_MASK + 17
 
-#NOTE: Structured System variables have values starting at 175.
-SSV_CHARACTER, SSV_DEVICE, SSV_DISPLAY, SSV_EVENT = 175, 176, 177, 178
-SSV_GLOBAL, SSV_JOB, SSV_LIBRARY, SSV_LOCK = 179, 180, 181, 182
-SSV_ROUTINE, SSV_SYSTEM, SSV_WINDOW, SSV_Y = 183, 184, 185, 186
-SSV_UNKNOWN = 187
+F_UNKNOWN = F_MASK + 0
+F_ASCII = F_MASK + 1
+F_CHAR = F_MASK + 2
+F_DATA = F_MASK + 3
+F_EXTRACT = F_MASK + 4
+F_FIND = F_MASK + 5
+F_FNUMBER = F_MASK + 6
+F_GET = F_MASK + 7
+F_JUSTIFY = F_MASK + 8
+F_LENGTH = F_MASK + 9
+F_NAME = F_MASK + 10
+F_NEXT = F_MASK + 11
+F_ORDER = F_MASK + 12
+F_PIECE = F_MASK + 13
+F_QLENGTH = F_MASK + 14
+F_QSUBSCRIPT = F_MASK + 15
+F_QUERY = F_MASK + 16
+F_RANDOM = F_MASK + 17
+F_REVERSE = F_MASK + 18
+F_SELECT = F_MASK + 19
+F_STACK = F_MASK + 20
+F_TEXT = F_MASK + 21
+F_TRANSLATE = F_MASK + 22
+F_VIEW = F_MASK + 23
 
+EXTERNALFUNC = F_MASK + 30
+USERFUNC = F_MASK + 31
 
+OPADD = OP_MASK + 1
+OPSUB = OP_MASK + 2 
+OPMULT = OP_MASK + 3
+OPEXP = OP_MASK + 4
+OPFRACDIV = OP_MASK + 5
+OPINTDIV = OP_MASK + 6
+OPMODULO = OP_MASK + 7
+OPNOT = OP_MASK + 8
+OPAND = OP_MASK + 9
+OPOR = OP_MASK + 10
+OPCONCAT = OP_MASK + 11
+OPGT = OP_MASK + 12
+OPLT = OP_MASK + 13
+OPNGT = OP_MASK + 14
+OPNLT = OP_MASK + 15
+OPEQ = OP_MASK + 16
+OPNEQ = OP_MASK + 17
+OPCONTAINS = OP_MASK + 18
+OPFOLLOWS = OP_MASK + 19
+OPSORTS = OP_MASK + 20
+OPPATMATCH = OP_MASK + 21
+OPINDIRECT = OP_MASK + 22
+OPPATATOM = OP_MASK + 23
+OPNAKEDREF = OP_MASK + 24
+
+UNKNOWNCMD = CMD_MASK + 0
+BREAKCMD = CMD_MASK + 1
+CLOSECMD = CMD_MASK + 2
+DOCMD = CMD_MASK + 3
+ELSECMD = CMD_MASK + 4
+FORCMD = CMD_MASK + 5
+GOTOCMD = CMD_MASK +  6
+HANGCMD = CMD_MASK + 7
+IFCMD = CMD_MASK + 8
+JOBCMD = CMD_MASK + 9
+KILLCMD = CMD_MASK + 10
+LOCKCMD = CMD_MASK + 11
+MERGECMD = CMD_MASK + 12
+NEWCMD = CMD_MASK + 13
+OPENCMD = CMD_MASK + 14
+QUITCMD = CMD_MASK + 15
+READCMD = CMD_MASK + 16
+SETCMD = CMD_MASK + 17
+USECMD = CMD_MASK + 18
+VIEWCMD = CMD_MASK + 19
+WRITECMD = CMD_MASK + 20
+XECUTECMD = CMD_MASK + 21
+
+ZWRITECMD = CMD_MASK + 31
+
 OP_TOKEN_DICT = {"+":OPADD, "-":OPSUB,
                  "*":OPMULT, "**":OPEXP,
                  "\\":OPFRACDIV, "/":OPINTDIV,
@@ -254,7 +346,9 @@
     EXPR:"Expression",
     LOCALVAR:"Local Variable",
     GLOBALVAR:"Global Variable",
+    EXTGLOBALVAR: "Extended Global",
     USERFUNC:"User Function",
+    EXTERNALFUNC:"External Function",
     STRINGLITERAL:"String",
     NUMLITERAL:"Number",
     INDIRECTION:"Indirection Expression",
@@ -353,9 +447,6 @@
         self.varname = None
         self.timeout = None
         self.expr = None
-        self.minrep = None
-        self.maxrep = None
-        self.repcount = None
         self.indirect = None
 
     def __del__(self):
@@ -483,6 +574,8 @@
     def __init__(self, tok_type, startpos):
         """ initializes a Token object of a variable Token type."""
         Token.__init__(self, tok_type, startpos)
+        self.global_dir = None
+        self.dummy = None
     
     def is_not(self):
         """returns true if the token is the not operator"""


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/