use function syntax for log, reserve log, add test
This commit is contained in:
parent
81d670e531
commit
3b07c156ad
6 changed files with 12 additions and 6 deletions
|
@ -715,7 +715,7 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedStatement<'ast, T> {
|
|||
}
|
||||
TypedStatement::Log(ref l, ref expressions) => write!(
|
||||
f,
|
||||
"log!({}, {})",
|
||||
"log({}, {})",
|
||||
l,
|
||||
expressions
|
||||
.iter()
|
||||
|
|
|
@ -431,7 +431,7 @@ impl<'ast> fmt::Display for Statement<'ast> {
|
|||
}
|
||||
Statement::Log(ref l, ref expressions) => write!(
|
||||
f,
|
||||
"log!({}, {})",
|
||||
"log({}, {})",
|
||||
l,
|
||||
expressions
|
||||
.iter()
|
||||
|
|
|
@ -181,7 +181,7 @@ impl<'ast, T: fmt::Display> ZirStatement<'ast, T> {
|
|||
}
|
||||
ZirStatement::Log(ref l, ref expressions) => write!(
|
||||
f,
|
||||
"log!(\"{}\"), {})",
|
||||
"log(\"{}\"), {})",
|
||||
l,
|
||||
expressions
|
||||
.iter()
|
||||
|
|
|
@ -4,6 +4,6 @@ struct Foo {
|
|||
}
|
||||
|
||||
def main(Foo x, field y) {
|
||||
log!("x is {}, y is {}", x, y);
|
||||
log("x is {}, y is {}", x, y);
|
||||
return;
|
||||
}
|
6
zokrates_cli/examples/compile_errors/reserved_log.zok
Normal file
6
zokrates_cli/examples/compile_errors/reserved_log.zok
Normal file
|
@ -0,0 +1,6 @@
|
|||
// "log" is reserved
|
||||
def log():
|
||||
return
|
||||
|
||||
def main()
|
||||
return
|
|
@ -59,7 +59,7 @@ statement = { (iteration_statement // does not require semicolon
|
|||
| assertion_statement
|
||||
) ~ semicolon)) ~ NEWLINE* }
|
||||
|
||||
log_statement = { "log!(\"" ~ format_string ~ "\"" ~ "," ~ expression_list ~ ")"}
|
||||
log_statement = { "log" ~ "(" ~ "\"" ~ format_string ~ "\"" ~ "," ~ expression_list ~ ")"}
|
||||
format_string = { (!"\"" ~ ANY)* }
|
||||
block_statement = _{ "{" ~ NEWLINE* ~ statement* ~ NEWLINE* ~ "}" }
|
||||
iteration_statement = { "for" ~ typed_identifier ~ "in" ~ expression ~ ".." ~ expression ~ block_statement }
|
||||
|
@ -181,6 +181,6 @@ COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ (!NEWLINE ~ ANY)*) }
|
|||
// the ordering of reserved keywords matters: if "as" is before "assert", then "assert" gets parsed as (as)(sert) and incorrectly
|
||||
// accepted
|
||||
keyword = @{
|
||||
"assert"|"as"|"bool"|"const"|"def"|"else"|"false"|"field"|"for"|"if"|"then"|"fi"|"import"|"from"|
|
||||
"log"|"assert"|"as"|"bool"|"const"|"def"|"else"|"false"|"field"|"for"|"if"|"then"|"fi"|"import"|"from"|
|
||||
"in"|"mut"|"private"|"public"|"return"|"struct"|"true"|"u8"|"u16"|"u32"|"u64"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue