Skip to content

Commit

Permalink
Merge pull request #418 from WebFreak001/add-dparse-strings
Browse files Browse the repository at this point in the history
add dparse.strings utility to unescape strings
  • Loading branch information
WebFreak001 authored Jun 25, 2020
2 parents 1557eb0 + 5ac08e9 commit 311e4d4
Show file tree
Hide file tree
Showing 2 changed files with 713 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/dparse/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,28 @@ public enum WhitespaceBehavior : ubyte
skip = 0b0000_0001,
}

private enum stringBehaviorNotWorking = "Automatic string parsing is not "
~ "supported and was previously not working. To unescape strings use the "
~ "`dparse.strings : unescapeString` function on the token texts instead.";

/**
* Configure string lexing behavior
*/
public enum StringBehavior : ubyte
// was enum, but struct now for deprecations and support with old compilers
public struct StringBehavior
{
/// Do not include quote characters, process escape sequences
compiler = 0b0000_0000,
/// Opening quotes, closing quotes, and string suffixes are included in the
/// string token
includeQuoteChars = 0b0000_0001,
deprecated(stringBehaviorNotWorking) static immutable StringBehavior compiler = StringBehavior(0b0000_0000);
/// Opening quotes, closing quotes, and string suffixes are included in
/// the string token
deprecated(stringBehaviorNotWorking) static immutable StringBehavior includeQuoteChars = StringBehavior(0b0000_0001);
/// String escape sequences are not replaced
notEscaped = 0b0000_0010,
deprecated(stringBehaviorNotWorking) static immutable StringBehavior notEscaped = StringBehavior(0b0000_0010);
/// Not modified at all. Useful for formatters or highlighters
source = includeQuoteChars | notEscaped
static immutable StringBehavior source = StringBehavior(0b0000_0011);

ubyte behavior;
alias behavior this;
}

public enum CommentBehavior : bool
Expand Down
Loading

0 comments on commit 311e4d4

Please sign in to comment.