// start = ${ SOI ~ NEWLINE* ~ config_definition* ~ declarations* ~ EOI }
start = ${ SOI ~ NEWLINE* ~ config_definition* ~ declarations* ~ EOI }
config_definition = { config_key ~ WHITESPACE* ~ ":" ~ WHITESPACE* ~ config_value ~ NEWLINE* }
config_key = { identifier }
config_value = {
int ~ unit? |
float ~ unit ? |
identifier ~ WHITESPACE* ~ "," ~ WHITESPACE* ~ identifier
}
declarations = {
flow_def
}
flow_def = { flow ~ WHITESPACE* ~ identifier ~ WHITESPACE* ~ "{" ~ interaction_def* ~ WHITESPACE* ~ NEWLINE*~ "}" ~ NEWLINE* }
interaction_def = {
see_def |
do_def |
react_def
}
see_def = { NEWLINE* ~ WHITESPACE* ~ see_text ~ WHITESPACE* ~ ( identifier ) ~ NEWLINE* }
do_def = { do_text }
react_def = { react_text }
action_name = { identifier }
scene_name = { identifier }
animate_name = { identifier }
component_name = { identifier }
component_value = { identifier }
int = @{ "-" ? ~ ("0" | '1'..'9' ~ '0'..'9' * ) }
float = @{
"-" ? ~
(
"0" ~ "." ~ '0'..'9' + |
'1'..'9' ~ '0'..'9' * ~ "." ~ '0'..'9' +
)
}
double_quoted_string = @{ "\"" ~ (!("\"") ~ ANY)* ~ "\""}
single_quoted_string = @{ "\'" ~ (!("\'") ~ ANY)* ~ "\'"}
backquoted_quoted_string = @{ "`" ~ (!("`") ~ ANY)* ~ "`"}
string = @{
double_quoted_string |
single_quoted_string |
backquoted_quoted_string
}
boolean = { "true" | "false" | "True" | "False" }
unit = { "rem" | "px" | "em" }
goto_text = { "goto" | "GOTO" | "跳转"}
show_key = { "show" | "SHOW" | "展示" }
flow = @{ "flow" | "流" }
see_text = { "see" | "SEE" | "看到" }
do_text = { "do" | "DO" | "做" }
react_text = { "react" | "REACT" | "响应" }
with_text = { "with" | "WITH" | "使用" }
animate = { "animte" | "ANIMATE" | "动画" }
repeat = { "repeat" }
layout = { "layout" | "Layout" | "布局" }
page = { "page" | "PAGE" | "页面" }
component = { "component" | "COMPONENT" | "组件" }
position = { "LEFT" | "RIGHT" | "TOP" | "BOTTOM" }
style = { "style" | "STYLE" | "CSS" | "css" }
library = { "library" | "LIBRARY" | "库" }
lparen = { "(" }
rparen = { ")" }
lbrace = @{ "{" }
rbrace = @{ "}" }
lbrack = { "[" }
rbrack = { "]" }
quote = { "\""}
singlequote = { "\'"}
colon = { ":"}
dot = { "."}
comma = { ","}
// todo: remove
// origin identifier
chars = @{ (ASCII_ALPHA | ASCII_ALPHANUMERIC | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
// todo: simplify code to like java
// ~[\u0000-\u007F\uD800-\uDBFF]
// [\uD800-\uDBFF] [\uDC00-\uDFFF]
Char = _{ "\u{0009}" | "\u{000A}" | "\u{000D}" |
'\u{0020}'..'\u{D7FF}' | '\u{E000}'..'\u{FFFD}' |
'\u{10000}'..'\u{10FFFF}' }
S = _{ "\u{0020}" | "\u{0009}" | "\u{000D}" | "\u{000A}" }
utf8 = { (!S ~ Char)* }
identifier = { chars | utf8 }
WHITESPACE = _{ " " | "\t" | "\\" ~ NEWLINE}
COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ (!NEWLINE ~ ANY)*) }