Rename rhs to simple_expression

This commit is contained in:
greg 2015-07-25 17:43:44 -07:00
parent c9fdd5e83c
commit 8f9bfbc5bd
2 changed files with 9 additions and 10 deletions

View File

@ -11,12 +11,11 @@
<expr> := if <expr> then <statements> end
| if <expr> then <statements> else <statements> end
| while <expr> SEP <statements> end
| <binexpr>
| <number>
| <id>
| <simple_expr>
<binexpr> :=
<simple_expr> := <id>
| <number>
| <string>
/* actual grammar encoded in program */

View File

@ -109,10 +109,10 @@ fn let_expression(tokens: &mut Tokens) -> ParseResult {
if let Some(&Identifier(ref name)) = tokens.next() {
if let Some(&Identifier(ref s)) = tokens.next() {
if s == "=" {
if let ParseResult::Ok(rhs) = rhs(tokens) {
if let ParseResult::Ok(expr) = simple_expression(tokens) {
return ParseResult::Ok(
AST::Binding(name.clone(),
Box::new(rhs)));
Box::new(expr)));
}
}
}
@ -130,7 +130,7 @@ fn expression(tokens: &mut Tokens) -> ParseResult {
Some(&Keyword(Kw::While)) => {
while_expression(tokens)
},
_ => rhs(tokens)
_ => simple_expression(tokens)
}
}
@ -190,7 +190,7 @@ fn while_expression(tokens: &mut Tokens) -> ParseResult {
))
}
fn rhs(tokens: &mut Tokens) -> ParseResult {
fn simple_expression(tokens: &mut Tokens) -> ParseResult {
let next = tokens.next();
if let Some(&Identifier(ref value)) = next {
return ParseResult::Ok(AST::Name(value.clone()));
@ -204,5 +204,5 @@ fn rhs(tokens: &mut Tokens) -> ParseResult {
return ParseResult::Ok(AST::Number(n));
}
return ParseResult::Err("Bad parse in rhs()".to_string());
return ParseResult::Err("Bad parse in simple_expression()".to_string());
}