diff options
author | Norbert Preining <norbert@preining.info> | 2022-09-20 03:01:38 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-09-20 03:01:38 +0000 |
commit | 7907f67d07d36a7e20421a1ec3a0eceecac4aacd (patch) | |
tree | 7aae41d00037cc944480cecfa75b88048a672970 /macros/luatex/latex/piton/piton.lua | |
parent | fe872ca5d5d1bb989da6b31802b8e0bfb0342e45 (diff) |
CTAN sync 202209200301
Diffstat (limited to 'macros/luatex/latex/piton/piton.lua')
-rw-r--r-- | macros/luatex/latex/piton/piton.lua | 80 |
1 files changed, 50 insertions, 30 deletions
diff --git a/macros/luatex/latex/piton/piton.lua b/macros/luatex/latex/piton/piton.lua index 8ef48f45b1..2860246c4c 100644 --- a/macros/luatex/latex/piton/piton.lua +++ b/macros/luatex/latex/piton/piton.lua @@ -14,7 +14,7 @@ -- Latex version 2005/12/01 or later. --- This file is part of the version 0.55 of the package 'piton' +-- This file is part of the version 0.6a of the package 'piton' local P, S, V , C , Ct, Cc, Cf = lpeg.P, lpeg.S, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cf @@ -315,7 +315,7 @@ local Comment = L ( "{\\pitonStyleComment {" ) local CommentLaTeX = P "##" - * L "{\\PitonStyle{Comment.LaTeX}{" + * L "{\\PitonStyle{Comment.LaTeX}{\\ignorespaces" * Ct ( C ( ( 1 - P "\r" ) ^ 0 ) ) * L "}}" * ( EOL + -1 ) @@ -347,32 +347,32 @@ local Operator = K ( P "!=" + P "==" + P "<<" + P ">>" + S "-~+/*%=<>&.@|" , 'Op local OperatorWord = K ( P "in" + P "is" + P "and" + P "or" + P "not" , 'Operator.Word') local SyntaxPython = - ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 * space ^ -1 * - ( ( space^1 * -1 ) - + EOL - + Space - + Escape - + CommentLaTeX - + LongString - + Comment - + ExceptionInConsole - + Set - + Delim - + Class * ( Space + Punct + EOL ) - + Namespace * ( Space + Punct + EOL ) - + ImportAs - + RaiseException - + Keyword * ( Space + Punct + EOL ) - + DefFunction - + ShortString - + Decorator * ( Space + Punct + EOL ) - + Operator - + OperatorWord * ( Space + Punct + EOL ) - + Builtin * ( Space + Punct + EOL ) - + Identifier - + Number - + Word - ) ^0 * -1 + ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 * + ( ( space^1 * -1 ) + + EOL + + Space + + Escape + + CommentLaTeX + + LongString + + Comment + + ExceptionInConsole + + Set + + Delim + + Class * ( Space + Punct + EOL ) + + Namespace * ( Space + Punct + EOL ) + + ImportAs + + RaiseException + + Keyword * ( Space + Punct + EOL ) + + DefFunction + + ShortString + + Decorator * ( Space + Punct + EOL ) + + Operator + + OperatorWord * ( Space + Punct + EOL ) + + Builtin * ( Space + Punct + EOL ) + + Identifier + + Number + + Word + ) ^0 * -1 local MinimalSyntax = @@ -397,6 +397,9 @@ function Parse(code) end end + + + function ParseFile(name) s = '' for line in io.lines(name) do s = s .. '\r' .. line end @@ -449,8 +452,7 @@ AutoGobbleSyntax = ( Cf ( Cc(0) * ( P " " * Cc(1) ) ^ 0 , add ) * ( 1 - P " " ) * ( 1 - P "\r" ) ^ 0 ) ^ -1 , min - ) - + ) function AutoGobbleParse(code) local n = AutoGobbleSyntax:match(code) @@ -462,6 +464,24 @@ function AutoGobbleParse(code) end +--[[ The following LPEG returns as capture the number of spaces at the last line, +that is to say begin the \end{Piton} ]] + +EnvGobbleSyntax = + ( ( 1 - P "\r" ) ^ 0 * P "\r" ) ^ 0 + * Cf ( Cc(0) * ( P " " * Cc(1) ) ^ 0 , add ) * -1 + +function EnvGobbleParse(code) + local n = EnvGobbleSyntax:match(code) + if n==0 + then Parse(code) + else define_gobble_syntax(n) + GobbleParse(code) + end +end + + + |