|
|
@ -1,8 +1,23 @@ |
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Copyright 2020 Garrit Franke |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
|
|
|
* You may obtain a copy of the License at |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
|
|
|
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
|
|
|
|
* limitations under the License. |
|
|
|
|
|
|
|
*/ |
|
|
|
use super::node_type::Statement; |
|
|
|
use super::node_type::Statement; |
|
|
|
use super::node_type::*; |
|
|
|
use super::node_type::*; |
|
|
|
use super::parser::Parser; |
|
|
|
use super::parser::Parser; |
|
|
|
use crate::lexer::Keyword; |
|
|
|
use crate::lexer::Keyword; |
|
|
|
use crate::lexer::{Token, TokenKind, Value}; |
|
|
|
use crate::lexer::{TokenKind, Value}; |
|
|
|
use std::convert::TryFrom; |
|
|
|
use std::convert::TryFrom; |
|
|
|
|
|
|
|
|
|
|
|
impl Parser { |
|
|
|
impl Parser { |
|
|
@ -113,7 +128,7 @@ impl Parser { |
|
|
|
match &next.kind { |
|
|
|
match &next.kind { |
|
|
|
TokenKind::BraceClose => break, |
|
|
|
TokenKind::BraceClose => break, |
|
|
|
TokenKind::Comma => { |
|
|
|
TokenKind::Comma => { |
|
|
|
self.next(); |
|
|
|
let _ = self.next(); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
TokenKind::Identifier(_) | TokenKind::Literal(_) => { |
|
|
|
TokenKind::Identifier(_) | TokenKind::Literal(_) => { |
|
|
@ -207,7 +222,7 @@ impl Parser { |
|
|
|
|
|
|
|
|
|
|
|
match self.peek()? { |
|
|
|
match self.peek()? { |
|
|
|
tok if tok.kind == TokenKind::Keyword(Keyword::Else) => { |
|
|
|
tok if tok.kind == TokenKind::Keyword(Keyword::Else) => { |
|
|
|
self.next(); |
|
|
|
let _ = self.next(); |
|
|
|
|
|
|
|
|
|
|
|
let peeked = self.peek()?; |
|
|
|
let peeked = self.peek()?; |
|
|
|
|
|
|
|
|
|
|
|