Commit 592bc036 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- LaTeX.ebnf slightly extended; need a test-suite first

parent 41357b5f
# latex Grammar
@ whitespace = /[ \t]*\n?(?!\s*\n)[ \t]*/
@ whitespace = /[ \t]*\n?(?!\s*\n)[ \t]*/ # whitespace, including at most one linefeed
@ comment = /%.*(?:\n|$)/
genericenv = beginenv sequence endenv
latexdoc = preamble document
preamble = { command }+
genericenv = beginenv sequence §endenv
beginenv = "\begin" §( "{" name "}" )
endenv = "\end" §( "{" ::name "}" )
name = ~/\w+/
name = /\w+/~
genericcmd = command [ config ] block
command = /\\\w+/
comand = cmdname [ config ] block
cmdname = /\\\w+/
config = "[" cfgtext §"]"
sequence = { partext | parblock }
......@@ -18,16 +21,16 @@ sequence = { partext | parblock }
parblock = "{" { partext | parblock } §"}"
block = "{" { text | block } §"}"
partext = text | par
partext = text | PARSEP
text = cfgtext | brackets
cfgtext = chunk | wspc | escaped
cfgtext = chunk | escaped | WSPC
escaped = /\\[%$&]/
brackets = /[\[\]]/ # left and right square brackets: [ ]
chunk = /[^\\%$&\{\}\[\]\s\n]+/ # some piece of text excluding whitespace,
# linefeed and special characters
wspc = /[ \t]*\n?(?!\s*\n)[ \t]*/ # whitespace, including at most one linefeed
lf = /[ \t]*\n(?!\s*\n)/ # a linefeed, but not an empty line (i.e. par)
par = /\s*\n\s*\n/ # at least one empty line, i.e.
WSPC = /[ \t]*\n?(?!\s*\n)[ \t]*/ # whitespace, including at most one linefeed
LF = /[ \t]*\n(?!\s*\n)/ # a linefeed, but not an empty line (i.e. par)
PARSEP = /\s*\n\s*\n/ # at least one empty line, i.e.
# [whitespace] linefeed [whitespace] linefeed
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment