Skip to content

Commit

Permalink
fix: fix parse parse impl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 30, 2022
1 parent e5b25d0 commit 8c4ca03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions crates/fkl_parser/src/parser/fkl.pest
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ impl_decl = {
}

endpoint_decl = {
"endpoint" ~ "{" ~ http_action ~ authorization_decl? ~ http_response_decl ~ "}"
"endpoint" ~ "{" ~ http_action ~ authorization_decl? ~ http_response_decl? ~ "}"
}

http_response_decl = {
"response" ~ ":" ~ identifier
"response" ~ ":" ~ identifier ~ ";"?
}

authorization_decl = {
Expand All @@ -120,19 +120,15 @@ username = { special_string }
password = { special_string }

http_action = {
"GET" ~ custom_param? ~ uri ~ http_body? ~ ";"?
| "POST" ~ custom_param? ~ uri ~ http_body? ~ ";"?
| "PUT" ~ custom_param? ~ uri ~ http_body? ~ ";"?
| "DELETE" ~ custom_param? ~ uri ~ http_body? ~ ";"?
| "PATCH" ~ custom_param? ~ uri ~ http_body? ~ ";"?
("GET" | "POST" | "PUT" | "DELETE" | "PATCH") ~ custom_param? ~ uri ~ http_body? ~ ";"?
}

custom_param = {
"$" ~ "{" ~ identifier ~ "}"
}

uri = {
url_origin? ~ ("/" ~ path?)* ~ query? ~ frag?
url_origin? ~ ("/" ~ path)* ~ (query? ~ frag?)?
}

url_origin = {
Expand All @@ -145,7 +141,7 @@ host = {
}

port = { number }
path = { special_string ~ ("/" ~ special_string)* }
path = { special_string }
query = { "?" ~ special_string ~ ("&" ~ special_string)* }
frag = { "#" ~ special_string }

Expand Down Expand Up @@ -231,7 +227,7 @@ string = @{
}
number = @{ '0'..'9'+ }
int = @{ number | "-" ~ "0"* ~ '1'..'9' ~ number? }
special_string = @{ (ASCII_ALPHANUMERIC | "$" | "{" | "}" | "-" | "-" )* }
special_string = @{ (ASCII_ALPHANUMERIC | "-" | "_" )* }

inline_doc = {
"\"\"\"" ~ (inline_doc | !"\"\"\"" ~ ANY)* ~ "\"\"\""
Expand Down
4 changes: 2 additions & 2 deletions crates/fkl_parser/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,14 +833,14 @@ Aggregate Cinema {

#[test]
fn aggregate_binding_syntax() {
let _decls = parse(r#"Context Cinema {
let result = parse(r#"Context Cinema {
DomainEvent CinemaCreated(impl = CinemaCreatedEvent);
}
impl CinemaCreatedEvent {
endpoint {
GET ${uri}/post;
authorization: Basic {{username}} {{password}};
authorization: Basic admin admin;
response: Cinema;
}
}
Expand Down

0 comments on commit 8c4ca03

Please sign in to comment.