From dd9468e5d99e5f1420fdfb1dc8abc46608763e14 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 23 Apr 2012 15:58:00 +0200 Subject: beta 2012.04.23 15:58 --- .../lexers/data/scite-context-data-context.lua | 2 +- .../data/scite/lexers/scite-context-lexer-lua.lua | 2 +- .../lexers/scite-context-lexer-pdf-object.lua | 10 ++-- .../scite/lexers/scite-context-lexer-pdf-xref.lua | 21 ++++++-- .../data/scite/lexers/scite-context-lexer-pdf.lua | 33 +++++++++--- context/data/scite/lexers/scite-context-lexer.lua | 46 +++++++++-------- .../scite/scite-context-data-context.properties | 60 +++++++++++----------- context/data/scite/scite-ctx.lua | 16 ++++-- 8 files changed, 120 insertions(+), 70 deletions(-) (limited to 'context/data/scite') diff --git a/context/data/scite/lexers/data/scite-context-data-context.lua b/context/data/scite/lexers/data/scite-context-data-context.lua index 1e5b4059c..853ce38de 100644 --- a/context/data/scite/lexers/data/scite-context-data-context.lua +++ b/context/data/scite/lexers/data/scite-context-data-context.lua @@ -1,4 +1,4 @@ return { ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "conditionaltrue", "conditionalfalse", "attributeunsetvalue", "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", "inicatcodes", "ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes", "prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes", "xmlcatcodes", "escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode", "endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode", "spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode", "tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode", "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode", "colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode", "leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode", "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", "primeasciicode", "activemathcharcode", "activetabtoken", "activeformfeedtoken", "activeendoflinetoken", "batchmodecode", "nonstopmodecode", "scrollmodecode", "errorstopmodecode", "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", "gluenodecode", "kernnodecode", "penaltynodecode", "unsetnodecode", "mathsnodecode", "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", "doifmode", "doifmodeelse", "doifnotmode", "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startdocument", "stopdocument", "documentvariable", "startmodule", "stopmodule", "usemodule", "enablemode", "disablemode", "preventmode", "pushmode", "popmode", "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", "continueifinputfile" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "donothing", "dontcomplain", "donetrue", "donefalse", "htdp", "unvoidbox", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextbgroupelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant", "newmacro", "setnewmacro", "newfraction", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "donothing", "dontcomplain", "donetrue", "donefalse", "htdp", "unvoidbox", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextbgroupelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant", "newmacro", "setnewmacro", "newfraction", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut" }, } \ No newline at end of file diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index 4f48fb2a5..0ace7afc6 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -142,7 +142,7 @@ local identifier = token("default",validword) ----- operator = token("special", P('..') + P('~=') + S('+-*/%^#=<>;:,.{}[]()')) -- maybe split off {}[]() ----- operator = token("special", S('+-*/%^#=<>;:,{}[]()') + P('..') + P('.') + P('~=') ) -- maybe split off {}[]() -local operator = token("special", S('+-*/%^#=<>;:,{}[]().') + P('~=') ) +local operator = token("special", S('+-*/%^#=<>;:,{}[]().') + P('~=') ) -- no ^1 because of nested lexers local structure = token("special", S('{}[]()')) diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-object.lua b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua index 3694b24d8..b1d87e080 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf-object.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua @@ -60,9 +60,12 @@ local whatsit = token("quote", langle) local keyword = token("command", name) local constant = token("constant", name) local number = token('number', real) -local reference = token("number", cardinal) +-- local reference = token("number", cardinal) +-- * t_spacing +-- * token("number", cardinal) +local reference = token("warning", cardinal) * t_spacing - * token("number", cardinal) + * token("warning", cardinal) * t_spacing * token("keyword", p_reference) local t_comment = token("comment", p_comment) @@ -92,9 +95,10 @@ local t_dictionary = { "dictionary", } local t_object = { "object", -- weird that we need to catch the end here (probably otherwise an invalid lpeg) - object = t_spaces * (V("dictionary") * t_spaces * t_stream^-1 + V("array") + t_spaces) * t_spaces * t_closeobject, + object = t_spaces * (V("dictionary") * t_spaces * t_stream^-1 + V("array") + V("number") + t_spaces) * t_spaces * t_closeobject, dictionary = t_opendictionary * (t_spaces * keyword * t_spaces * V("whatever"))^0 * t_spaces * t_closedictionary, array = t_openarray * (t_spaces * V("whatever"))^0 * t_spaces * t_closearray, + number = number, whatever = V("dictionary") + V("array") + constant + reference + string + unicode + number + whatsit, } diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua index 827926185..f205e9130 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua @@ -8,7 +8,12 @@ local info = { local lexer = lexer local token = lexer.token -local P = lpeg.P +local P, R = lpeg.P, lpeg.R + +-- xref +-- cardinal cardinal [character] +-- .. +-- %%EOF | startxref | trailer local pdfxreflexer = { _NAME = "pdf-xref", _FILENAME = "scite-context-lexer-pdf-xref" } local whitespace = lexer.WHITESPACE -- triggers states @@ -23,10 +28,18 @@ local t_spacing = token(whitespace, spacing) local p_trailer = P("trailer") -local t_xref = token("default", (1-p_trailer)^1) - * token("keyword", p_trailer) +local t_number = token("number", R("09")^1) + * t_spacing + * token("number", R("09")^1) * t_spacing - * pdfobjectlexer._shared.dictionary + * (token("keyword", R("az","AZ")) * t_spacing)^-1 + +local t_xref = t_number^1 + +-- local t_xref = token("default", (1-p_trailer)^1) +-- * token("keyword", p_trailer) +-- * t_spacing +-- * pdfobjectlexer._shared.dictionary pdfxreflexer._rules = { { 'whitespace', t_spacing }, diff --git a/context/data/scite/lexers/scite-context-lexer-pdf.lua b/context/data/scite/lexers/scite-context-lexer-pdf.lua index c89270c64..8687a5226 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf.lua @@ -34,29 +34,48 @@ local p_obj = P("obj") local p_endobj = P("endobj") local p_xref = P("xref") local p_startxref = P("startxref") +local p_eof = P("%%EOF") +local p_trailer = P("trailer") local p_objectnumber = patterns.cardinal local p_comment = P('%') * restofline local t_comment = token("comment", p_comment) -local t_openobject = token("number", p_objectnumber) +-- local t_openobject = token("number", p_objectnumber) +-- * t_spacing +-- * token("number", p_objectnumber) +local t_openobject = token("warning", p_objectnumber) * t_spacing - * token("number", p_objectnumber) + * token("warning", p_objectnumber) * t_spacing * token("keyword", p_obj) * t_spacing^0 local t_closeobject = token("keyword", p_endobj) -local t_openxref = token("keyword", p_xref) -local t_closexref = token("keyword", p_startxref) +-- We could do clever xref parsing but why should we (i.e. we should check for +-- the xref body. As a pdf file is not edited, we could do without a nested +-- lexer anyway. + +local t_trailer = token("keyword", p_trailer) + * t_spacing + * pdfobjectlexer._shared.dictionary + +local t_openxref = token("plain", p_xref) +local t_closexref = token("plain", p_startxref) + + token("comment", p_eof) + + t_trailer +local t_startxref = token("plain", p_startxref) + * t_spacing + * token("number", R("09")^1) lexer.embed_lexer(pdflexer, pdfobjectlexer, t_openobject, t_closeobject) lexer.embed_lexer(pdflexer, pdfxreflexer, t_openxref, t_closexref) pdflexer._rules = { - { 'whitespace', t_spacing }, - { 'comment', t_comment }, - { 'rest', t_rest }, + { 'whitespace', t_spacing }, + { 'comment', t_comment }, + { 'xref', t_startxref }, + { 'rest', t_rest }, } pdflexer._tokenstyles = context.styleset diff --git a/context/data/scite/lexers/scite-context-lexer.lua b/context/data/scite/lexers/scite-context-lexer.lua index 457b855d2..1218d1f51 100644 --- a/context/data/scite/lexers/scite-context-lexer.lua +++ b/context/data/scite/lexers/scite-context-lexer.lua @@ -16,25 +16,13 @@ local info = { -- change in 3.03 is that no longer a script can be specified. This means that instead -- of loading the extensions via the properties file, we now need to load them in our -- own lexers, unless of course we replace lexer.lua completely (which adds another --- installation issue). The loading takes place with: --- --- if not lexer._CONTEXTEXTENSIONS then --- dofile(_LEXERHOME .. "/scite-context-lexer.lua") --- end --- --- So, where pre 3.03 we loaded that file and in that file the original lexing code, we --- now do the reverse. I also moved some helpers here because the new module structure --- hides some (now local) functions. +-- installation issue). -- -- Another change has been that _LEXERHOME is no longer available. It looks like more and -- more functionality gets dropped so maybe at some point we need to ship our own dll/so --- files. For instance, I'd like to have access to the current filename etc. --- --- An increase in the number of built in styles made our own crash (probably due to some --- maximum being reached) so some measures has been taken. We now get pretty close to --- replacing the main lexer.lua file. --- --- Also needed: preamble scan once. Can be handled in caller below and _M.preamble. +-- files. For instance, I'd like to have access to the current filename and other scite +-- properties. For instance, we could cache some info with each file, if only we had +-- knowledge of what file we're dealing with. -- -- For huge files folding can be pretty slow and I do have some large ones that I keep -- open all the time. Loading is normally no ussue, unless one has remembered the status @@ -42,16 +30,32 @@ local info = { -- brought down loading of char-def.lua from 14 sec => 8 sec. Replacing the word_match -- function and optimizing the lex function gained another 2+ seconds. A 6 second load -- is quite ok for me. - +-- +-- When the lexer path is copied to the textadept lexer path, and the theme definition to +-- theme path (as lexer.lua), the lexer works there as well. When I have time and motive +-- I will make a proper setup file to tune the look and feel a bit and associate suffixes +-- with the context lexer. The textadept editor has a nice style tracing option but lacks +-- the tabs for selecting files that scite has. It also has no integrated run that pipes +-- to the log pane (I wonder if it could borrow code from the console2 project). Interesting +-- is that the jit version of textadept crashes on lexing large files (and does not feel +-- faster either). +-- -- Function load(lexer_name) starts with _M.WHITESPACE = lexer_name..'_whitespace' which -- means that we need to have it frozen at the moment we load another lexer. Because spacing -- is used to revert to a parent lexer we need to make sure that we load children as late -- as possible in order not to get the wrong whitespace trigger. This took me quite a while -- to figure out (not being that familiar with the internals). The lex and fold functions --- have been optimized. It is a pitty that there is no proper print available. - --- Maybe it's safer to copy the other methods here so that we have no dependencies, apart --- from the c library. We need to copy anyway as helpers are local +-- have been optimized. It is a pitty that there is no proper print available. Another thing +-- needed is a default style in ourown theme style definition, as otherwise we get wrong +-- nested lexers, especially if they are larger than a view. This is the hardest part of +-- getting things right. +-- +-- Eventually it might be safer to copy the other methods from lexer.lua here as well so +-- that we have no dependencies, apart from the c library (for which at some point the api +-- will be stable I guess). +-- +-- It's a pitty that there is no scintilua library for the OSX version of scite. Even +-- better would be to have scintilua as integral part of scite. local lpeg = require 'lpeg' diff --git a/context/data/scite/scite-context-data-context.properties b/context/data/scite/scite-context-data-context.properties index b5a4d1b1f..e2c1bb853 100644 --- a/context/data/scite/scite-context-data-context.properties +++ b/context/data/scite/scite-context-data-context.properties @@ -38,36 +38,36 @@ doifvaluenothing doifvaluesomething doifelsevaluenothing doifdimensionelse doifn doifcommonelse doifcommon doifnotcommon doifinstring doifnotinstring \ doifinstringelse doifassignmentelse tracingall tracingnone loggingall \ appendtoks prependtoks appendtotoks prependtotoks to \ -endgraf empty null space obeyspaces \ -obeylines normalspace executeifdefined singleexpandafter doubleexpandafter \ -tripleexpandafter dontleavehmode removelastspace removeunwantedspaces wait \ -writestatus define redefine setmeasure setemeasure \ -setgmeasure setxmeasure definemeasure measure getvalue \ -setvalue setevalue setgvalue setxvalue letvalue \ -letgvalue resetvalue undefinevalue ignorevalue setuvalue \ -setuevalue setugvalue setuxvalue globallet glet \ -getparameters geteparameters getgparameters getxparameters forgetparameters \ -processcommalist processcommacommand quitcommalist quitprevcommalist processaction \ -processallactions processfirstactioninset processallactionsinset unexpanded expanded \ -startexpanded stopexpanded protected protect unprotect \ -firstofoneargument firstoftwoarguments secondoftwoarguments firstofthreearguments secondofthreearguments \ -thirdofthreearguments firstoffourarguments secondoffourarguments thirdoffourarguments fourthoffourarguments \ -firstoffivearguments secondoffivearguments thirdoffivearguments fourthoffivearguments fifthoffivearguments \ -firstofsixarguments secondofsixarguments thirdofsixarguments fourthofsixarguments fifthofsixarguments \ -sixthofsixarguments firstofoneunexpanded gobbleoneargument gobbletwoarguments gobblethreearguments \ -gobblefourarguments gobblefivearguments gobblesixarguments gobblesevenarguments gobbleeightarguments \ -gobbleninearguments gobbletenarguments gobbleoneoptional gobbletwooptionals gobblethreeoptionals \ -gobblefouroptionals gobblefiveoptionals dorecurse doloop exitloop \ -dostepwiserecurse recurselevel recursedepth dofastloopcs newconstant \ -setnewconstant newconditional settrue setfalse setconstant \ -newmacro setnewmacro newfraction dosingleempty dodoubleempty \ -dotripleempty doquadrupleempty doquintupleempty dosixtupleempty doseventupleempty \ -dosingleargument dodoubleargument dotripleargument doquadrupleargument dosinglegroupempty \ -dodoublegroupempty dotriplegroupempty doquadruplegroupempty doquintuplegroupempty nopdfcompression \ -maximumpdfcompression normalpdfcompression modulonumber dividenumber getfirstcharacter \ -doiffirstcharelse startnointerference stopnointerference strut setstrut \ -strutbox strutht strutdp strutwd begstrut \ -endstrut +endgraf empty null space quad \ +enspace obeyspaces obeylines normalspace executeifdefined \ +singleexpandafter doubleexpandafter tripleexpandafter dontleavehmode removelastspace \ +removeunwantedspaces wait writestatus define redefine \ +setmeasure setemeasure setgmeasure setxmeasure definemeasure \ +measure getvalue setvalue setevalue setgvalue \ +setxvalue letvalue letgvalue resetvalue undefinevalue \ +ignorevalue setuvalue setuevalue setugvalue setuxvalue \ +globallet glet getparameters geteparameters getgparameters \ +getxparameters forgetparameters processcommalist processcommacommand quitcommalist \ +quitprevcommalist processaction processallactions processfirstactioninset processallactionsinset \ +unexpanded expanded startexpanded stopexpanded protected \ +protect unprotect firstofoneargument firstoftwoarguments secondoftwoarguments \ +firstofthreearguments secondofthreearguments thirdofthreearguments firstoffourarguments secondoffourarguments \ +thirdoffourarguments fourthoffourarguments firstoffivearguments secondoffivearguments thirdoffivearguments \ +fourthoffivearguments fifthoffivearguments firstofsixarguments secondofsixarguments thirdofsixarguments \ +fourthofsixarguments fifthofsixarguments sixthofsixarguments firstofoneunexpanded gobbleoneargument \ +gobbletwoarguments gobblethreearguments gobblefourarguments gobblefivearguments gobblesixarguments \ +gobblesevenarguments gobbleeightarguments gobbleninearguments gobbletenarguments gobbleoneoptional \ +gobbletwooptionals gobblethreeoptionals gobblefouroptionals gobblefiveoptionals dorecurse \ +doloop exitloop dostepwiserecurse recurselevel recursedepth \ +dofastloopcs newconstant setnewconstant newconditional settrue \ +setfalse setconstant newmacro setnewmacro newfraction \ +dosingleempty dodoubleempty dotripleempty doquadrupleempty doquintupleempty \ +dosixtupleempty doseventupleempty dosingleargument dodoubleargument dotripleargument \ +doquadrupleargument dosinglegroupempty dodoublegroupempty dotriplegroupempty doquadruplegroupempty \ +doquintuplegroupempty nopdfcompression maximumpdfcompression normalpdfcompression modulonumber \ +dividenumber getfirstcharacter doiffirstcharelse startnointerference stopnointerference \ +strut setstrut strutbox strutht strutdp \ +strutwd begstrut endstrut keywordclass.context.constants=\ zerocount minusone minustwo plusone \ diff --git a/context/data/scite/scite-ctx.lua b/context/data/scite/scite-ctx.lua index 9f3526dc3..3557994f3 100644 --- a/context/data/scite/scite-ctx.lua +++ b/context/data/scite/scite-ctx.lua @@ -80,8 +80,6 @@ function traceln(str) io.flush() end --- require "lpeg" - function string.grab(str,delimiter) local list = { } for snippet in gmatch(str,delimiter) do @@ -518,7 +516,7 @@ local worddone = 0 -- end -- end -function check_text() +function check_text() -- obsolete, replaced by lexer local dlanguage = props["ctx.spellcheck.language"] local dwordsize = props["ctx.spellcheck.wordsize"] @@ -838,3 +836,15 @@ menufunctions[14] = process_template_two function open_log() scite.Open(props['FileName'] .. ".log") end + +if not lpeg then + + local okay, root = pcall(function() return require "lpeg" end) + + if okay then + lpeg = root + else + trace("\nwarning: lpeg not loaded\n") + end + +end -- cgit v1.2.3