summaryrefslogtreecommitdiff
path: root/support/texlab/crates/parser
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/parser')
-rw-r--r--support/texlab/crates/parser/Cargo.toml2
-rw-r--r--support/texlab/crates/parser/src/latex.rs62
-rw-r--r--support/texlab/crates/parser/src/latex/lexer/commands.rs3
-rw-r--r--support/texlab/crates/parser/src/latex/lexer/types.rs3
4 files changed, 68 insertions, 2 deletions
diff --git a/support/texlab/crates/parser/Cargo.toml b/support/texlab/crates/parser/Cargo.toml
index 8dd3a771f8..e1edb782c5 100644
--- a/support/texlab/crates/parser/Cargo.toml
+++ b/support/texlab/crates/parser/Cargo.toml
@@ -10,7 +10,7 @@ rust-version.workspace = true
log.workspace = true
logos = "0.14.2"
once_cell.workspace = true
-pathdiff = "0.2.1"
+pathdiff = "0.2.2"
regex.workspace = true
rowan.workspace = true
rustc-hash.workspace = true
diff --git a/support/texlab/crates/parser/src/latex.rs b/support/texlab/crates/parser/src/latex.rs
index 669ba82f99..8379d9c5ca 100644
--- a/support/texlab/crates/parser/src/latex.rs
+++ b/support/texlab/crates/parser/src/latex.rs
@@ -158,6 +158,9 @@ impl<'a> Parser<'a> {
CommandName::EndBlockComment => self.generic_command(),
CommandName::VerbatimBlock => self.verbatim_block(),
CommandName::GraphicsPath => self.graphics_path(),
+ CommandName::BibItem => self.bibitem(),
+ CommandName::TocContentsLine => self.toc_contents_line(),
+ CommandName::TocNumberLine => self.toc_number_line(),
},
}
}
@@ -862,7 +865,20 @@ impl<'a> Parser<'a> {
}
if self.lexer.peek() == Some(Token::LCurly) {
- self.curly_group_word();
+ self.builder.start_node(CURLY_GROUP_WORD.into());
+ self.eat();
+ self.trivia();
+
+ if self.peek() == Some(Token::Word) || self.peek() == Some(Token::Pipe) {
+ self.key();
+ }
+
+ if let Some(Token::CommandName(_)) = self.peek() {
+ self.content(ParserContext::default());
+ }
+
+ self.expect(Token::RCurly);
+ self.builder.finish_node();
}
self.builder.finish_node();
@@ -1235,6 +1251,50 @@ impl<'a> Parser<'a> {
}
}
}
+
+ fn bibitem(&mut self) {
+ self.builder.start_node(BIBITEM.into());
+ self.eat();
+ self.trivia();
+
+ if self.lexer.peek() == Some(Token::LCurly) {
+ self.curly_group_word();
+ }
+
+ self.builder.finish_node();
+ }
+
+ fn toc_contents_line(&mut self) {
+ self.builder.start_node(TOC_CONTENTS_LINE.into());
+ self.eat();
+ self.trivia();
+
+ if self.lexer.peek() == Some(Token::LCurly) {
+ self.curly_group();
+ }
+
+ if self.lexer.peek() == Some(Token::LCurly) {
+ self.curly_group();
+ }
+
+ if self.lexer.peek() == Some(Token::LCurly) {
+ self.curly_group();
+ }
+
+ self.builder.finish_node();
+ }
+
+ fn toc_number_line(&mut self) {
+ self.builder.start_node(TOC_NUMBER_LINE.into());
+ self.eat();
+ self.trivia();
+
+ if self.lexer.peek() == Some(Token::LCurly) {
+ self.curly_group();
+ }
+
+ self.builder.finish_node();
+ }
}
pub fn parse_latex(text: &str, config: &SyntaxConfig) -> GreenNode {
diff --git a/support/texlab/crates/parser/src/latex/lexer/commands.rs b/support/texlab/crates/parser/src/latex/lexer/commands.rs
index 4d1a7ca320..3f8b6e36ed 100644
--- a/support/texlab/crates/parser/src/latex/lexer/commands.rs
+++ b/support/texlab/crates/parser/src/latex/lexer/commands.rs
@@ -96,6 +96,9 @@ pub fn classify(name: &str, config: &SyntaxConfig) -> CommandName {
"iffalse" => CommandName::BeginBlockComment,
"fi" => CommandName::EndBlockComment,
"verb" => CommandName::VerbatimBlock,
+ "bibitem" => CommandName::BibItem,
+ "contentsline" => CommandName::TocContentsLine,
+ "numberline" => CommandName::TocNumberLine,
_ if config.citation_commands.contains(name) => CommandName::Citation,
_ if config.label_definition_commands.contains(name) => CommandName::LabelDefinition,
diff --git a/support/texlab/crates/parser/src/latex/lexer/types.rs b/support/texlab/crates/parser/src/latex/lexer/types.rs
index 85e542792b..796378f671 100644
--- a/support/texlab/crates/parser/src/latex/lexer/types.rs
+++ b/support/texlab/crates/parser/src/latex/lexer/types.rs
@@ -95,6 +95,9 @@ pub enum CommandName {
BeginBlockComment,
EndBlockComment,
VerbatimBlock,
+ BibItem,
+ TocContentsLine,
+ TocNumberLine,
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]