Skip to content

Commit

Permalink
support for Universal Charcter Names #17
Browse files Browse the repository at this point in the history
  • Loading branch information
matter123 committed Apr 11, 2019
1 parent 3a1c957 commit 0bd47f4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
8 changes: 7 additions & 1 deletion cpp/examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,10 @@ int main() {
[[noreturn]] void func2(/*syntax highlighting*/); // no syntax highlighting
struct st { // syntax highlighting works now
};
void func3();
void func3();

// Universal character name
class LineReader{};
class Line_Reader{};
class Line\u00b7Reader{};
class Line\U0002070EReader{};
12 changes: 6 additions & 6 deletions cpp/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def blockFinderFor( name:"", tag_as:"", start_pattern:nil, needs_semicolon: true
]
)
end
#
#
#
#
# Contexts
#
#
#
#
preprocessor_context = [
"#preprocessor-rule-enabled",
"#preprocessor-rule-disabled",
Expand Down Expand Up @@ -278,13 +278,13 @@ def blockFinderFor( name:"", tag_as:"", start_pattern:nil, needs_semicolon: true
#
universal_character = /\\u[0-9a-fA-F]{4}/.or(/\\U000[0-9a-fA-F]/)
first_character = /[a-zA-Z_]/.or(universal_character)
subsequent_character = /[a-zA-Z0-9]/.or(universal_character)
subsequent_character = /[a-zA-Z0-9_]/.or(universal_character)
identifier = first_character.then(zeroOrMoreOf(subsequent_character))
# todo: make a better name for this function
variableBounds = ->(regex_pattern) do
lookBehindToAvoid(@standard_character).then(regex_pattern).lookAheadToAvoid(@standard_character)
end
variable_name_without_bounds = /[a-zA-Z_]#{@standard_character.without_default_mode_modifiers}*/
variable_name_without_bounds = identifier
# word bounds are inefficient, but they are accurate
variable_name = variableBounds[variable_name_without_bounds]

Expand Down
2 changes: 1 addition & 1 deletion syntaxes/cpp.tmLanguage.json

Large diffs are not rendered by default.

Loading

0 comments on commit 0bd47f4

Please sign in to comment.