| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821 |
- // Track environments
- @context elementContext from "./tokens.mjs"
- // External tokens must be defined before normal @tokens to take precedence
- // over them.
- @external tokens verbTokenizer from "./tokens.mjs" {
- VerbContent
- }
- @external tokens lstinlineTokenizer from "./tokens.mjs" {
- LstInlineContent
- }
- @external tokens literalArgTokenizer from "./tokens.mjs" {
- LiteralArgContent
- }
- @external tokens spaceDelimitedLiteralArgTokenizer from "./tokens.mjs" {
- SpaceDelimitedLiteralArgContent
- }
- @external tokens verbatimTokenizer from "./tokens.mjs" {
- VerbatimContent
- }
- // external tokenizer to read control sequence names including @ signs
- // (which are often used in TeX definitions).
- @external tokens csnameTokenizer from "./tokens.mjs" {
- Csname
- }
- @external tokens trailingContentTokenizer from "./tokens.mjs" {
- TrailingWhitespaceOnly,
- TrailingContent
- }
- // It doesn't seem to be possible to access specialized tokens in the context tracker.
- // They have id's which are not exported in the latex.terms.js file.
- // This is a workaround: use an external specializer to explicitly choose the terms
- // to use for the specialized tokens.
- @external specialize {CtrlSeq} specializeCtrlSeq from "./tokens.mjs" {
- Begin,
- End,
- RefCtrlSeq,
- RefStarrableCtrlSeq,
- CiteCtrlSeq,
- CiteStarrableCtrlSeq,
- LabelCtrlSeq,
- MathTextCtrlSeq,
- HboxCtrlSeq,
- TitleCtrlSeq,
- DocumentClassCtrlSeq,
- UsePackageCtrlSeq,
- HrefCtrlSeq,
- UrlCtrlSeq,
- VerbCtrlSeq,
- LstInlineCtrlSeq,
- IncludeGraphicsCtrlSeq,
- CaptionCtrlSeq,
- DefCtrlSeq,
- LetCtrlSeq,
- LeftCtrlSeq,
- RightCtrlSeq,
- NewCommandCtrlSeq,
- RenewCommandCtrlSeq,
- NewEnvironmentCtrlSeq,
- RenewEnvironmentCtrlSeq,
- // services/web/frontend/js/features/outline/outline-parser.js
- BookCtrlSeq,
- PartCtrlSeq,
- ChapterCtrlSeq,
- SectionCtrlSeq,
- SubSectionCtrlSeq,
- SubSubSectionCtrlSeq,
- ParagraphCtrlSeq,
- SubParagraphCtrlSeq,
- InputCtrlSeq,
- IncludeCtrlSeq,
- ItemCtrlSeq,
- NewTheoremCtrlSeq,
- TheoremStyleCtrlSeq,
- CenteringCtrlSeq,
- BibliographyCtrlSeq,
- BibliographyStyleCtrlSeq,
- AuthorCtrlSeq,
- AffilCtrlSeq,
- AffiliationCtrlSeq,
- MaketitleCtrlSeq,
- TextColorCtrlSeq,
- ColorBoxCtrlSeq,
- HLineCtrlSeq,
- TopRuleCtrlSeq,
- MidRuleCtrlSeq,
- BottomRuleCtrlSeq,
- MultiColumnCtrlSeq,
- ParBoxCtrlSeq,
- TextBoldCtrlSeq,
- TextItalicCtrlSeq,
- TextSmallCapsCtrlSeq,
- TextTeletypeCtrlSeq,
- TextMediumCtrlSeq,
- TextSansSerifCtrlSeq,
- TextSuperscriptCtrlSeq,
- TextSubscriptCtrlSeq,
- TextStrikeOutCtrlSeq,
- EmphasisCtrlSeq,
- UnderlineCtrlSeq
- }
- @external specialize {EnvName} specializeEnvName from "./tokens.mjs" {
- DocumentEnvName,
- TabularEnvName,
- EquationEnvName,
- EquationArrayEnvName,
- VerbatimEnvName,
- TikzPictureEnvName,
- FigureEnvName,
- ListEnvName,
- TableEnvName
- }
- @external specialize {CtrlSym} specializeCtrlSym from "./tokens.mjs" {
- OpenParenCtrlSym,
- CloseParenCtrlSym,
- OpenBracketCtrlSym,
- CloseBracketCtrlSym,
- LineBreakCtrlSym
- }
- @tokens {
- CtrlSeq { "\\" $[a-zA-Z]+ }
- CtrlSym { "\\" ![a-zA-Z] }
- // tokens for paragraphs
- Whitespace { $[ \t]+ }
- NewLine { "\n" }
- BlankLine { "\n" "\n"+ }
- Normal { ![\\{}\[\]$&~#^_% \t\n] ![\\{}\[\]$&~#^_%\t\n]* } // everything is normal text, except these characters
- @precedence { CtrlSeq, CtrlSym, BlankLine, NewLine, Whitespace, Normal }
- OpenBrace[closedBy=CloseBrace] { "{" }
- CloseBrace[openedBy=OpenBrace] { "}" }
- OpenBracket[closedBy=CloseBracket] { "[" }
- CloseBracket[openedBy=OpenBracket] { "]" }
- Comment { "%" ![\n]* "\n"? }
- Dollar { "$" }
- Number { $[0-9]+ ("." $[0-9]*)? }
- MathSpecialChar { $[^_=<>()\-+/*]+ } // FIXME not all of these are special
- MathChar { ![0-9^_=<>()\-+/*\\{}\[\]$%&~ \t\n]+ }
- @precedence { Number, MathSpecialChar, MathChar }
- Ampersand { "&" }
- Tilde { "~" }
- EnvName { $[a-zA-Z]+ $[*]? }
- }
- @top LaTeX {
- Text
- }
- @skip { Comment }
- // TEXT MODE
- optionalWhitespace {
- !argument Whitespace
- }
- OptionalArgument {
- !argument OpenBracket ShortOptionalArg CloseBracket
- }
- TextArgument {
- !argument OpenBrace LongArg CloseBrace
- }
- SectioningArgument {
- !argument OpenBrace LongArg CloseBrace
- }
- LabelArgument {
- !argument ShortTextArgument
- }
- RefArgument {
- !argument ShortTextArgument
- }
- BibKeyArgument {
- !argument ShortTextArgument
- }
- PackageArgument {
- !argument ShortTextArgument
- }
- TabularArgument {
- !argument OpenBrace TabularContent CloseBrace
- }
- UrlArgument {
- OpenBrace LiteralArgContent CloseBrace
- }
- FilePathArgument {
- OpenBrace LiteralArgContent CloseBrace
- }
- BareFilePathArgument {
- Whitespace SpaceDelimitedLiteralArgContent
- }
- DefinitionArgument {
- !argument NewLine? Whitespace* OpenBrace DefinitionFragment? CloseBrace
- }
- MacroParameter {
- "#" ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9")
- }
- OptionalMacroParameter {
- OpenBracket MacroParameter CloseBracket
- }
- // The autocompletion code in services/web/frontend/js/features/source-editor/utils/tree-operations/commands.ts
- // depends on following the `KnownCommand { Command { CommandCtrlSeq [args] } }`
- // structure
- KnownCommand<ArgumentType> {
- Title {
- TitleCtrlSeq optionalWhitespace? OptionalArgument? TextArgument
- } |
- Author {
- AuthorCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
- } |
- Affil {
- AffilCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
- } |
- Affiliation {
- AffiliationCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
- } |
- DocumentClass {
- DocumentClassCtrlSeq optionalWhitespace? OptionalArgument?
- DocumentClassArgument { ShortTextArgument }
- } |
- BibliographyCommand {
- BibliographyCtrlSeq optionalWhitespace?
- BibliographyArgument { ShortTextArgument }
- } |
- BibliographyStyleCommand {
- BibliographyStyleCtrlSeq optionalWhitespace?
- BibliographyStyleArgument { ShortTextArgument }
- } |
- UsePackage {
- UsePackageCtrlSeq optionalWhitespace? OptionalArgument?
- PackageArgument
- } |
- TextColorCommand {
- TextColorCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? ArgumentType
- } |
- ColorBoxCommand {
- ColorBoxCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? ArgumentType
- } |
- HrefCommand {
- HrefCtrlSeq optionalWhitespace? UrlArgument ShortTextArgument
- } |
- NewTheoremCommand {
- NewTheoremCtrlSeq "*"? optionalWhitespace? ShortTextArgument ((OptionalArgument? TextArgument) | (TextArgument OptionalArgument))
- } |
- TheoremStyleCommand {
- TheoremStyleCtrlSeq optionalWhitespace? ShortTextArgument
- } |
- UrlCommand {
- UrlCtrlSeq optionalWhitespace? UrlArgument
- } |
- VerbCommand {
- VerbCtrlSeq VerbContent
- } |
- LstInlineCommand {
- LstInlineCtrlSeq optionalWhitespace? OptionalArgument? LstInlineContent
- } |
- IncludeGraphics {
- IncludeGraphicsCtrlSeq optionalWhitespace? OptionalArgument?
- IncludeGraphicsArgument { FilePathArgument }
- } |
- Caption {
- CaptionCtrlSeq "*"? optionalWhitespace? OptionalArgument? TextArgument
- } |
- Label {
- LabelCtrlSeq optionalWhitespace? LabelArgument
- } |
- Ref {
- (RefCtrlSeq | RefStarrableCtrlSeq "*"?) optionalWhitespace? OptionalArgument? optionalWhitespace? OptionalArgument? optionalWhitespace? RefArgument
- } |
- Cite {
- (CiteCtrlSeq | CiteStarrableCtrlSeq "*"?) optionalWhitespace? OptionalArgument? optionalWhitespace? OptionalArgument? optionalWhitespace? BibKeyArgument
- } |
- Def {
- // allow more general Csname argument to \def commands, since other symbols such as '@' are often used in definitions
- DefCtrlSeq optionalWhitespace? (Csname | CtrlSym) optionalWhitespace? (MacroParameter | OptionalMacroParameter)* optionalWhitespace? DefinitionArgument
- } |
- Let {
- LetCtrlSeq Csname optionalWhitespace? "="? optionalWhitespace? Csname
- } |
- Hbox {
- HboxCtrlSeq optionalWhitespace? TextArgument
- } |
- NewCommand {
- NewCommandCtrlSeq optionalWhitespace?
- (Csname | OpenBrace LiteralArgContent CloseBrace)
- (OptionalArgument)*
- DefinitionArgument
- } |
- RenewCommand {
- RenewCommandCtrlSeq optionalWhitespace?
- (Csname | OpenBrace LiteralArgContent CloseBrace)
- (OptionalArgument)*
- DefinitionArgument
- } |
- NewEnvironment {
- NewEnvironmentCtrlSeq optionalWhitespace?
- (OpenBrace LiteralArgContent CloseBrace)
- (OptionalArgument)*
- DefinitionArgument
- DefinitionArgument
- } |
- RenewEnvironment {
- RenewEnvironmentCtrlSeq optionalWhitespace?
- (Csname | OpenBrace LiteralArgContent CloseBrace)
- (OptionalArgument)*
- DefinitionArgument
- DefinitionArgument
- } |
- Input {
- InputCtrlSeq InputArgument { ( FilePathArgument | BareFilePathArgument ) }
- } |
- Include {
- IncludeCtrlSeq IncludeArgument { FilePathArgument }
- } |
- Centering {
- CenteringCtrlSeq
- } |
- Item {
- ItemCtrlSeq OptionalArgument? optionalWhitespace?
- } |
- Maketitle {
- MaketitleCtrlSeq optionalWhitespace?
- } |
- HorizontalLine {
- (HLineCtrlSeq | TopRuleCtrlSeq | MidRuleCtrlSeq | BottomRuleCtrlSeq) optionalWhitespace?
- } |
- MultiColumn {
- MultiColumnCtrlSeq
- optionalWhitespace? SpanArgument { ShortTextArgument }
- optionalWhitespace? ColumnArgument { ShortTextArgument }
- optionalWhitespace? TabularArgument
- } |
- MathTextCommand {
- MathTextCtrlSeq optionalWhitespace? "*"? TextArgument
- } |
- ParBoxCommand {
- ParBoxCtrlSeq
- (optionalWhitespace? OptionalArgument)*
- ShortTextArgument
- optionalWhitespace? TextArgument
- } |
- TextBoldCommand {
- TextBoldCtrlSeq TextArgument
- } |
- TextItalicCommand {
- TextItalicCtrlSeq TextArgument
- } |
- TextSmallCapsCommand {
- TextSmallCapsCtrlSeq TextArgument
- } |
- TextTeletypeCommand {
- TextTeletypeCtrlSeq TextArgument
- } |
- TextMediumCommand {
- TextMediumCtrlSeq TextArgument
- } |
- TextSansSerifCommand {
- TextSansSerifCtrlSeq TextArgument
- } |
- TextSuperscriptCommand {
- TextSuperscriptCtrlSeq TextArgument
- } |
- TextSubscriptCommand {
- TextSubscriptCtrlSeq TextArgument
- } |
- StrikeOutCommand {
- TextStrikeOutCtrlSeq ArgumentType
- } |
- EmphasisCommand {
- EmphasisCtrlSeq ArgumentType
- } |
- UnderlineCommand {
- UnderlineCtrlSeq ArgumentType
- }
- }
- UnknownCommand {
- (CtrlSeq !argument Whitespace (OptionalArgument | TextArgument)+)
- | (CtrlSeq (OptionalArgument | TextArgument)+)
- | CtrlSeq Whitespace?
- | CtrlSym
- }
- Command {
- KnownCommand<TextArgument>
- | UnknownCommand
- | KnownCtrlSym
- // Not technically allowed in normal mode, but not worth failing the parse over
- | LeftCtrlSeq
- | RightCtrlSeq
- }
- KnownCtrlSym {
- LineBreak {
- LineBreakCtrlSym OptionalArgument?
- }
- }
- textBase {
- ( Command
- | DollarMath
- | BracketMath
- | ParenMath
- | NewLine
- | Normal
- | Whitespace
- | Ampersand
- | Tilde
- )
- }
- textWithBrackets {
- ( textBase
- | OpenBracket
- | CloseBracket
- )
- }
- textWithEnvironmentsAndBlankLines {
- ( BlankLine
- | KnownEnvironment
- | Environment
- | textWithBrackets
- )
- }
- textWithGroupsEnvironmentsAndBlankLines {
- textWithEnvironmentsAndBlankLines
- | Group<Text>
- }
- Content<Element> {
- Element
- }
- SectioningCommand<Command> {
- Command optionalWhitespace? "*"? optionalWhitespace? OptionalArgument? optionalWhitespace? SectioningArgument
- }
- documentSection<Command, Next> {
- SectioningCommand<Command> Content<(sectionText | !section Next)*>
- }
- Book[@isGroup="$SectioningCommand"] { documentSection<BookCtrlSeq, Part | Chapter | Section | SubSection | SubSubSection | Paragraph | SubParagraph> }
- Part[@isGroup="$SectioningCommand"] { documentSection<PartCtrlSeq, Chapter | Section | SubSection | SubSubSection | Paragraph | SubParagraph> }
- Chapter[@isGroup="$SectioningCommand"] { documentSection<ChapterCtrlSeq, Section | SubSection | SubSubSection | Paragraph | SubParagraph> }
- Section[@isGroup="$SectioningCommand"] { documentSection<SectionCtrlSeq, SubSection | SubSubSection | Paragraph | SubParagraph> }
- SubSection[@isGroup="$SectioningCommand"] { documentSection<SubSectionCtrlSeq, SubSubSection | Paragraph | SubParagraph> }
- SubSubSection[@isGroup="$SectioningCommand"] { documentSection<SubSubSectionCtrlSeq, Paragraph | SubParagraph> }
- Paragraph[@isGroup="$SectioningCommand"] { documentSection<ParagraphCtrlSeq, SubParagraph> }
- SubParagraph[@isGroup="$SectioningCommand"] { SectioningCommand<SubParagraphCtrlSeq> Content<sectionText*> }
- sectioningCommand {
- Book | Part | Chapter | Section | SubSection | SubSubSection | Paragraph | SubParagraph
- }
- sectionText {
- !section (
- textWithGroupsEnvironmentsAndBlankLines
- )+
- }
- Text {
- ( sectionText
- | sectioningCommand)+
- }
- LongArg {
- ( textWithBrackets
- | NonEmptyGroup<LongArg>
- | KnownEnvironment
- | Environment
- | BlankLine
- | "#" // macro character
- | "_" | "^" // other math chars
- )*
- }
- ShortTextArgument {
- OpenBrace ShortArg CloseBrace
- }
- ShortArg {
- ( textWithBrackets
- | NonEmptyGroup<ShortArg>
- | "#" // macro character
- | "_" | "^" // other math chars
- )*
- }
- ShortOptionalArg {
- ( textBase
- | NonEmptyGroup<ShortOptionalArg>
- | "#" // macro character
- | "_" // underscore is used in some parameter names
- )*
- }
- TikzPictureContent { /// same as Text but with added allowed characters
- ( textWithEnvironmentsAndBlankLines
- | NonEmptyGroup<TikzPictureContent>
- | "#" // macro character
- | "_" | "^" // other math chars
- )+
- }
- DefinitionFragment {
- ( DefinitionFragmentCommand
- | Begin
- | End
- | Group<DefinitionFragment>
- | Dollar
- | OpenParenCtrlSym
- | CloseParenCtrlSym
- | OpenBracketCtrlSym
- | CloseBracketCtrlSym
- | LeftCtrlSeq
- | RightCtrlSeq
- | BlankLine
- | NewLine
- | Normal
- | Whitespace
- | OpenBracket
- | CloseBracket
- | "#" // macro character
- | Ampersand // for tables
- | Tilde // unbreakable space
- | "_" | "^" // other math chars
- | SectioningCommand<
- BookCtrlSeq |
- PartCtrlSeq |
- ChapterCtrlSeq |
- SectionCtrlSeq |
- SubSectionCtrlSeq |
- SubSubSectionCtrlSeq |
- ParagraphCtrlSeq |
- SubParagraphCtrlSeq
- >
- )+
- }
- DefinitionFragmentArgument {
- OpenBrace DefinitionFragment? CloseBrace
- }
- DefinitionFragmentCommand {
- KnownCommand<TextArgument>
- | DefinitionFragmentUnknownCommand { genericUnknownCommandWithOptionalArguments<DefinitionFragmentArgument, OptionalArgument> }
- | KnownCtrlSym
- }
- KnownEnvironment {
- ( DocumentEnvironment
- | TabularEnvironment
- | EquationEnvironment
- | EquationArrayEnvironment
- | VerbatimEnvironment
- | TikzPictureEnvironment
- | FigureEnvironment
- | ListEnvironment
- | TableEnvironment
- )
- }
- BeginEnv<name> {
- Begin
- EnvNameGroup<name>
- OptionalArgument?
- (!argument TextArgument)*
- }
- EndEnv<name> {
- End
- EnvNameGroup<name>
- }
- DocumentEnvironment[@isGroup="$Environment"] {
- BeginEnv<DocumentEnvName>
- Content<Text>
- EndEnv<DocumentEnvName>
- (TrailingWhitespaceOnly | TrailingContent)?
- }
- TabularContent {
- (textWithGroupsEnvironmentsAndBlankLines)*
- }
- TabularEnvironment[@isGroup="$Environment"] {
- BeginEnv<TabularEnvName>
- Content<TabularContent>
- EndEnv<TabularEnvName>
- }
- TableEnvironment[@isGroup="$Environment"] {
- BeginEnv<TableEnvName>
- Content<Text>
- EndEnv<TableEnvName>
- }
- EquationEnvironment[@isGroup="$Environment"] {
- BeginEnv<EquationEnvName>
- Content<Math?>
- EndEnv<EquationEnvName>
- }
- EquationArrayEnvironment[@isGroup="$Environment"] {
- BeginEnv<EquationArrayEnvName>
- Content<Math?>
- EndEnv<EquationArrayEnvName>
- }
- VerbatimEnvironment[@isGroup="$Environment"] {
- BeginEnv<VerbatimEnvName>
- Content<VerbatimContent>
- EndEnv<VerbatimEnvName>
- }
- TikzPictureEnvironment[@isGroup="$Environment"] {
- BeginEnv<TikzPictureEnvName>
- Content<TikzPictureContent>
- EndEnv<TikzPictureEnvName>
- }
- FigureEnvironment[@isGroup="$Environment"] {
- BeginEnv<FigureEnvName>
- Content<Text>
- EndEnv<FigureEnvName>
- }
- ListEnvironment[@isGroup="$Environment"] {
- BeginEnv<ListEnvName>
- Content<Text>
- EndEnv<ListEnvName>
- }
- EnvNameGroup<name> {
- OpenBrace name CloseBrace
- }
- Environment[@isGroup="$Environment"] {
- BeginEnv<EnvName?>
- Content<Text>
- EndEnv<EnvName?>
- }
- Group<GroupContent> {
- OpenBrace GroupContent? CloseBrace
- }
- NonEmptyGroup<GroupContent> {
- OpenBrace GroupContent CloseBrace
- }
- /// MATH MODE
- DollarMath {
- Dollar (InlineMath | DisplayMath) Dollar
- }
- InlineMath {
- Math
- }
- DisplayMath {
- Dollar Math? Dollar
- }
- OpenParenMath[closedBy=CloseParenMath] {
- OpenParenCtrlSym
- }
- CloseParenMath[openedBy=OpenParenMath] {
- CloseParenCtrlSym
- }
- // alternative syntax \( math \) for inline math, it is the same as $ math $
- ParenMath {
- OpenParenMath
- Math?
- CloseParenMath
- }
- OpenBracketMath[closedBy=CloseBracketMath] {
- OpenBracketCtrlSym
- }
- CloseBracketMath[openedBy=OpenBracketMath] {
- CloseBracketCtrlSym
- }
- // alternative syntax \[ math \] for display math, it is the same as $$ math $$
- BracketMath {
- OpenBracketMath
- Math?
- CloseBracketMath
- }
- // FIXME: we should have separate math modes for inline and display math,
- // because display math can contain blank lines while inline math cannot.
- Math {
- ( MathCommand
- | Group<Math>
- | MathDelimitedGroup
- | MathSpecialChar
- | Number
- | NewLine
- | Whitespace
- | KnownEnvironment
- | Environment
- | MathChar
- | OpenBracket
- | CloseBracket
- | Ampersand
- | Tilde
- )+
- }
- MathCommand {
- KnownCommand<MathArgument>
- | MathUnknownCommand { genericUnknownCommand<MathArgument> }
- | KnownCtrlSym
- }
- @external tokens argumentListTokenizer from "./tokens.mjs" {
- hasMoreArguments,
- endOfArguments
- }
- @external tokens argumentListWithOptionalTokenizer from "./tokens.mjs" {
- hasMoreArgumentsOrOptionals,
- endOfArgumentsAndOptionals
- }
- genericUnknownCommand<ArgumentType> {
- CtrlSeq (hasMoreArguments optionalWhitespace? ArgumentType)* endOfArguments
- | CtrlSym
- }
- genericUnknownCommandWithOptionalArguments<ArgumentType, OptionalArgumentType> {
- CtrlSeq (hasMoreArgumentsOrOptionals optionalWhitespace? (ArgumentType | OptionalArgumentType))* endOfArgumentsAndOptionals
- | CtrlSym
- }
- MathArgument {
- OpenBrace Math? CloseBrace
- }
- MathDelimitedGroup {
- MathOpening Math? MathClosing
- }
- // FIXME: we have the same problem with specialize on \left,\right as the delimiters
- MathOpening {
- LeftCtrlSeq optionalWhitespace? MathDelimiter
- }
- MathClosing {
- RightCtrlSeq optionalWhitespace? MathDelimiter
- }
- MathDelimiter {
- // Allowed delimiters, from the LaTeX manual, table 3.10
- "/" | "|" | "(" | ")" | "[" | "]" |
- "\\{" | "\\}" | "\\|" |
- "\\lfloor" | "\\rfloor" |
- "\\lceil" | "\\rceil" |
- "\\langle" | "\\rangle" |
- "\\backslash" | "\\uparrow" |
- "\\Uparrow" | "\\Downarrow" |
- "\\updownarrow" | "\\Updownarrow" |
- "\\downarrow" | "\\lvert" |
- "\\lVert" | "\\rVert" |
- "\\rvert" | "\\vert" | "\\Vert" |
- "\\lbrace" | "\\rbrace" |
- "\\lbrack" | "\\rbrack" |
- // Also allow the empty match
- "."
- }
- // NOTE: precedence works differently for rules and token, in the rule
- // you have to give a specifier !foo which is defined in the @precedence
- // block here.
- @precedence {
- section @left,
- argument @left // make CtrlSeq arguments left associative
- }
|