* Tokens separated out of parser, needed in writer.

git-svn-id: trunk@27034 -
This commit is contained in:
michael 2014-03-08 14:45:34 +00:00
parent cedcd354b3
commit 0de9c58092
2 changed files with 80 additions and 0 deletions
.gitattributes
packages/fcl-js/src

1
.gitattributes vendored
View File

@ -2360,6 +2360,7 @@ packages/fcl-js/fpmake.pp svneol=native#text/plain
packages/fcl-js/src/jsbase.pp svneol=native#text/plain
packages/fcl-js/src/jsparser.pp svneol=native#text/plain
packages/fcl-js/src/jsscanner.pp svneol=native#text/plain
packages/fcl-js/src/jstoken.pp svneol=native#text/plain
packages/fcl-js/src/jstree.pp svneol=native#text/plain
packages/fcl-js/tests/tcparser.pp svneol=native#text/plain
packages/fcl-js/tests/tcscanner.pp svneol=native#text/plain

View File

@ -0,0 +1,79 @@
unit jstoken;
{$mode objfpc}{$H+}
interface
type
TJSToken = (tjsUnknown,
// Specials
tjsEOF,tjsWhiteSpace,tjsChar,tjsString, tjsIdentifier,tjsNumber, tjsComment,tjsREGEX, tjsRESERVED,
tjsANDAND, tjsANDEQ,
tjsBraceOpen,tjsBraceClose,tjsSQuaredBraceOpen,tjsSQuaredBraceClose,tjsCurlyBraceOpen,tjsCurlyBraceClose,
tjsCOMMA,tjsCOLON, tjsDOT,tjsSEMICOLON, tjsASSIGN,tjsGT,tjsLT, tjsConditional,
tjsPLUS,tjsMINUS,tjsMUL,tjsDIV,tjsAnd,tjsOR, tjsInv, tjsMod, tjsXOR, tjsNot,
tjsEQ,
tjsGE,
tjsLE, tjsLSHIFT, tjsLSHIFTEQ,
tjsMINUSEQ, tjsMINUSMINUS, tjsMODEQ,tjsDIVEQ,tjsXOREq,
tjsNE,
tjsOREQ, tjsOROR,
tjsPLUSEQ, tjsPLUSPLUS,
tjsURSHIFT, tjsURSHIFTEQ,
tjsRSHIFT, tjsRSHIFTEQ,
tjsSEQ, tjsSNE, tjsMULEQ,
{ Reserved words start here. They must be last }
tjsBREAK,tjsCASE, tjsCATCH, tjsCONTINUE,
tjsDEFAULT, tjsDELETE, tjsDO,
tjsELSE,
tjsFalse, tjsFINALLY, tjsFOR, tjsFUNCTION,
tjsIF, tjsIN, tjsINSTANCEOF,
tjsNEW,tjsNULL,
tjsRETURN,
tjsSWITCH,
tjsTHIS, tjsTHROW, tjsTrue, tjsTRY, tjsTYPEOF,
tjsVAR, tjsVOID,
tjsWHILE, tjsWITH
);
const
FirstKeyword = tjsBreak;
LastKeyWord = tJSWith;
TokenInfos: array[TJSToken] of string = ('unknown',
// Specials
'EOF','whitespace','Char','String', 'identifier','number','comment','regular expression', 'reserved word',
'&&','&=',
'(',')','[',']','{','}',
',',':','.',';','=','>','<','?',
'+','-','*','/','&','|','~','%','^','!',
'==',
'>=',
'<=', '<<', '<<=',
'-=', '--', '%=', '/=','^=',
'!=',
'|=', '||',
'+=', '++',
'>>>', '>>>=',
'>>', '>>=',
'===', '!==', '*=',
// Identifiers last
'break','case','catch', 'continue',
'default','delete', 'do',
'else',
'false','finally', 'for', 'function',
'if', 'in', 'instanceof',
'new','null',
'return',
'switch',
'this', 'throw', 'true', 'try', 'typeof',
'var', 'void',
'while', 'with'
);
implementation
end.