removed dead code from lexer

This commit is contained in:
0rphon 2022-02-18 15:49:39 -07:00
parent d46a041895
commit 938f1fdbc1
15 changed files with 818 additions and 170 deletions

11
cover.sh Executable file
View File

@ -0,0 +1,11 @@
cargo clean
cd parser
export RUSTFLAGS=-Cinstrument-coverage
cargo build
export LLVM_PROFILE_FILE=../target/out/leo_coverage-%p-%m.profraw
cargo test -- test::parser_tests --exact --nocapture
grcov ../target/out -s . --binary-path ../target/debug/ -t html --branch --ignore-not-existing -o ../target/debug/coverage/
cd ..
rm default.profraw
export RUSTFLAGS=
export LLVM_PROFILE_FILE=

View File

@ -78,20 +78,16 @@ impl Token {
return None;
}
if let Some(character) = escaped.chars().next() {
return match character {
'0' => Some(Char::Scalar(0 as char)),
't' => Some(Char::Scalar(9 as char)),
'n' => Some(Char::Scalar(10 as char)),
'r' => Some(Char::Scalar(13 as char)),
'\"' => Some(Char::Scalar(34 as char)),
'\'' => Some(Char::Scalar(39 as char)),
'\\' => Some(Char::Scalar(92 as char)),
_ => None,
};
} else {
return None;
}
return match escaped.chars().next().unwrap() {
'0' => Some(Char::Scalar(0 as char)),
't' => Some(Char::Scalar(9 as char)),
'n' => Some(Char::Scalar(10 as char)),
'r' => Some(Char::Scalar(13 as char)),
'\"' => Some(Char::Scalar(34 as char)),
'\'' => Some(Char::Scalar(39 as char)),
'\\' => Some(Char::Scalar(92 as char)),
_ => None,
};
}
if hex {

4
test.sh Executable file
View File

@ -0,0 +1,4 @@
export CLEAR_LEO_TEST_EXPECTATIONS=1
cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture
# cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture 2>&1 | grep -A 2 dbg
export CLEAR_LEO_TEST_EXPECTATIONS=

View File

@ -1,55 +1,576 @@
---
namespace: Token
namespace: ParseExpression
expectation: Pass
outputs:
- "'a' @ 1:1-4"
- "'Z' @ 1:1-4"
- "'\"' @ 1:1-5"
- "'' @ 1:1-5"
- "'' @ 1:1-5"
- "'\u0000' @ 1:1-5"
- "'\u000f' @ 1:1-8"
- "'' @ 1:1-6"
- "'å' @ 1:1-9"
- "'å' @ 1:1-5"
- "'Ӡ' @ 1:1-10"
- "'Ӡ' @ 1:1-5"
- "'❤' @ 1:1-11"
- "'❤' @ 1:1-6"
- "'😢' @ 1:1-12"
- "'😭' @ 1:1-7"
- "'􀀟' @ 1:1-13"
- "'*' @ 1:1-7"
- "'\u007f' @ 1:1-7"
- "'\u0000' @ 1:1-7"
- "'\u0001' @ 1:1-7"
- "'\u0002' @ 1:1-7"
- "'\u0003' @ 1:1-7"
- "'\u0004' @ 1:1-7"
- "'\u0005' @ 1:1-7"
- "'\u0006' @ 1:1-7"
- "'\u0007' @ 1:1-7"
- "'\u0010' @ 1:1-7"
- "'\u0011' @ 1:1-7"
- "'\u0012' @ 1:1-7"
- "'\u0013' @ 1:1-7"
- "'\u0014' @ 1:1-7"
- "'\u0015' @ 1:1-7"
- "'\u0016' @ 1:1-7"
- "'\u0017' @ 1:1-7"
- "'' @ 1:1-7"
- "'!' @ 1:1-7"
- "'\"' @ 1:1-7"
- "'#' @ 1:1-7"
- "'$' @ 1:1-7"
- "'%' @ 1:1-7"
- "'&' @ 1:1-7"
- "''' @ 1:1-7"
- "'0' @ 1:1-7"
- "'1' @ 1:1-7"
- "'2' @ 1:1-7"
- "'3' @ 1:1-7"
- "'4' @ 1:1-7"
- "'5' @ 1:1-7"
- "'6' @ 1:1-7"
- "'7' @ 1:1-7"
- Value:
Char:
character:
Scalar: 97
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 4
path: ""
content: "'a'"
- Value:
Char:
character:
Scalar: 90
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 4
path: ""
content: "'Z'"
- Value:
Char:
character:
Scalar: 34
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'\\\"'"
- Value:
Char:
character:
Scalar: 39
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'\\''"
- Value:
Char:
character:
Scalar: 9
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'\\t'"
- Value:
Char:
character:
Scalar: 13
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'\\r'"
- Value:
Char:
character:
Scalar: 0
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'\\0'"
- Value:
Char:
character:
Scalar: 15
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 8
path: ""
content: "'\\u{F}'"
- Value:
Char:
character:
Scalar: 57359
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 6
path: ""
content: "''"
- Value:
Char:
character:
Scalar: 229
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 9
path: ""
content: "'\\u{E5}'"
- Value:
Char:
character:
Scalar: 229
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'å'"
- Value:
Char:
character:
Scalar: 1248
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 10
path: ""
content: "'\\u{4e0}'"
- Value:
Char:
character:
Scalar: 1248
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 5
path: ""
content: "'Ӡ'"
- Value:
Char:
character:
Scalar: 10084
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 11
path: ""
content: "'\\u{2764}'"
- Value:
Char:
character:
Scalar: 10084
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 6
path: ""
content: "'❤'"
- Value:
Char:
character:
Scalar: 128546
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 12
path: ""
content: "'\\u{1F622}'"
- Value:
Char:
character:
Scalar: 128557
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'😭'"
- Value:
Char:
character:
Scalar: 1048607
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 13
path: ""
content: "'\\u{10001F}'"
- Value:
Char:
character:
Scalar: 42
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x2A'"
- Value:
Char:
character:
Scalar: 127
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x7f'"
- Value:
Char:
character:
Scalar: 0
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x00'"
- Value:
Char:
character:
Scalar: 1
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x01'"
- Value:
Char:
character:
Scalar: 2
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x02'"
- Value:
Char:
character:
Scalar: 3
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x03'"
- Value:
Char:
character:
Scalar: 4
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x04'"
- Value:
Char:
character:
Scalar: 5
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x05'"
- Value:
Char:
character:
Scalar: 6
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x06'"
- Value:
Char:
character:
Scalar: 7
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x07'"
- Value:
Char:
character:
Scalar: 16
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x10'"
- Value:
Char:
character:
Scalar: 17
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x11'"
- Value:
Char:
character:
Scalar: 18
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x12'"
- Value:
Char:
character:
Scalar: 19
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x13'"
- Value:
Char:
character:
Scalar: 20
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x14'"
- Value:
Char:
character:
Scalar: 21
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x15'"
- Value:
Char:
character:
Scalar: 22
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x16'"
- Value:
Char:
character:
Scalar: 23
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x17'"
- Value:
Char:
character:
Scalar: 32
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x20'"
- Value:
Char:
character:
Scalar: 33
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x21'"
- Value:
Char:
character:
Scalar: 34
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x22'"
- Value:
Char:
character:
Scalar: 35
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x23'"
- Value:
Char:
character:
Scalar: 36
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x24'"
- Value:
Char:
character:
Scalar: 37
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x25'"
- Value:
Char:
character:
Scalar: 38
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x26'"
- Value:
Char:
character:
Scalar: 39
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x27'"
- Value:
Char:
character:
Scalar: 48
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x30'"
- Value:
Char:
character:
Scalar: 49
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x31'"
- Value:
Char:
character:
Scalar: 50
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x32'"
- Value:
Char:
character:
Scalar: 51
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x33'"
- Value:
Char:
character:
Scalar: 52
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x34'"
- Value:
Char:
character:
Scalar: 53
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x35'"
- Value:
Char:
character:
Scalar: 54
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x36'"
- Value:
Char:
character:
Scalar: 55
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "'\\x37'"

View File

@ -5,6 +5,7 @@ outputs:
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\'\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | 'a\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | ''\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\x9A'\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\x7'\n | ^"
- "Error [EPAR0370000]: '\n --> test:1:1\n |\n 1 | '\\x7g'\n | ^"

View File

@ -10,3 +10,7 @@ outputs:
- "did not consume all input: 'group' @ 1:6-11\n"
- "did not consume all input: 'group' @ 1:12-17\n"
- "did not consume all input: 'group' @ 1:15-20\n"
- "Error [EPAR0370004]: Unexpected white space between terms (123,456) and group\n --> test:1:10\n |\n 1 | (123, 456) group\n | ^"
- "did not consume all input: 'group' @ 1:8-13\n"
- "did not consume all input: 'group' @ 1:16-21\n"
- "did not consume all input: 'bool' @ 1:11-15\n"

View File

@ -1,19 +1,201 @@
---
namespace: Token
namespace: ParseExpression
expectation: Pass
outputs:
- "'\"\"' @ 1:1-3"
- "'\"string\"' @ 1:1-9"
- "'\"another { } string\"' @ 1:1-21"
- "'\"{ ] [ ; a\"' @ 1:1-12"
- "'\"࿺\"' @ 1:1-10"
- "'\"򯫺\"' @ 1:1-12"
- "'\"꾯\"' @ 1:1-11"
- "'\"ૺ\"' @ 1:1-10"
- "'\"¯\"' @ 1:1-9"
- "'\"\n\"' @ 1:1-8"
- "'\"\n\"' @ 1:1-7"
- "'\"\u007f\"' @ 1:1-7"
- "'\"aa \\ \" \n aa \t \r \u0000\"' @ 1:1-28"
- "'\"test 😒€\"' @ 1:1-15"
- "'\"😭😂😘\"' @ 1:1-15"
- Value:
String:
- - Scalar: 115
- Scalar: 116
- Scalar: 114
- Scalar: 105
- Scalar: 110
- Scalar: 103
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 9
path: ""
content: "\"string\""
- Value:
String:
- - Scalar: 97
- Scalar: 110
- Scalar: 111
- Scalar: 116
- Scalar: 104
- Scalar: 101
- Scalar: 114
- Scalar: 32
- Scalar: 123
- Scalar: 32
- Scalar: 125
- Scalar: 32
- Scalar: 115
- Scalar: 116
- Scalar: 114
- Scalar: 105
- Scalar: 110
- Scalar: 103
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 21
path: ""
content: "\"another { } string\""
- Value:
String:
- - Scalar: 123
- Scalar: 32
- Scalar: 93
- Scalar: 32
- Scalar: 91
- Scalar: 32
- Scalar: 59
- Scalar: 32
- Scalar: 97
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 12
path: ""
content: "\"{ ] [ ; a\""
- Value:
String:
- - Scalar: 4090
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 10
path: ""
content: "\"\\u{FFA}\""
- Value:
String:
- - Scalar: 719610
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 12
path: ""
content: "\"\\u{afafa}\""
- Value:
String:
- - Scalar: 44975
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 11
path: ""
content: "\"\\u{afaf}\""
- Value:
String:
- - Scalar: 2810
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 10
path: ""
content: "\"\\u{afa}\""
- Value:
String:
- - Scalar: 175
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 9
path: ""
content: "\"\\u{af}\""
- Value:
String:
- - Scalar: 10
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 8
path: ""
content: "\"\\u{a}\""
- Value:
String:
- - Scalar: 10
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "\"\\x0A\""
- Value:
String:
- - Scalar: 127
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 7
path: ""
content: "\"\\x7F\""
- Value:
String:
- - Scalar: 97
- Scalar: 97
- Scalar: 32
- Scalar: 92
- Scalar: 32
- Scalar: 34
- Scalar: 32
- Scalar: 39
- Scalar: 32
- Scalar: 10
- Scalar: 32
- Scalar: 97
- Scalar: 97
- Scalar: 32
- Scalar: 9
- Scalar: 32
- Scalar: 13
- Scalar: 32
- Scalar: 32
- Scalar: 0
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 30
path: ""
content: "\"aa \\\\ \\\" \\' \\n aa \\t \\r \\0\""
- Value:
String:
- - Scalar: 116
- Scalar: 101
- Scalar: 115
- Scalar: 116
- Scalar: 32
- Scalar: 128530
- Scalar: 8364
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 15
path: ""
content: "\"test 😒€\""
- Value:
String:
- - Scalar: 128557
- Scalar: 128514
- Scalar: 128536
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 15
path: ""
content: "\"😭😂😘\""

View File

@ -4,6 +4,7 @@ expectation: Fail
outputs:
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"Hello world!\n | ^"
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"\\\"\n | ^"
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"\\\n | ^"
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"\\l\"\n | ^"
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"\\uaaa\"\n | ^"
- "Error [EPAR0370000]: \"\n --> test:1:1\n |\n 1 | \"\\u\"\n | ^"

View File

@ -1,11 +1,12 @@
/*
namespace: Token
namespace: ParseExpression
expectation: Pass
*/
'a'
'Z'
'\"'
'\''
'\t'
'\r'
'\0'

View File

@ -9,6 +9,8 @@ expectation: Fail
''
'\
'\x9A'
'\x7'
'\x7g'

View File

@ -1,57 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
'a'
'Z'
'\"'
'\t'
'\r'
'\0'
'\u{F}'
''
'\u{E5}'
'å'
'\u{4e0}'
'Ӡ'
'\u{2764}'
'❤'
'\u{1F622}'
'😭'
'\u{10001F}'
'\x2A'
'\x7f'
'\x00'
'\x01'
'\x02'
'\x03'
'\x04'
'\x05'
'\x06'
'\x07'
'\x10'
'\x11'
'\x12'
'\x13'
'\x14'
'\x15'
'\x16'
'\x17'
'\x20'
'\x21'
'\x22'
'\x23'
'\x24'
'\x25'
'\x26'
'\x27'
'\x30'
'\x31'
'\x32'
'\x33'
'\x34'
'\x35'
'\x36'
'\x37'

View File

@ -18,3 +18,11 @@ expectation: Fail
(123,456u8)group
(123,456field)group
(123, 456) group
(123, )group
(123, 456, 789)group
(123, 456)bool

View File

@ -1,10 +1,8 @@
/*
namespace: Token
namespace: ParseExpression
expectation: Pass
*/
""
"string"
"another { } string"
@ -22,7 +20,7 @@ expectation: Pass
"\x7F"
"aa \\ \" \n aa \t \r \0"
"aa \\ \" \' \n aa \t \r \0"
"test 😒€"
"😭😂😘"

View File

@ -7,6 +7,8 @@ expectation: Fail
"\"
"\
"\l"
"\uaaa"

View File

@ -1,26 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
"string"
"another { } string"
"{ ] [ ; a"
"\u{FFA}"
"\u{afafa}"
"\u{afaf}"
"\u{afa}"
"\u{af}"
"\u{a}"
"\x0A"
"\x7F"
"aa \\ \" \n aa \t \r \0"
"test 😒€"
"😭😂😘"