Skip to content

Commit

Permalink
fix: Fixed naoina#44
Browse files Browse the repository at this point in the history
  • Loading branch information
soudrug committed Aug 1, 2019
1 parent 9fafd69 commit b5ce969
Show file tree
Hide file tree
Showing 2 changed files with 946 additions and 882 deletions.
14 changes: 9 additions & 5 deletions parse.peg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type tomlParser Peg {
toml
}

TOML <- Expression (newline Expression)* newline? !. { _ = buffer }
TOML <- Expression (newline Expression)* wsnl? !. { _ = buffer }

Expression <- (
<ws table ws comment? (wsnl keyval ws comment?)*> { p.SetTableString(begin, end) }
Expand All @@ -13,12 +13,16 @@ Expression <- (
/ ws
)

newline <- <[\r\n]+> { p.AddLineCount(end - begin) }
newline <- newlineW / newlineU

ws <- [ \t]*
newlineW <- <'\0xd\0xa'+ > { p.AddLineCount((end - begin)/2) }
newlineU <- <'\0xd'+ / '\0xa'+ > { p.AddLineCount(end - begin) }

ws <- ' '* / '\0x9'*
wsnl <- (
[ \t]
/ <[\r\n]> { p.AddLineCount(end - begin) }
' '
/ '\0x9'
/ newline
)*

comment <- '#' <[\t -\0x10FFFF]*>
Expand Down
Loading

0 comments on commit b5ce969

Please sign in to comment.