mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-10-26 14:05:36 +03:00
Fix ';' in let term, allow '.' in name
This commit is contained in:
parent
af194db86c
commit
4a092a3bce
@ -6,7 +6,7 @@ use crate::ast::Number;
|
||||
#[derive(Logos, Debug, PartialEq, Clone)]
|
||||
#[logos(error=LexingError)]
|
||||
pub enum Token {
|
||||
#[regex("[_a-zA-Z][_a-zA-Z0-9]*", |lex| lex.slice().parse().ok())]
|
||||
#[regex("[_.a-zA-Z][_.a-zA-Z0-9]*", |lex| lex.slice().parse().ok())]
|
||||
Name(String),
|
||||
|
||||
#[regex("@|λ")]
|
||||
|
@ -125,6 +125,7 @@ where
|
||||
let var = name().map(|name| Term::Var { nam: name }).boxed();
|
||||
let global_var = just(Token::Dollar).ignore_then(name()).map(|name| Term::GlobalVar { nam: name }).boxed();
|
||||
let era_or_name = choice((select!(Token::Asterisk => None), name().map(Some))).boxed();
|
||||
let term_sep = choice((just(Token::NewLine), just(Token::Semicolon)));
|
||||
|
||||
recursive(|term| {
|
||||
// λx body
|
||||
@ -157,7 +158,7 @@ where
|
||||
.then_ignore(just(Token::Equals))
|
||||
.then_ignore(new_line())
|
||||
.then(term.clone())
|
||||
.then_ignore(just(Token::Semicolon))
|
||||
.then_ignore(term_sep.clone())
|
||||
.then_ignore(new_line())
|
||||
.then(term.clone())
|
||||
.map(|(((fst, snd), val), next)| Term::Dup { fst, snd, val: Box::new(val), nxt: Box::new(next) })
|
||||
@ -171,8 +172,7 @@ where
|
||||
.then_ignore(just(Token::Equals))
|
||||
.then_ignore(new_line())
|
||||
.then(term.clone())
|
||||
.then_ignore(new_line())
|
||||
.then_ignore(just(Token::Semicolon))
|
||||
.then_ignore(term_sep)
|
||||
.then_ignore(new_line())
|
||||
.then(term.clone())
|
||||
.map(|((name, body), next)| Term::App {
|
||||
|
Loading…
Reference in New Issue
Block a user