summaryrefslogtreecommitdiff
path: root/src/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax')
-rw-r--r--src/syntax/ast.rs14
-rw-r--r--src/syntax/kind.rs4
-rw-r--r--src/syntax/lexer.rs57
3 files changed, 4 insertions, 71 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index b9186787..3b573f7d 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -89,8 +89,6 @@ pub enum Expr {
/// A shorthand for a unicode codepoint. For example, `~` for non-breaking
/// space or `-?` for a soft hyphen.
Shorthand(Shorthand),
- /// Symbol notation: `:arrow:l:`.
- Symbol(Symbol),
/// A smart quote: `'` or `"`.
SmartQuote(SmartQuote),
/// Strong content: `*Strong*`.
@@ -414,18 +412,6 @@ impl Shorthand {
}
node! {
- /// Symbol notation: `:arrow:l:`.
- Symbol
-}
-
-impl Symbol {
- /// Get the symbol's notation.
- pub fn get(&self) -> &str {
- self.0.text().trim_matches(':')
- }
-}
-
-node! {
/// A smart quote: `'` or `"`.
SmartQuote
}
diff --git a/src/syntax/kind.rs b/src/syntax/kind.rs
index 34e2fce7..f0a0bc5a 100644
--- a/src/syntax/kind.rs
+++ b/src/syntax/kind.rs
@@ -24,9 +24,6 @@ pub enum SyntaxKind {
/// A shorthand for a unicode codepoint. For example, `~` for non-breaking
/// space or `-?` for a soft hyphen.
Shorthand,
- /// Symbol notation: `:arrow:l:`. The string only contains the inner part
- /// without leading and trailing dot.
- Symbol,
/// A smart quote: `'` or `"`.
SmartQuote,
/// Strong content: `*Strong*`.
@@ -332,7 +329,6 @@ impl SyntaxKind {
Self::Parbreak => "paragraph break",
Self::Escape => "escape sequence",
Self::Shorthand => "shorthand",
- Self::Symbol => "symbol notation",
Self::Strong => "strong content",
Self::Emph => "emphasized content",
Self::Raw => "raw block",
diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs
index 0735270b..d4548b8b 100644
--- a/src/syntax/lexer.rs
+++ b/src/syntax/lexer.rs
@@ -167,21 +167,12 @@ impl Lexer<'_> {
fn markup(&mut self, start: usize, c: char) -> SyntaxKind {
match c {
'\\' => self.backslash(),
- ':' if self.s.at(is_id_start) => self.maybe_symbol(),
'`' => self.raw(),
'h' if self.s.eat_if("ttp://") => self.link(),
'h' if self.s.eat_if("ttps://") => self.link(),
'0'..='9' => self.numbering(start),
'<' if self.s.at(is_id_continue) => self.label(),
'@' if self.s.at(is_id_continue) => self.reference(),
- '#' if self.s.eat_if('{') => SyntaxKind::LeftBrace,
- '#' if self.s.eat_if('[') => SyntaxKind::LeftBracket,
- '#' if self.s.at(is_id_start) => {
- match keyword(self.s.eat_while(is_id_continue)) {
- Some(keyword) => keyword,
- None => SyntaxKind::Ident,
- }
- }
'.' if self.s.eat_if("..") => SyntaxKind::Shorthand,
'-' if self.s.eat_if("--") => SyntaxKind::Shorthand,
@@ -190,8 +181,7 @@ impl Lexer<'_> {
'*' if !self.in_word() => SyntaxKind::Star,
'_' if !self.in_word() => SyntaxKind::Underscore,
- '{' => SyntaxKind::LeftBrace,
- '}' => SyntaxKind::RightBrace,
+ '#' if !self.s.at(char::is_whitespace) => SyntaxKind::Hashtag,
'[' => SyntaxKind::LeftBracket,
']' => SyntaxKind::RightBracket,
'\'' => SyntaxKind::SmartQuote,
@@ -241,26 +231,6 @@ impl Lexer<'_> {
}
}
- fn maybe_symbol(&mut self) -> SyntaxKind {
- let start = self.s.cursor();
- let mut end = start;
- while !self.s.eat_while(is_id_continue).is_empty() && self.s.at(':') {
- end = self.s.cursor();
- self.s.eat();
- }
-
- self.s.jump(end);
-
- if start < end {
- self.s.expect(':');
- SyntaxKind::Symbol
- } else if self.mode == LexMode::Markup {
- SyntaxKind::Colon
- } else {
- SyntaxKind::Atom
- }
- }
-
fn raw(&mut self) -> SyntaxKind {
let mut backticks = 1;
while self.s.eat_if('`') {
@@ -408,7 +378,6 @@ impl Lexer<'_> {
fn math(&mut self, start: usize, c: char) -> SyntaxKind {
match c {
'\\' => self.backslash(),
- ':' if self.s.at(is_id_start) => self.maybe_symbol(),
'"' => self.string(),
'.' if self.s.eat_if("..") => SyntaxKind::Shorthand,
@@ -434,9 +403,10 @@ impl Lexer<'_> {
'^' => SyntaxKind::Hat,
'&' => SyntaxKind::MathAlignPoint,
- // Identifiers and symbol notation.
+ // Identifiers.
c if is_math_id_start(c) && self.s.at(is_math_id_continue) => {
- self.math_ident()
+ self.s.eat_while(is_math_id_continue);
+ SyntaxKind::MathIdent
}
// Other math atoms.
@@ -444,25 +414,6 @@ impl Lexer<'_> {
}
}
- fn math_ident(&mut self) -> SyntaxKind {
- self.s.eat_while(is_math_id_continue);
-
- let mut symbol = false;
- while self.s.eat_if(':') && !self.s.eat_while(char::is_alphanumeric).is_empty() {
- symbol = true;
- }
-
- if symbol {
- return SyntaxKind::Symbol;
- }
-
- if self.s.scout(-1) == Some(':') {
- self.s.uneat();
- }
-
- SyntaxKind::Ident
- }
-
fn atom(&mut self, start: usize, c: char) -> SyntaxKind {
// Keep numbers and grapheme clusters together.
if c.is_numeric() {