overleaf/services/web/frontend/js/features/source-editor/lezer-bibtex/bibtex.grammar
Mathias Jakobsen 1e1a6f62a7 Merge pull request #15960 from overleaf/mj-bibtex-field-plus
[lezer] Support plus character in BibTeX field name

GitOrigin-RevId: a8af42fa9c372b36ed2ec0354bafa76154dd8d18
2023-11-30 09:03:23 +00:00

96 lines
No EOL
1.8 KiB
Text

@top Bibliography {
(Other | Declaration | CommentDeclaration | PreambleDeclaration | StringDeclaration)*
}
@tokens {
Other { ![@ \t\n] ![@]* }
whiteSpace { $[\t\n ]+ }
Identifier { ![,{} \t\n%]+ }
StringName { $[a-zA-Z:_] $[a-zA-Z:_0-9-]* }
FieldName {$[a-zA-Z-_0-9+]+}
LiteralString {
'"' (!["] | "\\" _)* '"'?
}
EntryTypeName { $[a-zA-Z]+ }
Number { @digit+ }
StringKeyword {"@"$[Ss]$[Tt]$[Rr]$[Ii]$[Nn]$[Gg]}
PreambleKeyword {"@"$[Pp]$[Rr]$[Ee]$[Aa]$[Mm]$[Bb]$[Ll]$[Ee]}
CommentKeyword {"@"$[Cc]$[Oo]$[Mm]$[Mm]$[Ee]$[Nn]$[Tt]}
CommentContents { ![@} \t\n] ![}@]* }
"{"[closedBy="}"]
"}"[openedBy="{"]
"@" "\"" "," "#" "@string"
}
@skip { whiteSpace }
StringDeclaration {
StringKeyword "{"
Field<StringName>*
"}"
}
PreambleDeclaration {
PreambleKeyword "{"
Expression
"}"
}
CommentDeclaration {
CommentKeyword "{"
CommentContents*
"}"
}
Declaration {
EntryName { "@" EntryTypeName } "{"
Identifier
fieldEntry {
("," Field<FieldName> )
}*
("," )?
"}"
}
Field<Name> {
Name "=" Expression
}
Expression {
BracedString |
Number |
StringConcatenation
}
@local tokens {
OpenBracedContents[closedBy="}", @name="{"] {"{"}
CloseBracedContents[openedBy="{", @name="}"] {"}"}
@else nonClosingBracedContents
}
@skip {}{
BracedStringContents {
(
nonClosingBracedContents |
nestedBracedString {
OpenBracedContents
BracedStringContents
CloseBracedContents
}
)*
}
BracedString {
"{" BracedStringContents CloseBracedContents
}
}
@precedence { concatenation @left }
StringConcatenation {
StringConcatenation !concatenation "#" StringConcatenation |
LiteralString |
StringName
}
@external propSource highlighting from "./highlight.mjs"