File tree Expand file tree Collapse file tree 5 files changed +235
-217
lines changed Expand file tree Collapse file tree 5 files changed +235
-217
lines changed Original file line number Diff line number Diff line change
1
+ ================================================================================
2
+ Simple tag
3
+ ================================================================================
4
+ *foobar*
5
+ --------------------------------------------------------------------------------
6
+
7
+ (help_file
8
+ (line
9
+ (tag
10
+ (word))))
11
+
12
+ ================================================================================
13
+ Tag in text
14
+ ================================================================================
15
+ *tag* in text
16
+ --------------------------------------------------------------------------------
17
+
18
+ (help_file
19
+ (line
20
+ (tag
21
+ (word))
22
+ (word)
23
+ (word)))
24
+
25
+ ================================================================================
26
+ Tag with lines after
27
+ ================================================================================
28
+ *foo*
29
+ Hello
30
+ --------------------------------------------------------------------------------
31
+
32
+ (help_file
33
+ (line
34
+ (tag
35
+ (word)))
36
+ (line
37
+ (word)))
Original file line number Diff line number Diff line change @@ -5,18 +5,18 @@ module.exports = grammar({
5
5
6
6
rules : {
7
7
// TODO: add the actual grammar rules
8
- help_file : ( $ ) => seq ( $ . line , repeat ( seq ( '\n' , $ . line ) ) ) ,
8
+ help_file : ( $ ) => repeat1 ( $ . line ) ,
9
9
10
10
header : ( $ ) => seq ( $ . tag ) ,
11
11
12
- line : ( $ ) => repeat1 ( $ . _atom ) ,
12
+ line : ( $ ) => prec . right ( seq ( repeat1 ( $ . _atom ) , optional ( '\n' ) ) ) ,
13
13
14
14
_atom : ( $ ) => choice ( $ . word , $ . tag ) ,
15
15
16
- word : ( $ ) => / [ ^ * ' | \n ] \S * [ ^ * ' | \n ] / ,
16
+ word : ( $ ) => / [ ^ * | ' \n \t ] + / ,
17
17
tag : ( $ ) => wrapped_word ( $ , '*' , 'name' ) ,
18
- option : ( $ ) => / ' [ a - z ] + ' / ,
19
- hotlink : ( $ ) => / | [ a - z - ] + | / ,
18
+ option : ( $ ) => wrapped_word ( $ , "'" , 'name' ) ,
19
+ hotlink : ( $ ) => wrapped_word ( $ , '|' , 'destination' ) ,
20
20
} ,
21
21
} ) ;
22
22
Original file line number Diff line number Diff line change 2
2
"name" : " help" ,
3
3
"rules" : {
4
4
"help_file" : {
5
+ "type" : " REPEAT1" ,
6
+ "content" : {
7
+ "type" : " SYMBOL" ,
8
+ "name" : " line"
9
+ }
10
+ },
11
+ "header" : {
5
12
"type" : " SEQ" ,
6
13
"members" : [
7
14
{
8
15
"type" : " SYMBOL" ,
9
- "name" : " line"
10
- },
11
- {
12
- "type" : " REPEAT" ,
13
- "content" : {
14
- "type" : " SEQ" ,
16
+ "name" : " tag"
17
+ }
18
+ ]
19
+ },
20
+ "line" : {
21
+ "type" : " PREC_RIGHT" ,
22
+ "value" : 0 ,
23
+ "content" : {
24
+ "type" : " SEQ" ,
25
+ "members" : [
26
+ {
27
+ "type" : " REPEAT1" ,
28
+ "content" : {
29
+ "type" : " SYMBOL" ,
30
+ "name" : " _atom"
31
+ }
32
+ },
33
+ {
34
+ "type" : " CHOICE" ,
15
35
"members" : [
16
36
{
17
37
"type" : " STRING" ,
18
38
"value" : " \n "
19
39
},
20
40
{
21
- "type" : " SYMBOL" ,
22
- "name" : " line"
41
+ "type" : " BLANK"
23
42
}
24
43
]
25
44
}
26
- }
27
- ]
28
- },
29
- "header" : {
30
- "type" : " SEQ" ,
31
- "members" : [
32
- {
33
- "type" : " SYMBOL" ,
34
- "name" : " tag"
35
- }
36
- ]
37
- },
38
- "line" : {
39
- "type" : " REPEAT1" ,
40
- "content" : {
41
- "type" : " SYMBOL" ,
42
- "name" : " _atom"
45
+ ]
43
46
}
44
47
},
45
48
"_atom" : {
57
60
},
58
61
"word" : {
59
62
"type" : " PATTERN" ,
60
- "value" : " [^*'| \\ n] \\ S*[^*'| \\ n] "
63
+ "value" : " [^*|' \\ n \\ t]+ "
61
64
},
62
65
"tag" : {
63
66
"type" : " SEQ" ,
81
84
]
82
85
},
83
86
"option" : {
84
- "type" : " PATTERN" ,
85
- "value" : " '[a-z]+'"
87
+ "type" : " SEQ" ,
88
+ "members" : [
89
+ {
90
+ "type" : " STRING" ,
91
+ "value" : " '"
92
+ },
93
+ {
94
+ "type" : " FIELD" ,
95
+ "name" : " name" ,
96
+ "content" : {
97
+ "type" : " SYMBOL" ,
98
+ "name" : " word"
99
+ }
100
+ },
101
+ {
102
+ "type" : " STRING" ,
103
+ "value" : " '"
104
+ }
105
+ ]
86
106
},
87
107
"hotlink" : {
88
- "type" : " PATTERN" ,
89
- "value" : " |[a-z-]+|"
108
+ "type" : " SEQ" ,
109
+ "members" : [
110
+ {
111
+ "type" : " STRING" ,
112
+ "value" : " |"
113
+ },
114
+ {
115
+ "type" : " FIELD" ,
116
+ "name" : " destination" ,
117
+ "content" : {
118
+ "type" : " SYMBOL" ,
119
+ "name" : " word"
120
+ }
121
+ },
122
+ {
123
+ "type" : " STRING" ,
124
+ "value" : " |"
125
+ }
126
+ ]
90
127
}
91
128
},
92
129
"extras" : [
Original file line number Diff line number Diff line change 53
53
"type" : " \n " ,
54
54
"named" : false
55
55
},
56
+ {
57
+ "type" : " '" ,
58
+ "named" : false
59
+ },
56
60
{
57
61
"type" : " *" ,
58
62
"named" : false
59
63
},
60
64
{
61
65
"type" : " word" ,
62
66
"named" : true
67
+ },
68
+ {
69
+ "type" : " |" ,
70
+ "named" : false
63
71
}
64
72
]
You can’t perform that action at this time.
0 commit comments