From 7ad500b3443c6497609ae1c8c003ef49fac1c1e1 Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Mon, 28 Mar 2022 06:53:22 -0700 Subject: [PATCH] remove uneeded circuit syms --- compiler/parser/src/tokenizer/lexer.rs | 3 +-- compiler/parser/src/tokenizer/mod.rs | 6 +----- compiler/parser/src/tokenizer/token.rs | 10 ---------- leo/span/src/symbol.rs | 2 -- .../parser/parser/expression/token_format.leo.out | 5 +---- .../parser/parser/unreachable/define.leo.out | 2 +- .../parser/parser/unreachable/eat_ident.leo.out | 2 +- .../parser/parser/unreachable/eat_int.leo.out | 2 +- .../unreachable/equality_and_order_expression.leo.out | 2 +- .../parser/parser/unreachable/expect_ident.leo.out | 6 +++--- .../parser/parser/unreachable/math_op_fail.leo.out | 4 ++-- tests/parser/expression/token_format.leo | 6 ------ tests/parser/functions/const_self_bad.leo | 8 -------- 13 files changed, 12 insertions(+), 46 deletions(-) delete mode 100644 tests/parser/functions/const_self_bad.leo diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index 7fab42e014..bfb58cb931 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -244,7 +244,7 @@ impl Token { if input.next_if_eq(&'&').is_some() { return Ok((2, Token::And)); } - return Ok((1, Token::Ampersand)); + return Err(ParserError::lexer_empty_input_tendril().into()); } Some('(') => { input.next(); @@ -436,7 +436,6 @@ impl Token { "let" => Token::Let, "mut" => Token::Mut, "return" => Token::Return, - "static" => Token::Static, "true" => Token::True, "type" => Token::Type, "u8" => Token::U8, diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index 7b6d8fd23d..f8d2ba8fd2 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -145,9 +145,7 @@ mod tests { input let mut - & return - static string test true @@ -156,8 +154,6 @@ mod tests { u32 u16 u8 - self - Self console ! != @@ -209,7 +205,7 @@ mod tests { assert_eq!( output, - r#"'a' '😭' "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 + r#"'a' '😭' "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 string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : :: ; < <= = == > >= @ [ ] { { } } || ? // test /* test */ // "# ); }); diff --git a/compiler/parser/src/tokenizer/token.rs b/compiler/parser/src/tokenizer/token.rs index fc58597520..2a55f45b32 100644 --- a/compiler/parser/src/tokenizer/token.rs +++ b/compiler/parser/src/tokenizer/token.rs @@ -135,11 +135,7 @@ pub enum Token { In, Let, Mut, - /// Represents `&`. - /// Used for `Reference` and `BitAnd`. - Ampersand, Return, - Static, Type, // Meta Tokens @@ -171,9 +167,7 @@ pub const KEYWORD_TOKENS: &[Token] = &[ Token::Input, Token::Let, Token::Mut, - Token::Ampersand, Token::Return, - Token::Static, Token::True, Token::Type, Token::U8, @@ -216,9 +210,7 @@ impl Token { Token::Input => sym::input, Token::Let => sym::Let, Token::Mut => sym::Mut, - Token::Ampersand => sym::Ampersand, Token::Return => sym::Return, - Token::Static => sym::Static, Token::True => sym::True, Token::Type => sym::Type, Token::U8 => sym::u8, @@ -321,9 +313,7 @@ impl fmt::Display for Token { In => write!(f, "in"), Let => write!(f, "let"), Mut => write!(f, "mut"), - Ampersand => write!(f, "&"), // Used for `Reference` and `BitAnd` Return => write!(f, "return"), - Static => write!(f, "static"), Type => write!(f, "type"), Eof => write!(f, ""), } diff --git a/leo/span/src/symbol.rs b/leo/span/src/symbol.rs index 214df3f3a1..95aa7f36bd 100644 --- a/leo/span/src/symbol.rs +++ b/leo/span/src/symbol.rs @@ -101,7 +101,6 @@ macro_rules! symbols { symbols! { address, AlwaysConst, - Ampersand: "&", array, As: "as", assert, @@ -138,7 +137,6 @@ symbols! { Return: "return", Star: "*", std, - Static: "static", Struct: "struct", test, True: "true", diff --git a/tests/expectations/parser/parser/expression/token_format.leo.out b/tests/expectations/parser/parser/expression/token_format.leo.out index 51c047f2d5..6d98d2ca3a 100644 --- a/tests/expectations/parser/parser/expression/token_format.leo.out +++ b/tests/expectations/parser/parser/expression/token_format.leo.out @@ -62,8 +62,6 @@ outputs: - "Error [EPAR0370030]: Could not lex the following content: `~`." - "Error [EPAR0370030]: Could not lex the following content: `~`." - "Error [EPAR0370030]: Could not lex the following content: `~`." - - "Error [EPAR0370030]: Could not lex the following content: `~`." - - "Error [EPAR0370030]: Could not lex the following content: `~`." - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'import'\n --> test:1:1\n |\n 1 | import\n | ^^^^^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'as'\n --> test:1:1\n |\n 1 | as\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'console'\n --> test:1:1\n |\n 1 | console\n | ^^^^^^^" @@ -75,7 +73,6 @@ outputs: - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'in'\n --> test:1:1\n |\n 1 | in\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'let'\n --> test:1:1\n |\n 1 | let\n | ^^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'mut'\n --> test:1:1\n |\n 1 | mut\n | ^^^" - - "Error [EPAR0370009]: unexpected string: expected 'expression', got '&'\n --> test:1:1\n |\n 1 | &\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'return'\n --> test:1:1\n |\n 1 | return\n | ^^^^^^" - - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'static'\n --> test:1:1\n |\n 1 | static\n | ^^^^^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'type'\n --> test:1:1\n |\n 1 | type\n | ^^^^" diff --git a/tests/expectations/parser/parser/unreachable/define.leo.out b/tests/expectations/parser/parser/unreachable/define.leo.out index 375ae97a14..d7699d0ea4 100644 --- a/tests/expectations/parser/parser/unreachable/define.leo.out +++ b/tests/expectations/parser/parser/unreachable/define.leo.out @@ -41,7 +41,7 @@ outputs: - "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:5\n |\n 1 | u32 x = 10u8;\n | ^" - "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:5\n |\n 1 | u64 x = 10u8;\n | ^" - "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:6\n |\n 1 | u128 x = 10u8;\n | ^" - - "Error [EPAR0370009]: unexpected string: expected 'expression', got '&'\n --> test:1:1\n |\n 1 | & x = 10u8;\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370005]: expected ; -- got '='\n --> test:1:10\n |\n 1 | return x = 10u8;\n | ^" - "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:6\n |\n 1 | self x = 10u8;\n | ^" - "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:6\n |\n 1 | Self x = 10u8;\n | ^" diff --git a/tests/expectations/parser/parser/unreachable/eat_ident.leo.out b/tests/expectations/parser/parser/unreachable/eat_ident.leo.out index f82e145f71..5c1018440c 100644 --- a/tests/expectations/parser/parser/unreachable/eat_ident.leo.out +++ b/tests/expectations/parser/parser/unreachable/eat_ident.leo.out @@ -2,4 +2,4 @@ namespace: Parse expectation: Fail outputs: - - "Error [EPAR0370005]: expected 'import', 'function', 'test', '@' -- got 'circuit'\n --> test:3:1\n |\n 3 | circuit ;\n | ^^^^^^^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." diff --git a/tests/expectations/parser/parser/unreachable/eat_int.leo.out b/tests/expectations/parser/parser/unreachable/eat_int.leo.out index f2f5151fe2..e3393e9411 100644 --- a/tests/expectations/parser/parser/unreachable/eat_int.leo.out +++ b/tests/expectations/parser/parser/unreachable/eat_int.leo.out @@ -48,7 +48,7 @@ outputs: - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_u32\n | ^" - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_u64\n | ^" - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_u128\n | ^" - - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_&\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_return\n | ^" - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_self\n | ^" - "Error [EPAR0370005]: expected ; -- got '_'\n --> test:1:4\n |\n 1 | x.0_Self\n | ^" diff --git a/tests/expectations/parser/parser/unreachable/equality_and_order_expression.leo.out b/tests/expectations/parser/parser/unreachable/equality_and_order_expression.leo.out index 23a140dc16..2fb078335f 100644 --- a/tests/expectations/parser/parser/unreachable/equality_and_order_expression.leo.out +++ b/tests/expectations/parser/parser/unreachable/equality_and_order_expression.leo.out @@ -47,7 +47,7 @@ outputs: - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 u32 {}\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 u64 {}\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 u128 {}\n | ^^" - - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 & {}\n | ^^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 return {}\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 self {}\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got 'if'\n --> test:1:1\n |\n 1 | if 10 Self {}\n | ^^" diff --git a/tests/expectations/parser/parser/unreachable/expect_ident.leo.out b/tests/expectations/parser/parser/unreachable/expect_ident.leo.out index 5d356e51f1..e98fc9fdc4 100644 --- a/tests/expectations/parser/parser/unreachable/expect_ident.leo.out +++ b/tests/expectations/parser/parser/unreachable/expect_ident.leo.out @@ -47,10 +47,10 @@ outputs: - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'u32'\n --> test:1:4\n |\n 1 | x::u32\n | ^^^" - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'u64'\n --> test:1:4\n |\n 1 | x::u64\n | ^^^" - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'u128'\n --> test:1:4\n |\n 1 | x::u128\n | ^^^^" - - "Error [EPAR0370009]: unexpected string: expected 'ident', got '&'\n --> test:1:4\n |\n 1 | x::&\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'return'\n --> test:1:4\n |\n 1 | x::return\n | ^^^^^^" - - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'self'\n --> test:1:4\n |\n 1 | x::self\n | ^^^^" - - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'Self'\n --> test:1:4\n |\n 1 | x::Self\n | ^^^^" + - "Error [EPAR0370003]: unexpected EOF\n --> test:1:4\n |\n 1 | x::self\n | ^^^^" + - "Error [EPAR0370003]: unexpected EOF\n --> test:1:4\n |\n 1 | x::Self\n | ^^^^" - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'true'\n --> test:1:4\n |\n 1 | x::true\n | ^^^^" - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'false'\n --> test:1:4\n |\n 1 | x::false\n | ^^^^^" - "Error [EPAR0370009]: unexpected string: expected 'ident', got '0'\n --> test:1:4\n |\n 1 | x::0\n | ^" diff --git a/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out b/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out index 1008530bed..a8bcac1e72 100644 --- a/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out +++ b/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out @@ -33,7 +33,7 @@ outputs: - "Error [EPAR0370005]: expected ; -- got 'u32'\n --> test:1:11\n |\n 1 | let x = a u32 b;\n | ^^^" - "Error [EPAR0370005]: expected ; -- got 'u64'\n --> test:1:11\n |\n 1 | let x = a u64 b;\n | ^^^" - "Error [EPAR0370005]: expected ; -- got 'u128'\n --> test:1:11\n |\n 1 | let x = a u128 b;\n | ^^^^" - - "Error [EPAR0370005]: expected ; -- got '&'\n --> test:1:11\n |\n 1 | let x = a & b;\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." - "Error [EPAR0370005]: expected ; -- got 'return'\n --> test:1:11\n |\n 1 | let x = a return b;\n | ^^^^^^" - "Error [EPAR0370005]: expected ; -- got 'self'\n --> test:1:11\n |\n 1 | let x = a self b;\n | ^^^^" - "Error [EPAR0370005]: expected ; -- got 'Self'\n --> test:1:11\n |\n 1 | let x = a Self b;\n | ^^^^" @@ -56,4 +56,4 @@ outputs: - "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:4\n |\n 1 | x>==b;\n | ^" - "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:4\n |\n 1 | x<==b;\n | ^" - "Error [EPAR0370005]: expected ; -- got '..'\n --> test:1:2\n |\n 1 | x..=b;\n | ^^" - - "Error [EPAR0370005]: expected ; -- got '&'\n --> test:1:2\n |\n 1 | x&=b;\n | ^" + - "Error [EPAR0370023]: Expected more characters to lex but found none." diff --git a/tests/parser/expression/token_format.leo b/tests/parser/expression/token_format.leo index 191641644c..0445fe5ce5 100644 --- a/tests/parser/expression/token_format.leo +++ b/tests/parser/expression/token_format.leo @@ -121,12 +121,8 @@ address ~ char ~ -Self ~ - input ~ -self ~ - import as @@ -153,6 +149,4 @@ mut return -static - type \ No newline at end of file diff --git a/tests/parser/functions/const_self_bad.leo b/tests/parser/functions/const_self_bad.leo deleted file mode 100644 index 281dbab043..0000000000 --- a/tests/parser/functions/const_self_bad.leo +++ /dev/null @@ -1,8 +0,0 @@ -/* -namespace: Parse -expectation: Pass -*/ - -function x(const self) { - return (); -} \ No newline at end of file