From 2baeace2356f971ddea47844aa8537873d271b1f Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 23 Sep 2016 06:16:23 +0200 Subject: [PATCH] JSON example: Expand some one-line rules to multiple lines Blocks of one-line rules with aligned "=" signs should be used only in cases where the rules are symmetric and we want to emphasize that. Follow-up to ff7193776e62d451b740b391a803246d89d31108. --- examples/json.pegjs | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/examples/json.pegjs b/examples/json.pegjs index aaf0951..e77ac80 100644 --- a/examples/json.pegjs +++ b/examples/json.pegjs @@ -84,15 +84,32 @@ array number "number" = minus? int frac? exp? { return parseFloat(text()); } -decimal_point = "." -digit1_9 = [1-9] -e = [eE] -exp = e (minus / plus)? DIGIT+ -frac = decimal_point DIGIT+ -int = zero / (digit1_9 DIGIT*) -minus = "-" -plus = "+" -zero = "0" +decimal_point + = "." + +digit1_9 + = [1-9] + +e + = [eE] + +exp + = e (minus / plus)? DIGIT+ + +frac + = decimal_point DIGIT+ + +int + = zero / (digit1_9 DIGIT*) + +minus + = "-" + +plus + = "+" + +zero + = "0" // ----- 7. Strings ----- @@ -117,9 +134,14 @@ char ) { return sequence; } -escape = "\\" -quotation_mark = '"' -unescaped = [^\0-\x1F\x22\x5C] +escape + = "\\" + +quotation_mark + = '"' + +unescaped + = [^\0-\x1F\x22\x5C] // ----- Core ABNF Rules -----