Skip to content

Commit

Permalink
fix: parse error on program
Browse files Browse the repository at this point in the history
  • Loading branch information
sbwtw committed Jul 21, 2024
1 parent 69bf1c7 commit 0aed727
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/src/parser/default_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ impl<I: Iterator<Item = LexerResult>> DefaultParserImpl<I> {
let tok = self.next_token()?;
for want in tokens {
if tok.kind.kind_match(want) {
dbg!("except:", tok, want);
return Ok(tok);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/parser/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ impl TokenKind {
TokenKind::Byte => matches!(rhs, TokenKind::Byte),
TokenKind::Function => matches!(rhs, TokenKind::Function),
TokenKind::EndFunction => matches!(rhs, TokenKind::EndFunction),
TokenKind::Program => matches!(rhs, TokenKind::EndProgram),
TokenKind::Program => matches!(rhs, TokenKind::Program),
TokenKind::EndProgram => matches!(rhs, TokenKind::EndProgram),
TokenKind::Colon => matches!(rhs, TokenKind::Colon),
TokenKind::Comma => matches!(rhs, TokenKind::Comma),
TokenKind::Semicolon => matches!(rhs, TokenKind::Semicolon),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/test_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use stc::parser::{ParserBuilder, StLexerBuilder};
use std::fs;

fn main() {
let f = "lib/src/test/test_body_parse/call_expression.st";
let f = "lib/src/test/test_decl_parse/test_parse_prg.st";
let code = fs::read_to_string(f).unwrap();
let lexer = StLexerBuilder::new().build_str(&code);

let parser = ParserBuilder::new().build();
match parser.parse_stmt(lexer) {
match parser.parse(lexer) {
Ok(r) => {
println!("{}", r);
println!("{:?}", r);
}
Err(e) => panic!("{}: {:?}", f, e),
}
Expand Down

0 comments on commit 0aed727

Please sign in to comment.