Merge pull request #152 from AleoHQ/fix/pest-address

Fix/pest address
This commit is contained in:
Collin Chin 2020-08-04 19:11:41 -07:00 committed by GitHub
commit ba23ea3832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 5 deletions

View File

@ -15,6 +15,7 @@ impl From<Error<Rule>> for SyntaxError {
Rule::type_integer => "`u32`".to_owned(),
Rule::type_field => "`field`".to_owned(),
Rule::type_group => "`group`".to_owned(),
Rule::address => "an aleo address: `aleo1...`".to_owned(),
Rule::file => "an import, circuit, or function".to_owned(),
Rule::identifier => "a variable name".to_owned(),
Rule::type_ => "a type".to_owned(),

View File

@ -209,7 +209,7 @@ group_tuple = {"(" ~ value_number ~ "," ~ value_number ~ ")"}
group_single_or_tuple = {value_number | group_tuple}
// Declared in values/address.rs
address = @{ (LOWERCASE_LETTER | ASCII_DIGIT)* }
address = @{ "aleo" ~ ASCII_DIGIT ~ (LOWERCASE_LETTER | ASCII_DIGIT){58} }
// Declared in values/address_value.rs
value_address = { type_address ~ "(" ~ address ~ ")" }

View File

@ -0,0 +1,3 @@
function main() {
let owner = address();
}

View File

@ -0,0 +1,3 @@
function main() {
let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88);
}

View File

@ -13,11 +13,27 @@ fn test_valid() {
}
#[test]
fn test_invalid() {
let bytes = include_bytes!("invalid.leo");
let program = parse_program(bytes).unwrap();
fn test_invalid_prefix() {
let bytes = include_bytes!("invalid_prefix.leo");
let syntax_error = parse_program(bytes).is_err();
let _output = expect_compiler_error(program);
assert!(syntax_error);
}
#[test]
fn test_invalid_length() {
let bytes = include_bytes!("invalid_length.leo");
let syntax_error = parse_program(bytes).is_err();
assert!(syntax_error);
}
#[test]
fn test_empty() {
let bytes = include_bytes!("empty.leo");
let syntax_error = parse_program(bytes).is_err();
assert!(syntax_error);
}
#[test]