more uniform syntax

main
Ziyang Hu 2 years ago
parent 88e2a19d2e
commit cf887b549d

@ -173,8 +173,8 @@ literal = _{ null | boolean | number | string}
// schema
schema_clause = { (schema_put | schema_retract) ~ compound_ident ~ (simple_schema_def | nested_schema_def) }
schema_put = {"put"}
schema_retract = {"retract"}
schema_put = {":put"}
schema_retract = {":retract"}
simple_schema_def = {":" ~ ident+ ~ ";"?}
nested_schema_def = {"{" ~ (nested_schema_clause ~ ",")* ~ nested_schema_clause? ~ "}" ~ ";"?}
nested_schema_clause = {compound_ident ~ ":" ~ ident+}
@ -182,9 +182,9 @@ nested_schema_clause = {compound_ident ~ ":" ~ ident+}
// tx
tx_clause = { (tx_put | tx_retract_all | tx_retract )? ~ ("@" ~ expr)? ~ tx_map ~ ";"? }
tx_put = {"put"}
tx_retract = {"retract"}
tx_retract_all = {"retract_all"}
tx_put = {":put"}
tx_retract = {":retract"}
tx_retract_all = {":retract_all"}
tx_map = {"{" ~ (tx_pair ~ ",")* ~ tx_pair? ~ "}"}
tx_pair = {tx_ident ~ ":" ~ (tx_list | tx_map | expr )}
tx_list = {"[" ~ ((expr | tx_map) ~ ",")* ~ (expr | tx_map)? ~ "]"}

@ -30,15 +30,15 @@ fn air_routes() -> Result<()> {
r#"
:schema
put country {
:put country {
code: string unique,
desc: string
}
put continent {
:put continent {
code: string unique,
desc: string
}
put airport {
:put airport {
iata: string unique,
icao: string index,
city: string index,
@ -51,12 +51,12 @@ fn air_routes() -> Result<()> {
lat: float,
lon: float
}
put route {
:put route {
src: ref,
dst: ref,
distance: int
}
put geo {
:put geo {
contains: ref many,
}
"#,

@ -29,7 +29,7 @@ fn simple() {
db.run_script(
r#"
:schema
put person {
:put person {
id: string unique,
first_name: string index,
last_name: string index,

Loading…
Cancel
Save