Skip to content

Commit

Permalink
Merge pull request #13 from koraktor/parslet-newlines
Browse files Browse the repository at this point in the history
Add support for CR and CRLF newlines
  • Loading branch information
parkr committed Sep 1, 2014
2 parents 7a00092 + 43554a4 commit d39648b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/toml/parslet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class Parslet < ::Parslet::Parser
space >> key.as(:key) >>
space >> str("=") >>
space >> value.as(:value) >>
space >> comment.maybe >> str("\n") >> all_space
space >> comment.maybe >> newline >> all_space
}
rule(:table) {
space >> str("[") >>
table_name.as(:table) >>
str("]") >>
space >> comment.maybe >> str("\n") >> all_space
space >> comment.maybe >> newline >> all_space
}
rule(:table_array) {
space >> str("[[") >>
Expand All @@ -57,11 +57,12 @@ class Parslet < ::Parslet::Parser
rule(:key) { match["^. \t\\]"].repeat(1) }
rule(:table_name) { key.as(:key) >> (str(".") >> key.as(:key)).repeat }

rule(:comment_line) { comment >> str("\n") >> all_space }
rule(:comment_line) { comment >> newline >> all_space }
rule(:comment) { str("#") >> match["^\n"].repeat }

rule(:space) { match[" \t"].repeat }
rule(:all_space) { match[" \t\r\n"].repeat }
rule(:newline) { str("\r").maybe >> str("\n") | str("\r") >> str("\n").maybe }

rule(:string) {
str('"') >> (
Expand Down

0 comments on commit d39648b

Please sign in to comment.