diff options
Diffstat (limited to 'src/ragel')
-rw-r--r-- | src/ragel/ragel.rl | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ragel/ragel.rl b/src/ragel/ragel.rl index 4974bd5..03c6eb3 100644 --- a/src/ragel/ragel.rl +++ b/src/ragel/ragel.rl @@ -4,8 +4,6 @@ #include <stdarg.h> #include <assert.h> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) - %%{ machine ragel; write data noerror nofinal; @@ -13,16 +11,18 @@ action red { fputs("\x1b[31m", stderr); } action reset { fputs("\x1b[0m", stderr); } action end { fputs("\x1b[0m\n", stderr); } - action mark { fputc('^', stderr); } - action tail { fputc('~', stderr); } + action mark { fputc((fpc == *error ? '^' : '~'), stderr); } action lead { fputc(' ', stderr); } + action char { fputc(fc, stderr); } + + valid = ^cntrl - space - punct; + mark_token = (space valid | punct) ${ *error = fpc; }; + search_err := ((any | mark_token) when { fpc != ragel->pe && fpc <= ragel->p })*; - word = alnum*; - token = ' ' | punct; + word = print | valid*; until_err = (any when { fpc != *error })*; - search_err := ((any | token %{ *error = fpc; }) when { fpc != ragel->pe && fpc <= ragel->p })*; - print_err := (until_err %red <: word %reset <: (any - '\n')*) ${ fputc(fc, stderr); } >lead %!end %/end; - print_mark := (until_err ${ fputc(' ', stderr); } %red %mark <: any word $tail) >lead %!end %/end; + print_err := (until_err <: word >red %reset <: (print - '\n')*) $char >*lead %!end %/end; + print_mark := (until_err $lead <: word >red $mark) >*lead %!end %/end; }%% static void |