diff --git a/src/lexer.rs b/src/lexer.rs index 0a171d4..5a382ec 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -236,6 +236,7 @@ pub fn lex(mut code: &str, use_whitespace: bool) -> Result, (LexerSta "\n" => { code = code.strip_prefix(fch.as_str()).expect(""); state.line += 1; + state.column = 0; } _ => { if inside_str > 0 || brvct.len() > 0 { diff --git a/src/parser.rs b/src/parser.rs index 75b7341..a041436 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -82,18 +82,20 @@ impl Parser { ast_res.ast_type = AstType::FunctionDeceleration; } self.index += 3; - } else if self.tokens.len()-index > 1 && token.value == "cb" && self.tokens[index+1].token_type == TokenType::Curly { - ast_res.tokens.push(self.tokens[index+1].clone()); - ast_res.ast_type = AstType::CodeBlock; - self.index += 1; - } else if self.tokens[index+1].token_type==TokenType::Identifier { - ast_res.tokens.push(self.tokens[index+1].clone()); - ast_res.ast_type = AstType::VariableDeceleration; - self.index += 1; - } else if self.tokens[index+1].value=="mut" && self.tokens[index+2].token_type==TokenType::Identifier { - ast_res.tokens.push(self.tokens[index+2].clone()); - ast_res.ast_type = AstType::MutVariableDeceleration; - self.index += 2; + } else if self.tokens.len()-index > 1 { + if token.value == "cb" && self.tokens[index+1].token_type == TokenType::Curly { + ast_res.tokens.push(self.tokens[index+1].clone()); + ast_res.ast_type = AstType::CodeBlock; + self.index += 1; + } else if self.tokens[index+1].token_type==TokenType::Identifier { + ast_res.tokens.push(self.tokens[index+1].clone()); + ast_res.ast_type = AstType::VariableDeceleration; + self.index += 1; + } else if self.tokens[index+1].value=="mut" && self.tokens[index+2].token_type==TokenType::Identifier { + ast_res.tokens.push(self.tokens[index+2].clone()); + ast_res.ast_type = AstType::MutVariableDeceleration; + self.index += 2; + } } } TokenType::Include => {