mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-10-15 23:58:46 +03:00
clean up commented out code
This commit is contained in:
parent
3593529c4d
commit
0a525fc04f
@ -108,22 +108,6 @@ impl<'a> ParserContext<'a> {
|
||||
.unwrap_or_else(|| Cow::Owned(Token::Eof))
|
||||
}
|
||||
|
||||
// pub fn peek_oneof(&self, token: &[Token]) -> Result<&SpannedToken> {
|
||||
// if let Some(spanned_token) = self.inner.last() {
|
||||
// if token.iter().any(|x| x == &spanned_token.token) {
|
||||
// Ok(spanned_token)
|
||||
// } else {
|
||||
// Err(SyntaxError::unexpected(
|
||||
// &spanned_token.token,
|
||||
// token,
|
||||
// &spanned_token.span,
|
||||
// ))
|
||||
// }
|
||||
// } else {
|
||||
// Err(self.eof())
|
||||
// }
|
||||
// }
|
||||
|
||||
///
|
||||
/// Returns true if the next token exists.
|
||||
///
|
||||
|
@ -123,66 +123,6 @@ impl ParserContext<'_> {
|
||||
self.parse_bin_expr(Token::And, BinaryOperation::And, Self::parse_equality_expression)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary bitwise or expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_bit_xor_expression`].
|
||||
///
|
||||
// pub fn parse_bit_or_expression(&mut self) -> Result<Expression> {
|
||||
// let mut expr = self.parse_bit_xor_expression()?;
|
||||
// while self.eat(Token::BitOr).is_some() {
|
||||
// let right = self.parse_bit_xor_expression()?;
|
||||
// expr = Expression::Binary(BinaryExpression {
|
||||
// span: expr.span() + right.span(),
|
||||
// op: BinaryOperation::BitOr,
|
||||
// left: Box::new(expr),
|
||||
// right: Box::new(right),
|
||||
// })
|
||||
// }
|
||||
// Ok(expr)
|
||||
// }
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary bitwise xor expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_bit_and_expression`].
|
||||
///
|
||||
// pub fn parse_bit_xor_expression(&mut self) -> Result<Expression> {
|
||||
// let mut expr = self.parse_bit_and_expression()?;
|
||||
// while self.eat(Token::BitXor).is_some() {
|
||||
// let right = self.parse_bit_and_expression()?;
|
||||
// expr = Expression::Binary(BinaryExpression {
|
||||
// span: expr.span() + right.span(),
|
||||
// op: BinaryOperation::BitXor,
|
||||
// left: Box::new(expr),
|
||||
// right: Box::new(right),
|
||||
// })
|
||||
// }
|
||||
// Ok(expr)
|
||||
// }
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary bitwise and expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_equality_expression`].
|
||||
///
|
||||
// pub fn parse_bit_and_expression(&mut self) -> Result<Expression> {
|
||||
// let mut expr = self.parse_equality_expression()?;
|
||||
// while self.eat(Token::Ampersand).is_some() {
|
||||
// let right = self.parse_equality_expression()?;
|
||||
// expr = Expression::Binary(BinaryExpression {
|
||||
// span: expr.span() + right.span(),
|
||||
// op: BinaryOperation::BitAnd,
|
||||
// left: Box::new(expr),
|
||||
// right: Box::new(right),
|
||||
// })
|
||||
// }
|
||||
// Ok(expr)
|
||||
// }
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary equals or not equals expression.
|
||||
///
|
||||
@ -222,31 +162,6 @@ impl ParserContext<'_> {
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary shift expression.
|
||||
///
|
||||
/// Otherwise, tries to parse the next token using [`parse_additive_expression`].
|
||||
///
|
||||
// pub fn parse_shift_expression(&mut self) -> Result<Expression> {
|
||||
// let mut expr = self.parse_additive_expression()?;
|
||||
// while let Some(SpannedToken { token: op, .. }) = self.eat_any(&[Token::Shl, Token::Shr, Token::ShrSigned]) {
|
||||
// let right = self.parse_additive_expression()?;
|
||||
// expr = Expression::Binary(BinaryExpression {
|
||||
// span: expr.span() + right.span(),
|
||||
// op: match op {
|
||||
// Token::Shl => BinaryOperation::Shl,
|
||||
// Token::Shr => BinaryOperation::Shr,
|
||||
// Token::ShrSigned => BinaryOperation::ShrSigned,
|
||||
// _ => unimplemented!(),
|
||||
// },
|
||||
// left: Box::new(expr),
|
||||
// right: Box::new(right),
|
||||
// })
|
||||
// }
|
||||
// Ok(expr)
|
||||
// }
|
||||
|
||||
/// Returns an [`Expression`] AST node if the next tokens represent a
|
||||
/// binary addition or subtraction expression.
|
||||
///
|
||||
|
@ -26,15 +26,6 @@ const ASSIGN_TOKENS: &[Token] = &[
|
||||
Token::MulEq,
|
||||
Token::DivEq,
|
||||
Token::ExpEq,
|
||||
// Token::BitAndEq,
|
||||
// Token::BitOrEq,
|
||||
// Token::BitXorEq,
|
||||
// Token::ShlEq,
|
||||
// Token::ShrEq,
|
||||
// Token::ShrSignedEq,
|
||||
// Token::ModEq,
|
||||
// Token::OrEq,
|
||||
// Token::AndEq,
|
||||
];
|
||||
|
||||
impl ParserContext<'_> {
|
||||
@ -124,15 +115,6 @@ impl ParserContext<'_> {
|
||||
Token::MulEq => AssignOperation::Mul,
|
||||
Token::DivEq => AssignOperation::Div,
|
||||
Token::ExpEq => AssignOperation::Pow,
|
||||
// Token::OrEq => AssignOperation::Or,
|
||||
// Token::AndEq => AssignOperation::And,
|
||||
// Token::BitOrEq => AssignOperation::BitOr,
|
||||
// Token::BitAndEq => AssignOperation::BitAnd,
|
||||
// Token::BitXorEq => AssignOperation::BitXor,
|
||||
// Token::ShrEq => AssignOperation::Shr,
|
||||
// Token::ShrSignedEq => AssignOperation::ShrSigned,
|
||||
// Token::ShlEq => AssignOperation::Shl,
|
||||
// Token::ModEq => AssignOperation::Mod,
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
value,
|
||||
|
@ -345,14 +345,8 @@ impl Token {
|
||||
}
|
||||
b'&' => {
|
||||
if let Some(len) = eat(input, "&&") {
|
||||
// if let Some(inner_len) = eat(&input[len..], "=") {
|
||||
// return (len + inner_len, Some(Token::AndEq));
|
||||
// }
|
||||
return (len, Some(Token::And));
|
||||
}
|
||||
// else if let Some(len) = eat(input, "&=") {
|
||||
// return (len, Some(Token::BitAndEq));
|
||||
// }
|
||||
return (1, Some(Token::Ampersand));
|
||||
}
|
||||
b'(' => return (1, Some(Token::LeftParen)),
|
||||
@ -421,29 +415,12 @@ impl Token {
|
||||
if let Some(len) = eat(input, "<=") {
|
||||
return (len, Some(Token::LtEq));
|
||||
}
|
||||
// else if let Some(len) = eat(input, "<<") {
|
||||
// if let Some(inner_len) = eat(&input[len..], "=") {
|
||||
// return (len + inner_len, Some(Token::ShlEq));
|
||||
// }
|
||||
// return (len, Some(Token::Shl));
|
||||
// }
|
||||
return (1, Some(Token::Lt));
|
||||
}
|
||||
b'>' => {
|
||||
if let Some(len) = eat(input, ">=") {
|
||||
return (len, Some(Token::GtEq));
|
||||
}
|
||||
// else if let Some(len) = eat(input, ">>") {
|
||||
// if let Some(inner_len) = eat(&input[len..], "=") {
|
||||
// return (len + inner_len, Some(Token::ShrEq));
|
||||
// } else if let Some(inner_len) = eat(&input[len..], ">") {
|
||||
// if let Some(eq_len) = eat(&input[len + inner_len..], "=") {
|
||||
// return (len + inner_len + eq_len, Some(Token::ShrSignedEq));
|
||||
// }
|
||||
// return (len + inner_len, Some(Token::ShrSigned));
|
||||
// }
|
||||
// return (len, Some(Token::Shr));
|
||||
// }
|
||||
return (1, Some(Token::Gt));
|
||||
}
|
||||
b'=' => {
|
||||
@ -459,29 +436,9 @@ impl Token {
|
||||
b'}' => return (1, Some(Token::RightCurly)),
|
||||
b'|' => {
|
||||
if let Some(len) = eat(input, "||") {
|
||||
// if let Some(inner_len) = eat(&input[len..], "=") {
|
||||
// return (len + inner_len, Some(Token::OrEq));
|
||||
// }
|
||||
return (len, Some(Token::Or));
|
||||
}
|
||||
// else if let Some(len) = eat(input, "|=") {
|
||||
// return (len, Some(Token::BitOrEq));
|
||||
// }
|
||||
// return (1, Some(Token::BitOr));
|
||||
}
|
||||
// b'^' => {
|
||||
// if let Some(len) = eat(input, "^=") {
|
||||
// return (len, Some(Token::BitXorEq));
|
||||
// }
|
||||
// return (1, Some(Token::BitXor));
|
||||
// }
|
||||
// b'~' => return (1, Some(Token::BitNot)),
|
||||
// b'%' => {
|
||||
// if let Some(len) = eat(input, "%=") {
|
||||
// return (len, Some(Token::ModEq));
|
||||
// }
|
||||
// return (1, Some(Token::Mod));
|
||||
// }
|
||||
_ => (),
|
||||
}
|
||||
if let Some(ident) = eat_identifier(&input_tendril) {
|
||||
|
@ -118,23 +118,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_tokenizer() {
|
||||
create_session_if_not_set_then(|_| {
|
||||
// &=
|
||||
// |
|
||||
// |=
|
||||
// ^
|
||||
// ^=
|
||||
// ~
|
||||
// <<
|
||||
// <<=
|
||||
// >>
|
||||
// >>=
|
||||
// >>>
|
||||
// >>>=
|
||||
// %
|
||||
// %=
|
||||
// ||=
|
||||
// &&=
|
||||
|
||||
let tokens = tokenize(
|
||||
"test_path",
|
||||
r#"
|
||||
@ -234,7 +217,6 @@ mod tests {
|
||||
output += &format!("{} ", token.to_string());
|
||||
}
|
||||
|
||||
// & &= | |= ^ ^= ~ << <<= >> >>= >>> >>>= % %= ||= &&=
|
||||
assert_eq!(
|
||||
output,
|
||||
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address as bool circuit const else false field for function group i128 i64 i32 i16 i8 if import in input let mut & return static string test true u128 u64 u32 u16 u8 self Self console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : :: ; < <= = == > >= @ [ ] { { } } || ? // test
|
||||
@ -270,7 +252,6 @@ mod tests {
|
||||
let original = &raw[*start + token.span.col_start - 1..*stop + token.span.col_stop - 1];
|
||||
assert_eq!(original, &token_raw);
|
||||
}
|
||||
// println!("{}", serde_json::to_string_pretty(&tokens).unwrap());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -145,24 +145,6 @@ pub enum Token {
|
||||
Static,
|
||||
Type,
|
||||
|
||||
// Not yet in ABNF
|
||||
// BitAndEq,
|
||||
// BitOr,
|
||||
// BitOrEq,
|
||||
// BitXor,
|
||||
// BitXorEq,
|
||||
// BitNot,
|
||||
// Shl,
|
||||
// ShlEq,
|
||||
// Shr,
|
||||
// ShrEq,
|
||||
// ShrSigned,
|
||||
// ShrSignedEq,
|
||||
// Mod,
|
||||
// ModEq,
|
||||
// OrEq,
|
||||
// AndEq,
|
||||
|
||||
// Meta Tokens
|
||||
Eof,
|
||||
}
|
||||
@ -354,22 +336,6 @@ impl fmt::Display for Token {
|
||||
Static => write!(f, "static"),
|
||||
Type => write!(f, "type"),
|
||||
Eof => write!(f, ""),
|
||||
// BitAndEq => write!(f, "&="),
|
||||
// BitOr => write!(f, "|"),
|
||||
// BitOrEq => write!(f, "|="),
|
||||
// BitXor => write!(f, "^"),
|
||||
// BitXorEq => write!(f, "^="),
|
||||
// BitNot => write!(f, "~"),
|
||||
// Shl => write!(f, "<<"),
|
||||
// ShlEq => write!(f, "<<="),
|
||||
// Shr => write!(f, ">>"),
|
||||
// ShrEq => write!(f, ">>="),
|
||||
// ShrSigned => write!(f, ">>>"),
|
||||
// ShrSignedEq => write!(f, ">>>="),
|
||||
// Mod => write!(f, "%"),
|
||||
// ModEq => write!(f, "%="),
|
||||
// OrEq => write!(f, "||="),
|
||||
// AndEq => write!(f, "&&="),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user