Skip to content

Commit

Permalink
add missing grammar changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisenwave committed Aug 30, 2024
1 parent e503a1b commit 0d15f80
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

Main
= Declaration / FormatCall
= XDeclarationList / FormatCall

FormatCall "printf-scanf-call"
= FormatScope?
Expand Down Expand Up @@ -93,8 +93,14 @@ PrimaryExpr

// DECLARATIONS

XDeclarationList
= head:Declaration tail:(_ ";" _ Declaration?)* {
return reduceRightRecursion(head, tail)
.filter(x => x !== null);
}

Declaration "declaration"
= declSpecs:DeclarationSpecifiers _ list:InitDeclaratorList (_ ";")* _ {
= declSpecs:DeclarationSpecifiers _ list:InitDeclaratorList {
return {specifiers: declSpecs, declarators: list};
}

Expand Down Expand Up @@ -463,7 +469,7 @@ Comma "comma"
= _ "," _

_ "whitespace"
= ' '?
= [ \n]?

__ "mandatory-whitespace"
= ' '
= [ \n]

0 comments on commit 0d15f80

Please sign in to comment.