bibtex.grammar 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. @top Bibliography {
  2. (Other | Declaration | CommentDeclaration | PreambleDeclaration | StringDeclaration)*
  3. }
  4. @tokens {
  5. Other { ![@ \t\n] ![@]* }
  6. whiteSpace { $[\t\n ]+ }
  7. Identifier { ![,{} \t\n%]+ }
  8. StringName { $[a-zA-Z:_] $[a-zA-Z:_0-9-]* }
  9. FieldName {$[a-zA-Z-_0-9+]+}
  10. LiteralString {
  11. '"' (!["] | "\\" _)* '"'?
  12. }
  13. EntryTypeName { $[a-zA-Z]+ }
  14. Number { @digit+ }
  15. StringKeyword {"@"$[Ss]$[Tt]$[Rr]$[Ii]$[Nn]$[Gg]}
  16. PreambleKeyword {"@"$[Pp]$[Rr]$[Ee]$[Aa]$[Mm]$[Bb]$[Ll]$[Ee]}
  17. CommentKeyword {"@"$[Cc]$[Oo]$[Mm]$[Mm]$[Ee]$[Nn]$[Tt]}
  18. CommentContents { ![@} \t\n] ![}@]* }
  19. "{"[closedBy="}"]
  20. "}"[openedBy="{"]
  21. "@" "\"" "," "#" "@string"
  22. }
  23. @skip { whiteSpace }
  24. StringDeclaration {
  25. StringKeyword "{"
  26. Field<StringName>*
  27. "}"
  28. }
  29. PreambleDeclaration {
  30. PreambleKeyword "{"
  31. Expression
  32. "}"
  33. }
  34. CommentDeclaration {
  35. CommentKeyword "{"
  36. CommentContents*
  37. "}"
  38. }
  39. EntryName {
  40. "@" EntryTypeName
  41. }
  42. Declaration {
  43. EntryName "{"
  44. Identifier
  45. fieldEntry {
  46. ("," Field<FieldName> )
  47. }*
  48. ("," )?
  49. "}"
  50. }
  51. Field<Name> {
  52. Name "=" Expression
  53. }
  54. Expression {
  55. BracedString |
  56. Number |
  57. StringConcatenation
  58. }
  59. @local tokens {
  60. OpenBracedContents[closedBy="}", @name="{"] {"{"}
  61. CloseBracedContents[openedBy="{", @name="}"] {"}"}
  62. @else nonClosingBracedContents
  63. }
  64. @skip {}{
  65. BracedStringContents {
  66. (
  67. nonClosingBracedContents |
  68. nestedBracedString {
  69. OpenBracedContents
  70. BracedStringContents
  71. CloseBracedContents
  72. }
  73. )*
  74. }
  75. BracedString {
  76. "{" BracedStringContents CloseBracedContents
  77. }
  78. }
  79. @precedence { concatenation @left }
  80. StringConcatenation {
  81. StringConcatenation !concatenation "#" StringConcatenation |
  82. LiteralString |
  83. StringName
  84. }
  85. @external propSource highlighting from "./highlight.mjs"