diff options
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/piton/piton.lua')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/piton/piton.lua | 73 |
1 files changed, 50 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/lualatex/piton/piton.lua b/Master/texmf-dist/tex/lualatex/piton/piton.lua index f909eef28a3..6ec0442b73c 100644 --- a/Master/texmf-dist/tex/lualatex/piton/piton.lua +++ b/Master/texmf-dist/tex/lualatex/piton/piton.lua @@ -20,7 +20,8 @@ -- ------------------------------------------- -- -- This file is part of the LuaLaTeX package 'piton'. -piton_version = "3.0a" -- 2024/05/12 +piton_version = "3.0b" -- 2024/05/23 + if piton.comment_latex == nil then piton.comment_latex = ">" end @@ -101,10 +102,21 @@ local Number = ) local Word if piton.begin_escape then - Word = Q ( ( 1 - space - piton.begin_escape - piton.end_escape - - S "'\"\r[({})]" - digit ) ^ 1 ) + if piton.begin_escape_math then + Word = Q ( ( 1 - space - piton.begin_escape - piton.end_escape + - piton.begin_escape_math - piton.end_escape_math + - S "'\"\r[({})]" - digit ) ^ 1 ) + else + Word = Q ( ( 1 - space - piton.begin_escape - piton.end_escape + - S "'\"\r[({})]" - digit ) ^ 1 ) + end else - Word = Q ( ( 1 - space - S "'\"\r[({})]" - digit ) ^ 1 ) + if piton.begin_escape_math then + Word = Q ( ( 1 - space - piton.begin_escape_math - piton.end_escape_math + - S "'\"\r[({})]" - digit ) ^ 1 ) + else + Word = Q ( ( 1 - space - S "'\"\r[({})]" - digit ) ^ 1 ) + end end local Space = Q " " ^ 1 @@ -494,7 +506,7 @@ local DefFunction = * ( EOL + CommentLaTeX + Comment ) -- in all cases, that contains an EOL * Tab ^ 0 * SkipSpace - * StringDoc ^ 0 -- there may be additionnal docstrings + * StringDoc ^ 0 -- there may be additional docstrings ) ^ -1 local ExceptionInConsole = Exception * Q ( ( 1 - P "\r" ) ^ 0 ) * EOL local Main = @@ -1310,14 +1322,21 @@ end function piton.new_language ( lang , definition ) lang = string.lower ( lang ) local alpha , digit = lpeg.alpha , lpeg.digit - local letter = alpha + S "@_$" -- $ - local other = S "+-*/<>!?:;.()@[]~^=#&\"\'\\$" -- $ + local extra_letters = { "@" , "_" , "$" } -- $ function add_to_letter ( c ) - if c ~= " " then letter = letter + c end + if c ~= " " then table.insert ( extra_letters , c ) end end function add_to_digit ( c ) if c ~= " " then digit = digit + c end end + local other = S ":_@+-*/<>!?;.()[]~^=#&\"\'\\$" -- $ + local extra_others = { } + function add_to_other ( c ) + if c ~= " " then + extra_others[c] = true + other = other + P "c" + end + end local strict_braces = P { "E" , E = ( "{" * V "F" * "}" + ( 1 - S ",{}" ) ) ^ 0 , @@ -1368,6 +1387,7 @@ function piton.new_language ( lang , definition ) end if x[1] == "alsodigit" then x[2] : gsub ( "." , add_to_digit ) end if x[1] == "alsoletter" then x[2] : gsub ( "." , add_to_letter ) end + if x[1] == "alsoother" then x[2] : gsub ( "." , add_to_other ) end if x[1] == "tag" then style_tag , left_tag , right_tag = args_for_tag : match ( x[2] ) style_tag = style_tag or [[\PitonStyle{Tag}]] @@ -1381,6 +1401,16 @@ function piton.new_language ( lang , definition ) * ( S "eE" * S "+-" ^ -1 * digit ^ 1 ) ^ -1 + digit ^ 1 ) + local string_extra_letters = "" + for _ , x in ipairs ( extra_letters ) do + if not ( extra_others[x] ) then + string_extra_letters = string_extra_letters .. x + end + end + local letter = alpha + S ( string_extra_letters ) + + P "â" + "à" + "ç" + "é" + "è" + "ê" + "ë" + "ï" + "î" + + "ô" + "û" + "ü" + "Â" + "À" + "Ç" + "É" + "È" + "Ê" + "Ë" + + "Ï" + "Î" + "Ô" + "Û" + "Ü" local alphanum = letter + digit local identifier = letter * alphanum ^ 0 local Identifier = K ( 'Identifier' , identifier ) @@ -1401,6 +1431,7 @@ function piton.new_language ( lang , definition ) ) end local Keyword = P ( false ) + local PrefixedKeyword = P ( false ) for _ , x in ipairs ( def_table ) do if x[1] == "morekeywords" or x[1] == "otherkeywords" @@ -1430,7 +1461,8 @@ function piton.new_language ( lang , definition ) end if x[1] == "keywordsprefix" then local prefix = ( ( C ( 1 - P " " ) ^ 1 ) * P " " ^ 0 ) : match ( x[2] ) - Keyword = Keyword + K ( 'Keyword' , P ( prefix ) * alphanum ^ 0 ) + PrefixedKeyword = PrefixedKeyword + + K ( 'Keyword' , P ( prefix ) * ( letter ^ 1 + other ) ) end end local long_string = P ( false ) @@ -1578,7 +1610,8 @@ function piton.new_language ( lang , definition ) + CommentDelim + LongString + Delim - + Keyword * ( Space + Punct + Delim + EOL + -1 ) + + PrefixedKeyword + + Keyword * ( -1 + # ( 1 - alphanum ) ) + Punct + K ( 'Identifier' , letter * alphanum ^ 0 ) + Number @@ -1596,7 +1629,7 @@ function piton.new_language ( lang , definition ) ) if left_tag then local Tag = Ct ( Cc "Open" * Cc ( "{" .. style_tag .. "{" ) * Cc "}}" ) - * Q ( left_tag * other ^ 0 ) + * Q ( left_tag * other ^ 0 ) -- $ * ( ( ( 1 - P ( right_tag ) ) ^ 0 ) / ( function ( x ) return LPEG0[lang] : match ( x ) end ) ) * Q ( right_tag ) @@ -1613,27 +1646,21 @@ function piton.new_language ( lang , definition ) + CommentDelim + Delim + LongString - + Keyword * ( Space + Punct + Delim + EOL + -1 ) + + PrefixedKeyword + + Keyword * ( -1 + # ( 1 - alphanum ) ) + Punct + K ( 'Identifier' , letter * alphanum ^ 0 ) + Number + Word LPEG0[lang] = MainWithoutTag ^ 0 + local LPEGaux = Tab + Escape + EscapeMath + CommentLaTeX + + Beamer + DetectedCommands + CommentDelim + Tag MainWithTag = space ^ 1 * -1 + space ^ 0 * EOL + Space - + Tab - + Escape + EscapeMath - + CommentLaTeX - + Beamer - + DetectedCommands - + CommentDelim - + Tag - + Delim - + Punct - + K ( 'Identifier' , letter * alphanum ^ 0 ) - + Word + + LPEGaux + + Q ( ( 1 - EOL - LPEGaux ) ^ 1 ) LPEG1[lang] = MainWithTag ^ 0 LPEG2[lang] = Ct ( |