// default symbols WHITESPACE = _{ " "+ } COMMENT = _{ "//" ~ (!"\n" ~ ANY)+ } // language custom symbols GL_EMIT = _{ ">" } GL_CONST = _{ "$" } GL_FN = _{ "#" } SY_BRO = _{ "(" } SY_BRC = _{ ")" } SY_UNDERSCORE = _{ "_" } // IDENTIFIER identifier = _{ (ASCII_ALPHANUMERIC | SY_UNDERSCORE)+ } file = _{ SOI ~ body ~ EOI } body = _{ NEWLINE* ~ (statement ~ NEWLINE+) * ~ statement? } statement = _{ const_statement | emit_statement | fn_statement } emit_statement = { GL_EMIT ~ atomic_strip } const_statement = { GL_CONST ~ const_statement_name ~ atomic_strip } const_statement_name = @{ identifier } fn_statement = { GL_FN ~ fn_statement_name ~ fn_statement_body } fn_statement_name = @{ identifier } fn_statement_body = { "{" ~ body ~ "}" } atomic_strip = _{ atom+ } atom = _{ atom_body ~ WHITESPACE? } atom_body = _{ atom_base_number | atom_const_decor | atom_hex | atom_utf8_decor | atom_fn } atom_hex = @{ ASCII_HEX_DIGIT+ } atom_base_number = { atom_base_number_base ~ "x" ~ atom_base_number_value } atom_base_number_base = { ('0'..'9')+ } atom_base_number_value = { ASCII_ALPHANUMERIC+ } atom_utf8 = { ( "''" | (!"'" ~ ANY) )* } atom_utf8_decor = _{ "'" ~ atom_utf8 ~ "'" } atom_const = @{ identifier } atom_const_decor = _{ GL_CONST ~ atom_const } atom_fn = { GL_FN ~ atom_fn_name ~ SY_BRO ~ atom_fn_params? ~ SY_BRC } atom_fn_name = { identifier } atom_fn_params = { (atom_fn_param ~ ",")* ~ atom_fn_param } atom_fn_param_identifier = { identifier } atom_fn_param_value = { atomic_strip } atom_fn_param = { (atom_fn_param_identifier ~ ":")? ~ atom_fn_param_value }