@@ -26,7 +26,7 @@ prog_language_rep::prog_language_rep (string name)
2626 if (DEBUG_PARSER)
2727 debug_packrat << " Building the " * name * " language parser" << LF;
2828 inline_comment_requires_space= false ;
29- path_parser_enabled= false ;
29+ path_parser_enabled = false ;
3030
3131 string use_modules= " (use-modules (code " * name * " -lang))" ;
3232 eval (use_modules);
@@ -249,8 +249,8 @@ prog_language_rep::customize_path (tree config) {
249249static bool
250250is_path_token_delim (char c) {
251251 return is_space (c) || c == ' (' || c == ' )' || c == ' {' || c == ' }' ||
252- c == ' [' || c == ' ]' || c == ' ;' || c == ' |' || c == ' &' ||
253- c == ' < ' || c == ' >' ;
252+ c == ' [' || c == ' ]' || c == ' ;' || c == ' |' || c == ' &' || c == ' < ' ||
253+ c == ' >' ;
254254}
255255
256256static bool
@@ -264,13 +264,17 @@ looks_like_path_token (string token) {
264264
265265 bool has_dot = false ;
266266 bool has_alpha= false ;
267+ bool has_digit= false ;
267268 bool has_at = false ;
268269 bool has_colon= false ;
270+ bool has_dash = false ;
269271 for (int i= 0 ; i < N (token); i++) {
270272 char c= token[i];
271273 if (c == ' /' || c == ' \\ ' ) return true ;
272274 if (c == ' .' ) has_dot= true ;
273275 if (is_alpha (c)) has_alpha= true ;
276+ if (is_digit (c)) has_digit= true ;
277+ if (c == ' -' ) has_dash= true ;
274278 if (c == ' @' ) has_at= true ;
275279 if (c == ' :' ) has_colon= true ;
276280 if (c == ' :' && i + 2 < N (token) && token[i + 1 ] == ' /' &&
@@ -279,12 +283,12 @@ looks_like_path_token (string token) {
279283 }
280284
281285 if (N (token) >= 2 && token[0 ] == ' .' && token[1 ] == ' /' ) return true ;
282- if (N (token) >= 3 && token[0 ] == ' .' && token[1 ] == ' .' &&
283- token[2 ] == ' /' )
286+ if (N (token) >= 3 && token[0 ] == ' .' && token[1 ] == ' .' && token[2 ] == ' /' )
284287 return true ;
285288 if (N (token) >= 2 && token[0 ] == ' ~' && token[1 ] == ' /' ) return true ;
286289 if (has_at && has_colon) return true ;
287290 if (has_dot && has_alpha) return true ;
291+ if (token[0 ] != ' -' && has_dash && has_alpha && has_digit) return true ;
288292 return false ;
289293}
290294
@@ -295,7 +299,8 @@ parse_path_token (string s, int& pos) {
295299
296300 int start= pos;
297301 int end = pos;
298- while (end < N (s) && !is_path_token_delim (s[end])) end++;
302+ while (end < N (s) && !is_path_token_delim (s[end]))
303+ end++;
299304 string token= s (start, end);
300305 if (!looks_like_path_token (token)) return false ;
301306 pos= end;
@@ -392,8 +397,7 @@ prog_language_rep::get_color (tree t, int start, int end) {
392397 int pos= 0 ;
393398 while (pos <= start) {
394399 if (inline_comment_parser.can_parse (s, pos)) {
395- if (!inline_comment_requires_space ||
396- (pos == 0 || is_space (s[pos - 1 ])))
400+ if (!inline_comment_requires_space || (pos == 0 || is_space (s[pos - 1 ])))
397401 return decode_color (lan_name, encode_color (" comment" ));
398402 }
399403 pos++;
0 commit comments