Skip to content

Commit

Permalink
#603: whitespace escape in character literals
Browse files Browse the repository at this point in the history
  • Loading branch information
deadok22 committed May 24, 2015
1 parent d36848a commit 69fc0c6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
24 changes: 10 additions & 14 deletions gen/org/intellij/erlang/parser/_ErlangLexer.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/org/intellij/erlang/parser/Erlang.flex
Expand Up @@ -33,7 +33,8 @@ CommentLine = "%"[^\r\n]*
ModuleDocComment = {ModuleDocCommentLine} {ModuleDocCommentLine}*
FunctionDocComment = {FunctionDocCommentLine} {FunctionDocCommentLine}*
Comment = {CommentLine} {CommentLine}*
Whitespace = ([ \t\n] | {ControlCharacter})+
WhitespaceChar = [ \t\n] | {ControlCharacter}
Whitespace = {WhitespaceChar}+
ErlangUppercase = [A-Z]
ErlangLowercase = [a-z]
ErlangLetter = {ErlangUppercase} | {ErlangLowercase}
Expand All @@ -54,7 +55,7 @@ ControlName = [@A-Z\[\\\]\^_] /* this is the octal range \100 - \137 */
ControlEscape = \\ \^ {ControlName}
EscapeSequence = \\\" | "\\b" | "\\d" | "\\e" | "\\f" | "\\n" | "\\r" | "\\s" | "\\t" | "\\v" | "\\'" | "\\\\" | "\\[" | "\\{" | "\\]" | "\\}" | "\\`" | "\\$" | "\\=" | "\\%" | "\\," | "\\." | "\\_" | {ControlEscape} | {OctalEscape}

CharLiteralChar = {InputCharacter} | {EscapeSequence}
CharLiteralChar = {InputCharacter} | {EscapeSequence} | (\\ {WhitespaceChar})
CharLiteral = \$ {CharLiteralChar} | \$

/* Without the \\\" at the start the lexer won't find it, for unknown reasons */
Expand Down
6 changes: 6 additions & 0 deletions testData/parser/WhitespaceEscapeInCharLiterals.erl
@@ -0,0 +1,6 @@
space() ->
$\ .

newline() ->
$\
.
27 changes: 27 additions & 0 deletions testData/parser/WhitespaceEscapeInCharLiterals.txt
@@ -0,0 +1,27 @@
ERL_FILE
ERL_FUNCTION
ERL_FUNCTION_CLAUSE
ERL_Q_ATOM
ERL_ATOM
PsiElement(atom_name)('space')
ERL_ARGUMENT_DEFINITION_LIST
PsiElement(()('(')
PsiElement())(')')
ERL_CLAUSE_BODY
PsiElement(->)('->')
ERL_MAX_EXPRESSION
PsiElement(char)('$\ ')
PsiElement(.)('.')
ERL_FUNCTION
ERL_FUNCTION_CLAUSE
ERL_Q_ATOM
ERL_ATOM
PsiElement(atom_name)('newline')
ERL_ARGUMENT_DEFINITION_LIST
PsiElement(()('(')
PsiElement())(')')
ERL_CLAUSE_BODY
PsiElement(->)('->')
ERL_MAX_EXPRESSION
PsiElement(char)('$\\n')
PsiElement(.)('.')
1 change: 1 addition & 0 deletions tests/org/intellij/erlang/parser/ErlangParserTest.java
Expand Up @@ -91,4 +91,5 @@ public ErlangParserTest() {
public void testMacrosHacks() { doTest(true, false); }
public void testMacrosUnderscore() { doTest(true, false); }
public void testComprehensionsRecovery() { doTest(true, true); }
public void testWhitespaceEscapeInCharLiterals() { doTest(true, false); }
}

0 comments on commit 69fc0c6

Please sign in to comment.