1 // idl_pvwave.rl written by Sylwester Arabas. slayoo<att>igf<dott>fuw<dott>edu<dott>pl.
2 // (it's the tex.rl file with the comment symbol changed from "%" into ";")
4 /************************* Required for every parser *************************/
5 #ifndef RAGEL_IDL_PVWAVE_PARSER
6 #define RAGEL_IDL_PVWAVE_PARSER
8 #include "../parser_macros.h"
10 // the name of the language
11 const char *IDL_PVWAVE_LANG = "idl_pvwave";
13 // the languages entities
14 const char *idl_pvwave_entities[] = {
15 "space", "comment", "string", "any"
18 // constants associated with the entities
20 IDL_PVWAVE_SPACE = 0, IDL_PVWAVE_COMMENT, IDL_PVWAVE_STRING, IDL_PVWAVE_ANY
23 /*****************************************************************************/
28 include common "common.rl";
30 # Line counting machine
32 action idl_pvwave_ccallback {
34 case IDL_PVWAVE_SPACE:
41 std_internal_newline(IDL_PVWAVE_LANG)
44 std_newline(IDL_PVWAVE_LANG)
48 idl_pvwave_comment = ';' @comment nonnewline*;
51 spaces ${ entity = IDL_PVWAVE_SPACE; } => idl_pvwave_ccallback;
53 newline ${ entity = NEWLINE; } => idl_pvwave_ccallback;
54 ^space ${ entity = IDL_PVWAVE_ANY; } => idl_pvwave_ccallback;
59 action idl_pvwave_ecallback {
60 callback(IDL_PVWAVE_LANG, idl_pvwave_entities[entity], cint(ts), cint(te), userdata);
63 idl_pvwave_comment_entity = ';' nonnewline*;
65 idl_pvwave_entity := |*
66 space+ ${ entity = IDL_PVWAVE_SPACE; } => idl_pvwave_ecallback;
67 idl_pvwave_comment_entity ${ entity = IDL_PVWAVE_COMMENT; } => idl_pvwave_ecallback;
73 /************************* Required for every parser *************************/
75 /* Parses a string buffer with IDL_PVWAVE markup.
77 * @param *buffer The string to parse.
78 * @param length The length of the string to parse.
79 * @param count Integer flag specifying whether or not to count lines. If yes,
80 * uses the Ragel machine optimized for counting. Otherwise uses the Ragel
81 * machine optimized for returning entity positions.
82 * @param *callback Callback function. If count is set, callback is called for
83 * every line of code, comment, or blank with 'lcode', 'lcomment', and
84 * 'lblank' respectively. Otherwise callback is called for each entity found.
86 void parse_idl_pvwave(char *buffer, int length, int count,
87 void (*callback) (const char *lang, const char *entity, int start, int end, void *udata),
93 cs = (count) ? idl_pvwave_en_idl_pvwave_line : idl_pvwave_en_idl_pvwave_entity;
96 // if no newline at EOF; callback contents of last line
97 if (count) { process_last_line(IDL_PVWAVE_LANG) }
102 /*****************************************************************************/