From db1e188fdbc94b17515583d542a0a2acfa456fb0 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 12 Jan 2016 03:29:28 -0800 Subject: [PATCH] Move grammar to top of file --- src/parser.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index d0f951c..5501858 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,6 +1,21 @@ use tokenizer::Token; use tokenizer::Kw; +/* Grammar + program := (statement delimiter ?)* + delimiter := Newline | Semicolon + statement := declaration | expression + declaraion := Fn prototype (statement)* End + prototype := identifier LParen identlist RParen + identlist := Ident (Comma Ident)* | e + + expression := primary_expression (op primary_expression)* + primary_expression := Variable | Number | String | call_expr | paren_expr + paren_expr := LParen expression RParen + call_expr := identifier LParen identlist RParen + op := '+', '-', etc. + */ + #[derive(Debug, Clone)] pub enum ASTNode { ExprNode(Expression), @@ -44,21 +59,6 @@ impl ParseError { } } -/* Grammar - program := (statement delimiter ?)* - delimiter := Newline | Semicolon - statement := declaration | expression - declaraion := Fn prototype (statement)* End - prototype := identifier LParen identlist RParen - identlist := Ident (Comma Ident)* | e - - expression := primary_expression (op primary_expression)* - primary_expression := Variable | Number | String | call_expr | paren_expr - paren_expr := LParen expression RParen - call_expr := identifier LParen identlist RParen - op := '+', '-', etc. - */ - struct Parser { tokens: Vec, }