Make note to fix parsing bug

This commit is contained in:
greg 2019-01-09 17:37:51 -08:00
parent 1085b528fe
commit 479a098e0f

View File

@ -213,7 +213,7 @@ expression := precedence_expr type_anno+
precedence_expr := prefix_expr precedence_expr := prefix_expr
prefix_expr := prefix_op call_expr prefix_expr := prefix_op call_expr
prefix_op := '+' | '-' | '!' | '~' prefix_op := '+' | '-' | '!' | '~'
call_expr := index_expr ( '(' expr_list ')' )* call_expr := index_expr '(' ( expr_list )* ')'
expr_list := expression (',' expression)* | ε expr_list := expression (',' expression)* | ε
index_expr := primary ( '[' (expression (',' (expression)* | ε) ']' )* index_expr := primary ( '[' (expression (',' (expression)* | ε) ']' )*
primary := literal | paren_expr | if_expr | for_expr | while_expr | identifier_expr | lambda_expr | anonymous_struct | list_expr primary := literal | paren_expr | if_expr | for_expr | while_expr | identifier_expr | lambda_expr | anonymous_struct | list_expr
@ -276,7 +276,6 @@ enumerator := identifier '<-' expression | identifier '=' expression //TODO add
*/ */
impl Parser { impl Parser {
//TODO make this a proper public interface
#[recursive_descent_method] #[recursive_descent_method]
fn program(&mut self) -> ParseResult<AST> { fn program(&mut self) -> ParseResult<AST> {
let mut statements = Vec::new(); let mut statements = Vec::new();
@ -1242,7 +1241,17 @@ mod parse_tests {
parse_test!("a + b", AST(vec![exst!(binexp!("+", val!("a"), val!("b")))])); parse_test!("a + b", AST(vec![exst!(binexp!("+", val!("a"), val!("b")))]));
//parse_test!("a[b]", AST(vec![Expression( //parse_test!("a[b]", AST(vec![Expression(
//parse_test!("a[]", <- TODO THIS NEEDS TO FAIL //parse_test!("a[]", <- TODO THIS NEEDS TO FAIL
//parse_test!(damn()[a] ,<- TODO needs to succeed //parse_test("a()[b]()[d]")
//TODO fix this parsing stuff
/*
parse_test! { "perspicacity()[a]", AST(vec![
exst!(Index {
indexee: bx!(ex!(Call { f: bx!(ex!(val!("perspicacity"))), arguments: vec![] })),
indexers: vec![ex!(val!("a"))]
})
])
}
*/
parse_test!("a[b,c]", AST(vec![exst!(Index { indexee: bx!(ex!(val!("a"))), indexers: vec![ex!(val!("b")), ex!(val!("c"))]} )])); parse_test!("a[b,c]", AST(vec![exst!(Index { indexee: bx!(ex!(val!("a"))), indexers: vec![ex!(val!("b")), ex!(val!("c"))]} )]));
parse_test!("None", AST(vec![exst!(val!("None"))])); parse_test!("None", AST(vec![exst!(val!("None"))]));