fix whitespace definition in pest
This commit is contained in:
parent
9e7f01ca2c
commit
baf8b57804
1 changed files with 12 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
file = { SOI ~ NEWLINE* ~ pragma? ~ NEWLINE* ~ symbol_declaration* ~ EOI }
|
||||
file = { SOI ~ pragma? ~ symbol_declaration* ~ EOI }
|
||||
|
||||
pragma = { "#pragma" ~ "curve" ~ curve }
|
||||
curve = @{ (ASCII_ALPHANUMERIC | "_") * }
|
||||
|
@ -6,7 +6,7 @@ string = @{(!"\"" ~ ANY)*}
|
|||
semicolon = _{";"}
|
||||
quoted_string = _{ "\"" ~ string ~ "\"" }
|
||||
|
||||
symbol_declaration = { (((import_directive | const_definition | type_definition) ~ semicolon) | (ty_struct_definition | function_definition)) ~ NEWLINE* }
|
||||
symbol_declaration = { (((import_directive | const_definition | type_definition) ~ semicolon) | (ty_struct_definition | function_definition)) }
|
||||
|
||||
import_directive = { main_import_directive | from_import_directive }
|
||||
from_import_directive = { "from" ~ quoted_string ~ "import" ~ import_symbol_list }
|
||||
|
@ -41,8 +41,8 @@ ty_tuple_multiple_inner = _{ ty ~ ("," ~ ty)+ ~ ","? }
|
|||
// structs
|
||||
ty_struct = { identifier ~ explicit_generics? }
|
||||
// type definitions
|
||||
ty_struct_definition = { "struct" ~ identifier ~ constant_generics_declaration? ~ "{" ~ NEWLINE* ~ struct_field_list ~ NEWLINE* ~ "}" ~ NEWLINE* }
|
||||
struct_field_list = _{ (struct_field ~ semicolon ~ NEWLINE*)* }
|
||||
ty_struct_definition = { "struct" ~ identifier ~ constant_generics_declaration? ~ "{" ~ struct_field_list ~ "}" }
|
||||
struct_field_list = _{ (struct_field ~ semicolon)* }
|
||||
struct_field = { typed_identifier }
|
||||
|
||||
vis_private = {"private"}
|
||||
|
@ -57,10 +57,10 @@ statement = { (iteration_statement // does not require semicolon
|
|||
|return_statement
|
||||
| definition_statement
|
||||
| assertion_statement
|
||||
) ~ semicolon)) ~ NEWLINE* }
|
||||
) ~ semicolon)) }
|
||||
|
||||
log_statement = { "log" ~ "(" ~ quoted_string ~ "," ~ expression_list ~ ")"}
|
||||
block_statement = _{ "{" ~ NEWLINE* ~ statement* ~ NEWLINE* ~ "}" }
|
||||
block_statement = _{ "{" ~ statement* ~ "}" }
|
||||
iteration_statement = { "for" ~ typed_identifier ~ "in" ~ expression ~ ".." ~ expression ~ block_statement }
|
||||
return_statement = { "return" ~ expression? }
|
||||
definition_statement = { typed_identifier_or_assignee ~ "=" ~ expression }
|
||||
|
@ -86,7 +86,7 @@ inline_tuple_empty_expression_inner = _{ "" }
|
|||
inline_tuple_single_expression_inner = _{ expression ~ "," }
|
||||
inline_tuple_multiple_expression_inner = _{ expression ~ ("," ~ expression)+ ~ ","? }
|
||||
|
||||
block_expression = _{ "{" ~ NEWLINE* ~ statement* ~ expression ~ NEWLINE* ~ "}" }
|
||||
block_expression = _{ "{" ~ statement* ~ expression ~ "}" }
|
||||
if_else_expression = { "if" ~ expression ~ block_expression ~ "else" ~ block_expression }
|
||||
|
||||
access = { array_access | call_access | dot_access }
|
||||
|
@ -102,12 +102,12 @@ identifier_or_decimal = { identifier | decimal_number }
|
|||
|
||||
primary_expression = { identifier | literal }
|
||||
|
||||
inline_struct_expression = { identifier ~ "{" ~ NEWLINE* ~ inline_struct_member_list ~ NEWLINE* ~ "}" }
|
||||
inline_struct_member_list = _{(inline_struct_member ~ ("," ~ NEWLINE* ~ inline_struct_member)*)? ~ ","? }
|
||||
inline_struct_expression = { identifier ~ "{" ~ inline_struct_member_list ~ "}" }
|
||||
inline_struct_member_list = _{(inline_struct_member ~ ("," ~ inline_struct_member)*)? ~ ","? }
|
||||
inline_struct_member = { identifier ~ ":" ~ expression }
|
||||
|
||||
inline_array_expression = { "[" ~ NEWLINE* ~ inline_array_inner ~ NEWLINE* ~ "]" }
|
||||
inline_array_inner = _{(spread_or_expression ~ ("," ~ NEWLINE* ~ spread_or_expression)*)?}
|
||||
inline_array_expression = { "[" ~ inline_array_inner ~ "]" }
|
||||
inline_array_inner = _{(spread_or_expression ~ ("," ~ spread_or_expression)*)?}
|
||||
spread_or_expression = { spread | expression }
|
||||
range_or_expression = { range | expression }
|
||||
|
||||
|
@ -174,7 +174,7 @@ op_ternary = {"?" ~ expression ~ ":"}
|
|||
op_binary = _ { op_or | op_and | op_bit_xor | op_bit_and | op_bit_or | op_left_shift | op_right_shift | op_equal | op_not_equal | op_lte | op_lt | op_gte | op_gt | op_add | op_sub | op_mul | op_div | op_rem | op_ternary }
|
||||
op_unary = { op_pos | op_neg | op_not }
|
||||
|
||||
WHITESPACE = _{ " " | "\t" | "\\" ~ COMMENT? ~ NEWLINE}
|
||||
WHITESPACE = _{ " " | "\t" | "\\" | COMMENT | NEWLINE }
|
||||
COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ (!NEWLINE ~ ANY)*) }
|
||||
|
||||
// the ordering of reserved keywords matters: if "as" is before "assert", then "assert" gets parsed as (as)(sert) and incorrectly
|
||||
|
|
Loading…
Reference in a new issue