-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
grammar BibTex | ||
|
||
rule expression | ||
(comment / book / white)* | ||
end | ||
|
||
rule comment | ||
('%' / '@comment') (!'\n' . )* '\n' { | ||
def label | ||
return "comment" | ||
end | ||
} | ||
end | ||
|
||
rule book | ||
title:bookTitle space '{' space key:Character+ space ',' (attribute space ',' white)* attribute '}' { | ||
def label | ||
return "book" | ||
end | ||
} | ||
end | ||
|
||
rule attribute | ||
key space '=' space value | ||
end | ||
|
||
rule value | ||
('"' content:(!'"' . )* '"') / ('{' content:(!'{' . )* '}') / key | ||
end | ||
|
||
rule bookTitle | ||
'@' key { | ||
def label | ||
return "label" | ||
end | ||
} | ||
end | ||
|
||
rule key | ||
[a-zA-Z] [-a-zA-Z0-9_]* | ||
end | ||
|
||
rule white | ||
[ \n]+ | ||
end | ||
|
||
rule space | ||
' '* { | ||
def label | ||
return "white" | ||
end | ||
} | ||
end | ||
|
||
end |