1 -- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
4 local l
= require('lexer')
5 local token
, word_match
= l
.token
, l
.word_match
6 local P
, R
, S
= lpeg
.P
, lpeg
.R
, lpeg
.S
8 local M
= {_NAME
= 'bibtex'}
11 local ws
= token(l
.WHITESPACE
, l
.space^
1)
14 local string = token(l
.STRING
, l
.delimited_range('"') +
15 l
.delimited_range('{}', false, true, true))
18 local field
= token('field', word_match
{
19 'author', 'title', 'journal', 'year', 'volume', 'number', 'pages', 'month',
20 'note', 'key', 'publisher', 'editor', 'series', 'address', 'edition',
21 'howpublished', 'booktitle', 'organization', 'chapter', 'school',
22 'institution', 'type', 'isbn', 'issn', 'affiliation', 'issue', 'keyword',
27 local identifier
= token(l
.IDENTIFIER
, l
.word
)
30 local operator
= token(l
.OPERATOR
, S(',='))
35 {'identifier', identifier
},
37 {'operator', operator
},
41 local latex
= l
.load('latex')
44 local entry
= token('entry', P('@') * word_match({
45 'book', 'article', 'booklet', 'conference', 'inbook', 'incollection',
46 'inproceedings', 'manual', 'mastersthesis', 'lambda', 'misc', 'phdthesis',
47 'proceedings', 'techreport', 'unpublished'
49 local bibtex_start_rule
= entry
* ws^
0 * token(l
.OPERATOR
, P('{'))
50 local bibtex_end_rule
= token(l
.OPERATOR
, P('}'))
51 l
.embed_lexer(latex
, M
, bibtex_start_rule
, bibtex_end_rule
)
54 field
= l
.STYLE_CONSTANT
,
55 entry
= l
.STYLE_PREPROCESSOR