Getting rid of some newlines - concision
This commit is contained in:
parent
f6e5ea250d
commit
8651839a66
@ -275,7 +275,6 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn body(&mut self) -> ParseResult<Vec<Statement>> {
|
fn body(&mut self) -> ParseResult<Vec<Statement>> {
|
||||||
|
|
||||||
let statements = delimiter_block!(
|
let statements = delimiter_block!(
|
||||||
self,
|
self,
|
||||||
statement,
|
statement,
|
||||||
@ -312,7 +311,6 @@ impl Parser {
|
|||||||
|
|
||||||
lhs = Expression::BinExp(op.0, Box::new(lhs), Box::new(rhs));
|
lhs = Expression::BinExp(op.0, Box::new(lhs), Box::new(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(lhs)
|
Ok(lhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,15 +344,12 @@ impl Parser {
|
|||||||
fn while_expr(&mut self) -> ParseResult<Expression> {
|
fn while_expr(&mut self) -> ParseResult<Expression> {
|
||||||
use self::Expression::*;
|
use self::Expression::*;
|
||||||
expect!(self, Keyword(Kw::While));
|
expect!(self, Keyword(Kw::While));
|
||||||
|
|
||||||
let test = try!(self.expression());
|
let test = try!(self.expression());
|
||||||
|
|
||||||
let body = delimiter_block!(
|
let body = delimiter_block!(
|
||||||
self,
|
self,
|
||||||
expression,
|
expression,
|
||||||
Some(Keyword(Kw::End))
|
Some(Keyword(Kw::End))
|
||||||
);
|
);
|
||||||
|
|
||||||
expect!(self, Keyword(Kw::End));
|
expect!(self, Keyword(Kw::End));
|
||||||
Ok(While(Box::new(test), body))
|
Ok(While(Box::new(test), body))
|
||||||
}
|
}
|
||||||
@ -362,9 +357,7 @@ impl Parser {
|
|||||||
fn conditional_expr(&mut self) -> ParseResult<Expression> {
|
fn conditional_expr(&mut self) -> ParseResult<Expression> {
|
||||||
use self::Expression::*;
|
use self::Expression::*;
|
||||||
expect!(self, Keyword(Kw::If));
|
expect!(self, Keyword(Kw::If));
|
||||||
|
|
||||||
let test = try!(self.expression());
|
let test = try!(self.expression());
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.peek() {
|
match self.peek() {
|
||||||
Some(ref t) if is_delimiter(t) => {
|
Some(ref t) if is_delimiter(t) => {
|
||||||
@ -374,14 +367,12 @@ impl Parser {
|
|||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect!(self, Keyword(Kw::Then));
|
expect!(self, Keyword(Kw::Then));
|
||||||
let then_block = delimiter_block!(
|
let then_block = delimiter_block!(
|
||||||
self,
|
self,
|
||||||
expression,
|
expression,
|
||||||
Some(Keyword(Kw::Else)) | Some(Keyword(Kw::End))
|
Some(Keyword(Kw::Else)) | Some(Keyword(Kw::End))
|
||||||
);
|
);
|
||||||
|
|
||||||
let else_block = if let Some(Keyword(Kw::Else)) = self.peek() {
|
let else_block = if let Some(Keyword(Kw::Else)) = self.peek() {
|
||||||
self.next();
|
self.next();
|
||||||
let else_exprs = delimiter_block!(
|
let else_exprs = delimiter_block!(
|
||||||
@ -393,7 +384,6 @@ impl Parser {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
expect!(self, Keyword(Kw::End));
|
expect!(self, Keyword(Kw::End));
|
||||||
Ok(Conditional(Box::new(test),
|
Ok(Conditional(Box::new(test),
|
||||||
Box::new(Block(VecDeque::from(then_block))),
|
Box::new(Block(VecDeque::from(then_block))),
|
||||||
@ -409,7 +399,6 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
__ => Expression::Variable(name),
|
__ => Expression::Variable(name),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(expr)
|
Ok(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user