mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-22 05:34:41 +01:00
lang: fix some details in the parser
This commit is contained in:
parent
0de076ace1
commit
cfefab9fd0
|
@ -86,14 +86,17 @@ fn def(p: &mut Parser) -> Option<CompletedMarker> {
|
||||||
body.error(p, SyntaxError::Expected(vec![DEF_BODY]));
|
body.error(p, SyntaxError::Expected(vec![DEF_BODY]));
|
||||||
}
|
}
|
||||||
|
|
||||||
let def = def_start.complete(p, DEF);
|
|
||||||
Some(if p.eat(SEMICOLON) {
|
Some(if p.eat(SEMICOLON) {
|
||||||
def
|
def_start.complete(p, DEF)
|
||||||
} else if TOP_LEVEL_ITEM_START.contains(p.current()) || p.at(EOF) {
|
} else if TOP_LEVEL_ITEM_START.contains(p.current()) || p.at(EOF) {
|
||||||
def.precede(p, "unterminated_tl_item")
|
def_start
|
||||||
|
.complete(p, DEF)
|
||||||
|
.precede(p, "unterminated_tl_item")
|
||||||
.error(p, SyntaxError::UnterminatedTopLevelItem)
|
.error(p, SyntaxError::UnterminatedTopLevelItem)
|
||||||
} else {
|
} else {
|
||||||
def.precede(p, "err_unexpected")
|
def_start
|
||||||
|
.complete(p, DEF)
|
||||||
|
.precede(p, "err_unexpected")
|
||||||
.error(p, SyntaxError::Expected(vec![SEMICOLON]))
|
.error(p, SyntaxError::Expected(vec![SEMICOLON]))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -110,7 +113,7 @@ fn r#use(p: &mut Parser) -> Option<CompletedMarker> {
|
||||||
.error(p, SyntaxError::Expected(vec![USE_PAT]));
|
.error(p, SyntaxError::Expected(vec![USE_PAT]));
|
||||||
}
|
}
|
||||||
|
|
||||||
let use_item = use_start.complete(p, DEF);
|
let use_item = use_start.complete(p, USE);
|
||||||
Some(if p.eat(SEMICOLON) {
|
Some(if p.eat(SEMICOLON) {
|
||||||
use_item
|
use_item
|
||||||
} else if TOP_LEVEL_ITEM_START.contains(p.current()) || p.at(EOF) {
|
} else if TOP_LEVEL_ITEM_START.contains(p.current()) || p.at(EOF) {
|
||||||
|
@ -142,6 +145,9 @@ fn use_pat(p: &mut Parser) -> Option<CompletedMarker> {
|
||||||
wrong_semi.error(p, SyntaxError::PathSepContainsSemicolon);
|
wrong_semi.error(p, SyntaxError::PathSepContainsSemicolon);
|
||||||
p.eat(COLON);
|
p.eat(COLON);
|
||||||
broken_sep.complete(p, PATH_SEP);
|
broken_sep.complete(p, PATH_SEP);
|
||||||
|
if pat_item(p).is_none() {
|
||||||
|
break Some(use_pat_marker.error(p, SyntaxError::UnfinishedPath));
|
||||||
|
}
|
||||||
} else if p.at(COLON) && p.nth_at(1, SEMICOLON) {
|
} else if p.at(COLON) && p.nth_at(1, SEMICOLON) {
|
||||||
let broken_sep = p.start("broken_path_sep");
|
let broken_sep = p.start("broken_path_sep");
|
||||||
p.eat(COLON);
|
p.eat(COLON);
|
||||||
|
@ -149,6 +155,9 @@ fn use_pat(p: &mut Parser) -> Option<CompletedMarker> {
|
||||||
p.eat(SEMICOLON);
|
p.eat(SEMICOLON);
|
||||||
wrong_semi.error(p, SyntaxError::PathSepContainsSemicolon);
|
wrong_semi.error(p, SyntaxError::PathSepContainsSemicolon);
|
||||||
broken_sep.complete(p, PATH_SEP);
|
broken_sep.complete(p, PATH_SEP);
|
||||||
|
if pat_item(p).is_none() {
|
||||||
|
break Some(use_pat_marker.error(p, SyntaxError::UnfinishedPath));
|
||||||
|
}
|
||||||
} else if p.at(SEMICOLON) && p.nth_at(1, SEMICOLON) {
|
} else if p.at(SEMICOLON) && p.nth_at(1, SEMICOLON) {
|
||||||
let broken_sep = p.start("broken_path_sep");
|
let broken_sep = p.start("broken_path_sep");
|
||||||
p.eat(SEMICOLON);
|
p.eat(SEMICOLON);
|
||||||
|
@ -157,7 +166,10 @@ fn use_pat(p: &mut Parser) -> Option<CompletedMarker> {
|
||||||
.complete(p, PATH_SEP)
|
.complete(p, PATH_SEP)
|
||||||
.precede(p, "semi_typo_err")
|
.precede(p, "semi_typo_err")
|
||||||
.error(p, SyntaxError::PathSepContainsSemicolon);
|
.error(p, SyntaxError::PathSepContainsSemicolon);
|
||||||
} else if p.at(SEMICOLON) {
|
if pat_item(p).is_none() {
|
||||||
|
break Some(use_pat_marker.error(p, SyntaxError::UnfinishedPath));
|
||||||
|
}
|
||||||
|
} else if p.eat(SEMICOLON) {
|
||||||
break Some(use_pat_marker.complete(p, USE_PAT));
|
break Some(use_pat_marker.complete(p, USE_PAT));
|
||||||
} else {
|
} else {
|
||||||
break Some(use_pat_marker.error(p, SyntaxError::Expected(vec![PATH_SEP, SEMICOLON])));
|
break Some(use_pat_marker.error(p, SyntaxError::Expected(vec![PATH_SEP, SEMICOLON])));
|
||||||
|
|
|
@ -5,6 +5,7 @@ def hello_world = meow [ 1 2 ];
|
||||||
def test
|
def test
|
||||||
|
|
||||||
mod hello {
|
mod hello {
|
||||||
|
use gay:;uwu_meow::*;
|
||||||
def meow = uwu;
|
def meow = uwu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue