Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Char Tokens #25

Merged
merged 3 commits into from
Oct 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gen/org/elixir_lang/parser/ElixirParser.java

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

1 change: 1 addition & 0 deletions gen/org/elixir_lang/psi/ElixirTypes.java

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

Binary file modified screenshots/Color Settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/org/elixir_lang/Elixir.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private quote ::= (charList | string)
stringHeredoc ::= STRING_HEREDOC_PROMOTER EOL
interpolatedStringBody
STRING_HEREDOC_TERMINATOR
private expression ::= (atom | NUMBER | charListHeredoc | quote | sigil | stringHeredoc)
private expression ::= (atom | CHAR_TOKEN | NUMBER | charListHeredoc | quote | sigil | stringHeredoc)
// allow multiple EOLs to separate expressions to handle lines comments
private expressionList ::= expression (EOL+ expression)*
interpolation ::= INTERPOLATION_START expressionList? INTERPOLATION_END
Expand Down
34 changes: 21 additions & 13 deletions src/org/elixir_lang/Elixir.flex
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,25 @@ COLON = :

HEXADECIMAL_DIGIT = [A-Fa-f0-9]

/*
* Escape Sequences
*/

ESCAPE = "\\"

ESCAPED_CHARACTER = {ESCAPE} .
ESCAPED_CHARACTER_CODE = {ESCAPE} "x{" {HEXADECIMAL_DIGIT}{1,6} "}" |
{ESCAPE} "x" {HEXADECIMAL_DIGIT}{1,2}

VALID_ESCAPE_SEQUENCE = {ESCAPED_CHARACTER_CODE} |
{ESCAPED_CHARACTER}

/*
* Char tokens
*/

CHAR_TOKEN = "?" ({VALID_ESCAPE_SEQUENCE} | .)

/*
* White Space
*/
Expand Down Expand Up @@ -308,19 +327,6 @@ SIGIL_HEREDOC_TERMINATOR = ({SIGIL_DOUBLE_QUOTES_TERMINATOR}|{SIGIL_SINGLE_QUOTE
GROUP_TERMINATOR = {QUOTE_TERMINATOR}|{SIGIL_TERMINATOR}
GROUP_HEREDOC_TERMINATOR = {QUOTE_HEREDOC_TERMINATOR}|{SIGIL_HEREDOC_TERMINATOR}

/*
* Escape Sequences
*/

ESCAPE = "\\"

ESCAPED_CHARACTER = {ESCAPE} .
ESCAPED_CHARACTER_CODE = {ESCAPE} "x{" {HEXADECIMAL_DIGIT}{1,6} "}" |
{ESCAPE} "x" {HEXADECIMAL_DIGIT}{1,2}

VALID_ESCAPE_SEQUENCE = {ESCAPED_CHARACTER_CODE} |
{ESCAPED_CHARACTER}

/*
* States - Ordered lexigraphically
*/
Expand Down Expand Up @@ -350,6 +356,8 @@ VALID_ESCAPE_SEQUENCE = {ESCAPED_CHARACTER_CODE} |
// This rule is only meant to match whitespace surrounded by other tokens as the above rule will handle blank lines.
{WHITE_SPACE}+ { return TokenType.WHITE_SPACE; }

{CHAR_TOKEN} { return ElixirTypes.CHAR_TOKEN; }

{COLON} { pushAndBegin(ATOM_START);
return ElixirTypes.COLON; }

Expand Down
3 changes: 2 additions & 1 deletion src/org/elixir_lang/ElixirColorSettingsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
public class ElixirColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
new AttributesDescriptor("Atom", ElixirSyntaxHighlighter.ATOM),
new AttributesDescriptor("Comment", ElixirSyntaxHighlighter.COMMENT),
new AttributesDescriptor("Character List", ElixirSyntaxHighlighter.CHAR_LIST),
new AttributesDescriptor("Character Token", ElixirSyntaxHighlighter.CHAR_TOKEN),
new AttributesDescriptor("Comment", ElixirSyntaxHighlighter.COMMENT),
new AttributesDescriptor("Escape Sequence", ElixirSyntaxHighlighter.VALID_ESCAPE_SEQUENCE),
new AttributesDescriptor("Expression Substitution Mark", ElixirSyntaxHighlighter.EXPRESSION_SUBSTITUTION_MARK),
new AttributesDescriptor("Number", ElixirSyntaxHighlighter.NUMBER),
Expand Down
Loading