Skip to content

Commit 3db56e0

Browse files
committed
Allow apostrophes in Alex/Happy identifiers
1 parent 6a53b27 commit 3db56e0

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

syntaxes/alex.YAML-tmLanguage

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,23 @@ repository:
2121
- name: comment.line.alex
2222
match: '\-\-.*$'
2323
- include: "#block_comment"
24+
startcode:
25+
patterns:
26+
- name: variable.other.startcode.alex
27+
match: ([\p{Ll}\p{Lu}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)
2428
blocks:
2529
patterns:
2630
- name: meta.block.startcode.alex
27-
begin: (<)\s*(\w*)(?:\s*(,)\s*(\w*))*\s*(>)\s*(\{)
31+
begin: (<)\s*([\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)(?:\s*(,)\s*([\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*))*\s*(>)\s*(\{)
2832
beginCaptures:
2933
"1": { name: punctuation.bracket.startcode.alex }
30-
"2": { name: variable.other.starcode.alex }
34+
"2":
35+
patterns:
36+
- include: '#startcode'
3137
"3": { name: punctuation.comma.startcode.alex }
32-
"4": { name: variable.other.startcode.alex }
38+
"4":
39+
patterns:
40+
- include: '#startcode'
3341
"5": { name: punctuation.bracket.startcode.alex }
3442
"6": { name: punctuation.block.startcode.begin.alex }
3543
end: "}"
@@ -46,14 +54,15 @@ repository:
4654
"0": { name: punctuation.block.end.alex }
4755
patterns:
4856
- include: source.haskell
57+
4958
syntax:
5059
patterns:
5160
- name: entity.name.pragma.alex
52-
match: \%\w+
61+
match: \%([\p{Ll}\p{Lu}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)
5362
- name: entity.name.macro.character-set.alex
54-
match: \$\w+
63+
match: \$([\p{Ll}\p{Lu}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)
5564
- name: entity.name.macro.regular-expression.alex
56-
match: \@\w+
65+
match: \@([\p{Ll}\p{Lu}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)
5766
- name: constant.character.escape.hex.alex
5867
match: \\x[\da-fA-F]+
5968
- name: constant.character.escape.oct.alex
@@ -71,12 +80,16 @@ repository:
7180
- name: punctuation.semicolon.alex
7281
match: \;
7382
- name: meta.startcode.alex
74-
match: (<)\s*(\w*)(?:\s*(,)\s*(\w*))*\s*(>)
83+
match: (<)\s*([\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)(?:\s*(,)\s*([\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*))*\s*(>)
7584
captures:
7685
"1": { name: punctuation.bracket.startcode.alex }
77-
"2": { name: variable.other.starcode.alex }
86+
"2":
87+
patterns:
88+
- include: '#startcode'
7889
"3": { name: punctuation.comma.startcode.alex }
79-
"4": { name: variable.other.startcode.alex }
90+
"4":
91+
patterns:
92+
- include: '#startcode'
8093
"5": { name: punctuation.bracket.startcode.alex }
8194
strings:
8295
patterns:

syntaxes/happy.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repository:
4848
syntax:
4949
patterns:
5050
- name: entity.name.directive.happy
51-
match: \%\w+
51+
match: \%([\p{Ll}\p{Lu}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\.']*)
5252
- name: constant.character.escape.hex.happy
5353
match: \\x[\da-fA-F]+
5454
- name: constant.character.escape.oct.happy

test/tests/Alex2.x

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- SYNTAX TEST "source.haskell.alex" "Alex apostrophes etc"
2+
3+
%_wrapper "basic"
4+
-- <-------- entity.name.pragma.alex
5+
6+
%wrapper' "basic"
7+
-- <-------- entity.name.pragma.alex
8+
9+
%wrap'pe_r_ "basic"
10+
-- <---------- entity.name.pragma.alex
11+
12+
$digit' = 0-9
13+
-- <------ entity.name.macro.character-set.alex
14+
15+
$d'igi_t_ = 0-9
16+
-- <-------- entity.name.macro.character-set.alex

test/tests/Happy2.y

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- SYNTAX TEST "source.haskell.happy" "Happy apostrophes etc"
2+
3+
%_name parse
4+
-- <----- entity.name.directive.happy
5+
6+
%tokentype' { Token }
7+
-- <---------- entity.name.directive.happy
8+
9+
%er'o_r'_ { parseError }
10+
-- <-------- entity.name.directive.happy

0 commit comments

Comments
 (0)