def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","/[*]","[*]/") self.addRule("Comment","//.*$") self.addRulePair("String",'L?"',r'$|[^\\](\\\\)*"') self.addRule("Char",r"'\\.'|'[^\\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?") self.addRule("Preprc",r"^\s*#(.*\\\n)*(.*(?!\\))$") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = ['struct','class','union','enum', 'int','float','double','signed','unsigned','char','short','void','bool', 'long','register','auto','operator', 'static','const','private','public','protected','virtual','explicit', 'new','delete','this', 'if','else','while','for','do','switch','case','default','sizeof', 'dynamic_cast','static_cast','const_cast','reinterpret_cast','typeid', 'try','catch','throw','throws','return','continue','break','goto'] reserved_words2 = ['extern', 'volatile', 'typedef', 'friend', '__declspec', 'inline','__asm','thread','naked', 'dllimport','dllexport','namespace','using', 'template','typename','goto'] special_words = ['std','string','vector','map','set','cout','cin','cerr'] constant_words = ['true','false','NULL'] self.addReserved(reserved_words) self.addConstant(constant_words) self.addWords(reserved_words2,'ResWord2') self.addWords(special_words,'Special')
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment", "/[*]", "[*]/") self.addRule("Comment", "//.*$") self.addRulePair("String", '"', r'$|[^\](\\)*"') self.addRule("Char", r"'\.'|'[^\]'") self.addRule( "Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[ll]?") self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = [ 'default', 'do', 'double', 'else', 'enum', 'extends', 'if', 'final', 'finally', 'float', 'for', 'integer', 'implements', 'import', 'int', 'jump', 'key', 'list', 'long', 'new', 'native', 'package', 'private', 'protected', 'return', 'rotation', 'state', 'static', 'string', 'synchronized', 'vector', 'while' ] self.addReserved(reserved_words) constant_words = ['true', 'false', 'null'] self.addConstant(constant_words)
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","\(\*","\*\)") self.addRulePair("Comment","\{","\}") self.addRule("Comment","//.*$") self.addRulePair("String",'\'','\'') self.addRule("Char",r"'\\.'|#[a-f0-9][a-f0-9]") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?|\$[0-9a-fA-F]+") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = ['class','interface','set','uses','unit', 'byte','integer','longint','float','double', 'extended','char','shortint','boolean', 'var','const','private','public','protected', 'new','this','super','abstract','native', 'synchronized','transient','volatile','strictfp', 'if','else','while','for','do','case','default', 'try','except','finally','raise','continue','break', 'begin','end','type','class','implementation', 'procedure','function','constructor','destructor'] self.addReserved(reserved_words) constant_words = ['true','false','nil'] self.addConstant(constant_words)
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","<--","-->/") self.addRulePair("String",r"(?<!\\)\"",r"(?<!\\)\"") self.addRulePair("String",r"(?<!\\)\'",r"(?<!\\)\'") self.addRule("Char",r"'\\.'|'[^\\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment", "<--", "-->/") self.addRulePair("String", r"(?<!\\)\"", r"(?<!\\)\"") self.addRulePair("String", r"(?<!\\)\'", r"(?<!\\)\'") self.addRule("Char", r"'\\.'|'[^\\]'") self.addRule( "Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?") self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
def setupRules (self): ParserBase.setupRules (self) self.addRulePair ("String", '"', r'$|[^\*]"') self.addRule ("Comment", "#.*$") reserved_words = ['INVALID', 'BEFORE', 'AFTER', 'EXPECTED', 'CODE', 'STUCK', 'NONE'] self.addRule("Preprc", r"^.[A-Z]*") self.addRule ("ID", "[a-zA-Z\.][0-9a-zA-Z\.]*") self.addRule ("SPChar", r"[><=~&:;\[\]+-?!]") self.addReserved(reserved_words)
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("String", '"', r'$|[^\*]"') self.addRule("Comment", "#.*$") reserved_words = [ 'INVALID', 'BEFORE', 'AFTER', 'EXPECTED', 'CODE', 'STUCK', 'NONE' ] self.addRule("Preprc", r"^.[A-Z]*") self.addRule("ID", "[a-zA-Z\.][0-9a-zA-Z\.]*") self.addRule("SPChar", r"[><=~&:;\[\]+-?!]") self.addReserved(reserved_words)
def setupRules (self): ParserBase.setupRules (self) self.addRule ("Comment","--.*$") self.addRulePair ("String", '"', r'$|[^\*]"') self.addRule ("Char", r"'\*.'|'[^\*]'") self.addRule ("Number", r"[0-9](\.[0-9]*)?(E[+-][0-9])?") self.addRule ("Preprc", r"#[A-Z]*") reserved_words = ['PROC', 'FUNCTION', 'VAL', 'BOOL', 'BYTE', 'INT16', 'INT32', 'INT64', 'INT', 'REAL32', 'REAL64', 'CHAR', 'SKIP', 'STOP', 'PAR', 'SEQ', 'ALT', 'IF', 'CASE', 'ELSE', 'FOR', 'TO', 'SIZE', 'IN', 'AT', 'WORKSPACE', 'VECTORSPACE', 'MOBILESPACE', 'WHILE', 'CHAN', 'PORT', 'INCLUDE', 'PRAGMA', 'EXTERNAL', 'USE', 'PLUS', 'MINUS', 'TIMES'] self.addRule ("ID", "[a-zA-Z\.][0-9a-zA-Z\.]*") self.addRule ("SPChar", r"[><=~&:;\[\]+-?!]") self.addRule ("Folded", r"\.\.\. .*$") self.addReserved(reserved_words) constant_words = ['TRUE', 'FALSE'] special_words = ['NATIVELIB', 'USES', 'INCLUDES', 'NAMESPACE'] self.addConstant(constant_words) self.addWords(special_words, 'Special')
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","/[*]","[*]/") self.addRule("Comment","//.*$") self.addRulePair("String",'"',r'$|[^\](\\)*"') self.addRule("Char",r"'\.'|'[^\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = ['default','do','double','else','enum','extends','if','final','finally', 'float','for','integer','implements','import','int','jump','key','list', 'long','new','native','package','private','protected','return','rotation','state','static','string', 'synchronized','vector','while'] self.addReserved(reserved_words) constant_words = ['true','false','null'] self.addConstant(constant_words)
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","/[*]","[*]/") self.addRule("Comment","//.*$") self.addRulePair("String",'"',r'$|[^\\](\\\\)*"') self.addRule("Char",r"'\\.'|'[^\\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = [ 'default', 'do', 'else', 'for', 'if', 'jump', 'return', 'state', 'while', 'float', 'integer', 'key', 'list', 'rotation', 'string', 'vector' ] self.addReserved(reserved_words) event_words = [ START:events '%name%', END:events 'last-event-with-no-comma' ] self.addWords(event_words,'ResWord2')
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","/[*]","[*]/") self.addRule("Comment","//.*$") self.addRulePair("String",'"',r'$|[^\\](\\\\)*"') self.addRule("Char",r"'\\.'|'[^\\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = ['class','interface','enum','import','package', 'byte','int','long','float','double','char','short','void','boolean', 'static','final','const','private','public','protected', 'new','this','super','abstract','native','synchronized','transient','volatile','strictfp', 'extends','implements','if','else','while','for','do','switch','case','default','instanceof', 'try','catch','finally','throw','throws','return','continue','break'] self.addReserved(reserved_words) constant_words = ['true','false','null'] self.addConstant(constant_words)
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment", "\(\*", "\*\)") self.addRulePair("Comment", "\{", "\}") self.addRule("Comment", "//.*$") self.addRulePair("String", "'", "'") self.addRule("Char", r"'\\.'|#[a-f0-9][a-f0-9]") self.addRule("Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?|\$[0-9a-fA-F]+") self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = [ "class", "interface", "set", "uses", "unit", "byte", "integer", "longint", "float", "double", "extended", "char", "shortint", "boolean", "var", "const", "private", "public", "protected", "new", "this", "super", "abstract", "native", "synchronized", "transient", "volatile", "strictfp", "if", "else", "while", "for", "do", "case", "default", "try", "except", "finally", "raise", "continue", "break", "begin", "end", "type", "class", "implementation", "procedure", "function", "constructor", "destructor", ] self.addReserved(reserved_words) constant_words = ["true", "false", "nil"] self.addConstant(constant_words)
def __init__(self, raw, request, **kw): ParserBase.__init__(self, raw, request, **kw) self._ignore_case = 1
def setupRules(self): ParserBase.setupRules(self) self.addRulePair("Comment","/[*]","[*]/") self.addRule("Comment","//.*$") self.addRulePair("String",'"',r'$|[^\](\\)*"') self.addRule("Char",r"'\.'|'[^\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = [ 'default', 'do', 'else', 'for', 'if', 'jump', 'return', 'state', 'while', 'float', 'integer', 'key', 'list', 'rotation', 'string', 'vector' ] self.addReserved(reserved_words) event_words = [ 'at_rot_target', 'at_target', 'attach', 'changed', 'collision', 'collision_end', 'collision_start', 'control', 'dataserver', 'email', 'http_request', 'http_response', 'land_collision', 'land_collision_end', 'land_collision_start', 'link_message', 'listen', 'money', 'moving_end', 'moving_start', 'no_sensor', 'not_at_rot_target', 'not_at_target', 'object_rez', 'on_rez', 'remote_data', 'run_time_permissions', 'sensor', 'state_entry', 'state_exit', 'timer', 'touch', 'touch_end', 'touch_start', 'last-event-with-no-comma' ] self.addWords(event_words,'ResWord2')