rqml/pest/qml.pest

38 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-07-04 18:35:37 +00:00
COMMENT = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" }
string = ${ "\"" ~ inner ~ "\"" }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}
number = @{
"-"?
~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)
~ ("." ~ ASCII_DIGIT*)?
~ (^"e" ~ ("+" | "-")? ~ ASCII_DIGIT+)?
}
alpha = { 'a'..'z' | 'A'..'Z' }
digit = { '0'..'9' }
ident = { (alpha | digit | ".")+}
version = {digit* ~ "." ~ digit*}
2020-07-05 23:23:22 +00:00
import = {"import" ~ WHITE_SPACE ~ ident ~ WHITE_SPACE ~ NEWLINE*}
2020-07-04 18:35:37 +00:00
2020-07-04 21:58:15 +00:00
function_code = {
!( // if the following text is not
"]]" // a space
)
~ ANY // then consume one character
}
function = {WHITE_SPACE* ~ ident ~ WHITE_SPACE* ~ "=" ~ WHITE_SPACE* ~ "[[" ~ function_code* ~ "]]" ~ NEWLINE* }
2020-07-06 03:45:09 +00:00
property = {WHITE_SPACE* ~ ident ~ ":" ~ WHITE_SPACE* ~ (number|string |ident|("[[" ~ function_code* ~ "]]")) ~ NEWLINE* }
2020-07-04 18:35:37 +00:00
2020-07-05 23:30:07 +00:00
body = {WHITE_SPACE* ~ ident ~ WHITE_SPACE ~ "{" ~ NEWLINE* ~ (property|function|body)* ~ NEWLINE* ~ WHITE_SPACE* ~ "}" ~ NEWLINE?}
2020-07-04 18:35:37 +00:00
qml = {import* ~ NEWLINE* ~ body}