Skip to content

Commit

Permalink
fix[lexer]: Renamed Key to Ident.
Browse files Browse the repository at this point in the history
  • Loading branch information
watcol committed Nov 23, 2021
1 parent ff6a193 commit b2e66b9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ peg::parser! { grammar lexer() for str {
/ expected!("symbols")

// TODO: Add test
rule key() -> String = key_bare() / key_raw() / expected!("key")
rule key_bare() -> String
rule ident() -> String = ident_bare() / ident_raw() / expected!("identifier")
rule ident_bare() -> String
= s:$(['a'..='z'|'A'..='Z'] ['a'..='z'|'A'..='Z'|'0'..='9'|'_']*) { s.to_string() }
rule key_raw() -> String
rule ident_raw() -> String
= "${" s:((
c:$([^ '\\'|'}']) {? c.chars().next().map(|c| Some(c)).ok_or("char") }
/ escape("}")
Expand Down Expand Up @@ -86,7 +86,7 @@ peg::parser! { grammar lexer() for str {
t:(
s:symbol() { Token::Symbol(s) }
/ b:boolean() { Token::Bool(b) }
/ k:key() { Token::Key(k) }
/ k:ident() { Token::Ident(k) }
)
e:position!() { PosToken{ file_id, pos: s..e, token: t } }

Expand All @@ -108,7 +108,7 @@ pub struct PosToken {
#[derive(Clone, Debug, PartialEq)]
pub enum Token {
Symbol(Symbol),
Key(String),
Ident(String),
Int(i64),
Float(f64),
Bool(bool),
Expand Down

0 comments on commit b2e66b9

Please sign in to comment.