Getting there
This commit is contained in:
parent
d3488349b4
commit
1f58f0b25e
30
shortcodes.c
30
shortcodes.c
@ -8,7 +8,7 @@ bstring grab_chunk(char *start, char *end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#line 33 "shortcodes.rl"
|
#line 36 "shortcodes.rl"
|
||||||
|
|
||||||
|
|
||||||
bstring parse(char *_input) {
|
bstring parse(char *_input) {
|
||||||
@ -21,7 +21,7 @@ static const int shortcode_error = 0;
|
|||||||
static const int shortcode_en_main = 1;
|
static const int shortcode_en_main = 1;
|
||||||
|
|
||||||
|
|
||||||
#line 37 "shortcodes.rl"
|
#line 40 "shortcodes.rl"
|
||||||
char *eof, *ts, *te = 0;
|
char *eof, *ts, *te = 0;
|
||||||
int cs, act = 0;
|
int cs, act = 0;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ static const int shortcode_en_main = 1;
|
|||||||
cs = shortcode_start;
|
cs = shortcode_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 51 "shortcodes.rl"
|
#line 54 "shortcodes.rl"
|
||||||
|
|
||||||
#line 47 "shortcodes.c"
|
#line 47 "shortcodes.c"
|
||||||
{
|
{
|
||||||
@ -104,16 +104,16 @@ case 4:
|
|||||||
goto st0;
|
goto st0;
|
||||||
tr4:
|
tr4:
|
||||||
#line 20 "shortcodes.rl"
|
#line 20 "shortcodes.rl"
|
||||||
{printf("label: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("name: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st5;
|
goto st5;
|
||||||
tr14:
|
tr14:
|
||||||
#line 23 "shortcodes.rl"
|
#line 26 "shortcodes.rl"
|
||||||
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st5;
|
goto st5;
|
||||||
tr24:
|
tr24:
|
||||||
#line 23 "shortcodes.rl"
|
|
||||||
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
|
||||||
#line 26 "shortcodes.rl"
|
#line 26 "shortcodes.rl"
|
||||||
|
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
|
#line 29 "shortcodes.rl"
|
||||||
{printf("arg: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("arg: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st5;
|
goto st5;
|
||||||
st5:
|
st5:
|
||||||
@ -165,16 +165,16 @@ case 7:
|
|||||||
goto st0;
|
goto st0;
|
||||||
tr6:
|
tr6:
|
||||||
#line 20 "shortcodes.rl"
|
#line 20 "shortcodes.rl"
|
||||||
{printf("label: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("name: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st8;
|
goto st8;
|
||||||
tr15:
|
tr15:
|
||||||
#line 23 "shortcodes.rl"
|
#line 26 "shortcodes.rl"
|
||||||
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st8;
|
goto st8;
|
||||||
tr25:
|
tr25:
|
||||||
#line 23 "shortcodes.rl"
|
|
||||||
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
|
||||||
#line 26 "shortcodes.rl"
|
#line 26 "shortcodes.rl"
|
||||||
|
{printf("value: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
|
#line 29 "shortcodes.rl"
|
||||||
{printf("arg: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("arg: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st8;
|
goto st8;
|
||||||
st8:
|
st8:
|
||||||
@ -246,8 +246,8 @@ case 10:
|
|||||||
goto st9;
|
goto st9;
|
||||||
goto st0;
|
goto st0;
|
||||||
tr18:
|
tr18:
|
||||||
#line 20 "shortcodes.rl"
|
#line 23 "shortcodes.rl"
|
||||||
{printf("label: '%s'\n", grab_chunk(mark, p)->data);}
|
{printf("argname: '%s'\n", grab_chunk(mark, p)->data);}
|
||||||
goto st11;
|
goto st11;
|
||||||
st11:
|
st11:
|
||||||
if ( ++p == pe )
|
if ( ++p == pe )
|
||||||
@ -337,14 +337,14 @@ case 14:
|
|||||||
_out: {}
|
_out: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 52 "shortcodes.rl"
|
#line 55 "shortcodes.rl"
|
||||||
|
|
||||||
printf("\nLabel is: '%s'\n", label->data);
|
printf("\nLabel is: '%s'\n", label->data);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
bstring output = parse("{{ foo \"sarasa\" foobar foo=\"bar\" }}");
|
bstring output = parse("{{ thename \"onearg\" another arg=\"val3\" }}");
|
||||||
printf("\n%s\n", output->data);
|
printf("\n%s\n", output->data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,23 @@ bstring grab_chunk(char *start, char *end) {
|
|||||||
spc = space*;
|
spc = space*;
|
||||||
sep = space+;
|
sep = space+;
|
||||||
|
|
||||||
label = alpha+
|
name = alpha+
|
||||||
> mark
|
> mark
|
||||||
% {printf("label: '%s'\n", grab_chunk(mark, p)->data);};
|
% {printf("name: '%s'\n", grab_chunk(mark, p)->data);};
|
||||||
|
argname = alpha+
|
||||||
|
> mark
|
||||||
|
% {printf("argname: '%s'\n", grab_chunk(mark, p)->data);};
|
||||||
value = (('"' [^"]* '"') | alnum+)
|
value = (('"' [^"]* '"') | alnum+)
|
||||||
> mark
|
> mark
|
||||||
% {printf("value: '%s'\n", grab_chunk(mark, p)->data);};
|
% {printf("value: '%s'\n", grab_chunk(mark, p)->data);};
|
||||||
arg = (label '=' value)
|
arg = (argname '=' value)
|
||||||
> mark
|
> mark
|
||||||
% {printf("arg: '%s'\n", grab_chunk(mark, p)->data);};
|
% {printf("arg: '%s'\n", grab_chunk(mark, p)->data);};
|
||||||
|
|
||||||
start = '{{';
|
start = '{{';
|
||||||
end = '}}';
|
end = '}}';
|
||||||
|
|
||||||
main := (start spc label (sep (value | arg))* spc end);
|
main := (start spc name (sep (arg | value))* spc end);
|
||||||
|
|
||||||
}%%
|
}%%
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ bstring parse(char *_input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
bstring output = parse("{{ foo \"sarasa\" foobar foo=\"bar\" }}");
|
bstring output = parse("{{ thename \"onearg\" another arg=\"val3\" }}");
|
||||||
printf("\n%s\n", output->data);
|
printf("\n%s\n", output->data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user