Skip to content

Commit

Permalink
fixed string escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmasoldi3r committed Nov 4, 2023
1 parent 1894ff1 commit 68ed578
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/basic.saturn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let some_var = "foo";
let some_char = 'a'; // This is a number actually.
some_char += 1;
print(some_var, some_char);
print("Escape \"quotes\"");

// Mutate them
some_var = 5;
Expand Down
4 changes: 3 additions & 1 deletion src/parser/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ peg::parser! {
/ expected!("Number literal")

rule string_literal() -> StringLiteral
= "\"" value:$((!"\"" ANY())*) "\"" { StringLiteral::Double(value.into()) }
= "\"" value:$(
( "\\\"" / (!"\"" ANY()) )*
) "\"" { StringLiteral::Double(value.into()) }
/ expected!("String literal")

rule vector_literal() -> Vector
Expand Down

0 comments on commit 68ed578

Please sign in to comment.