forked from AbleScript/ablescript
Changed hopback
to and again
(credits: Evrey#6086)
This commit is contained in:
parent
bb3de6db14
commit
c0a2857122
|
@ -111,7 +111,7 @@ pub enum Stmt {
|
||||||
body: Block,
|
body: Block,
|
||||||
},
|
},
|
||||||
Enough,
|
Enough,
|
||||||
HopBack,
|
AndAgain,
|
||||||
|
|
||||||
Dim {
|
Dim {
|
||||||
ident: Spanned<String>,
|
ident: Spanned<String>,
|
||||||
|
|
|
@ -72,9 +72,9 @@ enum HaltStatus {
|
||||||
/// caught by a `loop` statement up to this point.
|
/// caught by a `loop` statement up to this point.
|
||||||
Enough(Range<usize>),
|
Enough(Range<usize>),
|
||||||
|
|
||||||
/// A `hopback` statement occurred at the given span, and was not
|
/// A `and again` statement occurred at the given span, and was not
|
||||||
/// caught by a `loop` statement up to this point.
|
/// caught by a `loop` statement up to this point.
|
||||||
Hopback(Range<usize>),
|
AndAgain(Range<usize>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The number of bits the `read` statement reads at once from
|
/// The number of bits the `read` statement reads at once from
|
||||||
|
@ -105,11 +105,11 @@ impl ExecEnv {
|
||||||
|
|
||||||
/// Execute a set of Statements in the root stack frame. Return an
|
/// Execute a set of Statements in the root stack frame. Return an
|
||||||
/// error if one or more of the Stmts failed to evaluate, or if a
|
/// error if one or more of the Stmts failed to evaluate, or if a
|
||||||
/// `enough` or `hopback` statement occurred at the top level.
|
/// `enough` or `and again` statement occurred at the top level.
|
||||||
pub fn eval_stmts(&mut self, stmts: &[Spanned<Stmt>]) -> Result<(), Error> {
|
pub fn eval_stmts(&mut self, stmts: &[Spanned<Stmt>]) -> Result<(), Error> {
|
||||||
match self.eval_stmts_hs(stmts, false)? {
|
match self.eval_stmts_hs(stmts, false)? {
|
||||||
HaltStatus::Finished => Ok(()),
|
HaltStatus::Finished => Ok(()),
|
||||||
HaltStatus::Enough(span) | HaltStatus::Hopback(span) => Err(Error {
|
HaltStatus::Enough(span) | HaltStatus::AndAgain(span) => Err(Error {
|
||||||
// It's an error to issue a `enough` outside of a
|
// It's an error to issue a `enough` outside of a
|
||||||
// `loop` statement.
|
// `loop` statement.
|
||||||
kind: ErrorKind::TopLevelEnough,
|
kind: ErrorKind::TopLevelEnough,
|
||||||
|
@ -118,7 +118,7 @@ impl ExecEnv {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The same as `eval_stmts`, but report "enough" and "hopback"
|
/// The same as `eval_stmts`, but report "enough" and "and again"
|
||||||
/// exit codes as normal conditions in a HaltStatus enum, and
|
/// exit codes as normal conditions in a HaltStatus enum, and
|
||||||
/// create a new stack frame if `stackframe` is true.
|
/// create a new stack frame if `stackframe` is true.
|
||||||
///
|
///
|
||||||
|
@ -280,7 +280,7 @@ impl ExecEnv {
|
||||||
match res {
|
match res {
|
||||||
HaltStatus::Finished => (),
|
HaltStatus::Finished => (),
|
||||||
HaltStatus::Enough(_) => break,
|
HaltStatus::Enough(_) => break,
|
||||||
HaltStatus::Hopback(_) => continue,
|
HaltStatus::AndAgain(_) => continue,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Stmt::Assign { assignable, value } => {
|
Stmt::Assign { assignable, value } => {
|
||||||
|
@ -289,8 +289,8 @@ impl ExecEnv {
|
||||||
Stmt::Enough => {
|
Stmt::Enough => {
|
||||||
return Ok(HaltStatus::Enough(stmt.span.clone()));
|
return Ok(HaltStatus::Enough(stmt.span.clone()));
|
||||||
}
|
}
|
||||||
Stmt::HopBack => {
|
Stmt::AndAgain => {
|
||||||
return Ok(HaltStatus::Hopback(stmt.span.clone()));
|
return Ok(HaltStatus::AndAgain(stmt.span.clone()));
|
||||||
}
|
}
|
||||||
Stmt::Melo(ident) => match self.get_var_mut(ident)? {
|
Stmt::Melo(ident) => match self.get_var_mut(ident)? {
|
||||||
var @ Variable::Ref(_) => *var = Variable::Melo,
|
var @ Variable::Ref(_) => *var = Variable::Melo,
|
||||||
|
|
|
@ -97,9 +97,9 @@ pub enum Token {
|
||||||
#[token("enough")]
|
#[token("enough")]
|
||||||
Enough,
|
Enough,
|
||||||
|
|
||||||
/// HopBack hops on the back of loop - like `continue`
|
/// Jump at the start of the loop
|
||||||
#[token("hopback")]
|
#[token("and again")]
|
||||||
HopBack,
|
AndAgain,
|
||||||
|
|
||||||
/// Crash with random error (see discussion #17)
|
/// Crash with random error (see discussion #17)
|
||||||
#[token("rlyeh")]
|
#[token("rlyeh")]
|
||||||
|
@ -123,6 +123,7 @@ pub enum Token {
|
||||||
|
|
||||||
/// An identifier
|
/// An identifier
|
||||||
#[regex(r"\p{XID_Start}[\p{XID_Continue}]+", get_ident)]
|
#[regex(r"\p{XID_Start}[\p{XID_Continue}]+", get_ident)]
|
||||||
|
#[token("and ", |_| "and".to_owned())]
|
||||||
Identifier(String),
|
Identifier(String),
|
||||||
|
|
||||||
#[regex(r"owo .*")]
|
#[regex(r"owo .*")]
|
||||||
|
|
|
@ -88,8 +88,8 @@ impl<'source> Parser<'source> {
|
||||||
self.semicolon_terminated(Stmt::Enough)?,
|
self.semicolon_terminated(Stmt::Enough)?,
|
||||||
start..self.lexer.span().end,
|
start..self.lexer.span().end,
|
||||||
)),
|
)),
|
||||||
Token::HopBack => Ok(Spanned::new(
|
Token::AndAgain => Ok(Spanned::new(
|
||||||
self.semicolon_terminated(Stmt::HopBack)?,
|
self.semicolon_terminated(Stmt::AndAgain)?,
|
||||||
start..self.lexer.span().end,
|
start..self.lexer.span().end,
|
||||||
)),
|
)),
|
||||||
Token::Rlyeh => Ok(Spanned::new(
|
Token::Rlyeh => Ok(Spanned::new(
|
||||||
|
|
Loading…
Reference in a new issue