1 /* Sets the line_start variable to ts.
2 * This is typically used for the SPACE entity in the main action.
4 #define ls { if (!line_start) line_start = ts; }
6 /* The C equivalent of the Ragel 'code' action.
7 * This is tyically used in the main action for entities where Ragel actions
8 * cannot, for one reason or another, be used.
11 if (!line_contains_code && !line_start) line_start = ts; \
12 line_contains_code = 1; \
15 /* The C equivalent of the Ragel 'comment' action.
16 * This is typically unused, but here for consistency.
19 if (!line_contains_code) { \
20 whole_line_comment = 1; \
21 if (!line_start) line_start = ts; \
25 /* Executes standard line counting actions for INTERNAL_NL entities.
26 * This is typically used in the main action for the INTERNAL_NL entity.
27 * @param lang The language name string.
29 #define std_internal_newline(lang) { \
30 if (callback && p > line_start) { \
31 if (line_contains_code) \
32 callback(lang, "lcode", cint(line_start), cint(p)); \
33 else if (whole_line_comment) \
34 callback(lang, "lcomment", cint(line_start), cint(p)); \
36 callback(lang, "lblank", cint(line_start), cint(p)); \
38 whole_line_comment = 0; \
39 line_contains_code = 0; \
43 /* Executes standard line counting actions for NEWLINE entities.
44 * This is typically used in the main action for the NEWLINE entity.
45 * @param lang The language name string.
47 #define std_newline(lang) {\
48 if (callback && te > line_start) { \
49 if (line_contains_code) \
50 callback(lang, "lcode", cint(line_start), cint(te)); \
51 else if (whole_line_comment) \
52 callback(lang, "lcomment", cint(line_start), cint(te)); \
54 callback(lang, "lblank", cint(ts), cint(te)); \
56 whole_line_comment = 0; \
57 line_contains_code = 0; \
61 /* Processes the last line for buffers that don't have a newline at EOF.
62 * This is typically used at the end of the parse_lang function after the Ragel
63 * parser has been executed.
64 * @param lang The language name string.
66 #define process_last_line(lang) {\
67 if ((whole_line_comment || line_contains_code) && callback) { \
68 if (line_contains_code) \
69 callback(lang, "lcode", cint(line_start), cint(pe)); \
70 else if (whole_line_comment) \
71 callback(lang, "lcomment", cint(line_start), cint(pe)); \