Bind more, more tests

This commit is contained in:
Roberto Alsina 2023-07-14 16:47:41 -03:00
parent 44619dd1d4
commit 910b7ce861
4 changed files with 312 additions and 316 deletions

View File

@ -17,24 +17,15 @@ describe "Shortcodes" do
result.shortcodes[0].args.size.should eq 0 result.shortcodes[0].args.size.should eq 0
result.shortcodes[0].whole.should eq "{{% shortcode %}}" result.shortcodes[0].whole.should eq "{{% shortcode %}}"
end end
# Ensure(parse, simple_shortcode)
# {
# char *input = "foobar {{% shortcode %}}blah";
# result = parse(input);
# // Only 1 shortcode
# assert_that(result.sccount, is_equal_to(1));
# // It's a simple one called shortcode, no args
# chunk_s(input, result.sc[0].name);
# assert_that(s.s, is_equal_to_string("shortcode"));
# assert_that(result.sc[0].matching, is_equal_to(0));
# assert_that(result.sc[0].argcount, is_equal_to(0));
# // The whole shortcode is the whole thing
# chunk_s(input, result.sc[0].whole);
# assert_that(s.s, is_equal_to_string("{{% shortcode %}}"));
# assert_that(result.errcount, is_equal_to(0));
# }
it "should report mismatched tags" do
input = "foobar {{% shortcode %}}blah{{% /foo %}}"
result = parse(input)
result.shortcodes.size.should eq 1
result.errors.size.should eq 1
result.errors[0].code.should eq ERR_MISMATCHED_CLOSING_TAG
input[result.errors[0].position, 8].should eq "{{% /foo"
end
# Ensure(parse, mismatched_tags) # Ensure(parse, mismatched_tags)
# { # {
# char *input = "foobar {{% shortcode %}}blah{{% /foo %}}"; # char *input = "foobar {{% shortcode %}}blah{{% /foo %}}";

View File

@ -29,6 +29,7 @@ static const int shortcode_en_main = 141;
char *pe = p + len; char *pe = p + len;
sc_result result; sc_result result;
result.errcount = 0;
shortcode *sc_list = result.sc; shortcode *sc_list = result.sc;
int c_sc = 0; int c_sc = 0;
@ -36,14 +37,14 @@ static const int shortcode_en_main = 141;
char *data_mark = p; char *data_mark = p;
#line 40 "shortcodes.c" #line 41 "shortcodes.c"
{ {
cs = shortcode_start; cs = shortcode_start;
} }
#line 132 "shortcodes.rl" #line 133 "shortcodes.rl"
#line 47 "shortcodes.c" #line 48 "shortcodes.c"
{ {
if ( p == pe ) if ( p == pe )
goto _test_eof; goto _test_eof;
@ -64,7 +65,7 @@ st141:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof141; goto _test_eof141;
case 141: case 141:
#line 68 "shortcodes.c" #line 69 "shortcodes.c"
if ( (*p) == 123 ) if ( (*p) == 123 )
goto tr1; goto tr1;
goto st0; goto st0;
@ -85,7 +86,7 @@ st1:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof1; goto _test_eof1;
case 1: case 1:
#line 89 "shortcodes.c" #line 90 "shortcodes.c"
if ( (*p) == 123 ) if ( (*p) == 123 )
goto tr2; goto tr2;
goto st0; goto st0;
@ -99,7 +100,7 @@ st2:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof2; goto _test_eof2;
case 2: case 2:
#line 103 "shortcodes.c" #line 104 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 37: goto st3; case 37: goto st3;
case 60: goto st139; case 60: goto st139;
@ -133,7 +134,7 @@ st4:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof4; goto _test_eof4;
case 4: case 4:
#line 137 "shortcodes.c" #line 138 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr6; case 32: goto tr6;
case 37: goto tr7; case 37: goto tr7;
@ -179,7 +180,7 @@ st5:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof5; goto _test_eof5;
case 5: case 5:
#line 183 "shortcodes.c" #line 184 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st5; case 32: goto st5;
case 34: goto tr11; case 34: goto tr11;
@ -209,7 +210,7 @@ st6:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof6; goto _test_eof6;
case 6: case 6:
#line 213 "shortcodes.c" #line 214 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 123: goto tr18; case 123: goto tr18;
@ -255,7 +256,7 @@ st8:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof8; goto _test_eof8;
case 8: case 8:
#line 259 "shortcodes.c" #line 260 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 123: goto tr1; case 123: goto tr1;
case 125: goto st9; case 125: goto st9;
@ -315,7 +316,7 @@ st142:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof142; goto _test_eof142;
case 142: case 142:
#line 319 "shortcodes.c" #line 320 "shortcodes.c"
if ( (*p) == 123 ) if ( (*p) == 123 )
goto tr25; goto tr25;
goto st10; goto st10;
@ -347,7 +348,7 @@ st11:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof11; goto _test_eof11;
case 11: case 11:
#line 351 "shortcodes.c" #line 352 "shortcodes.c"
if ( (*p) == 123 ) if ( (*p) == 123 )
goto tr26; goto tr26;
goto st10; goto st10;
@ -372,7 +373,7 @@ st12:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof12; goto _test_eof12;
case 12: case 12:
#line 376 "shortcodes.c" #line 377 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 37: goto st13; case 37: goto st13;
case 60: goto st86; case 60: goto st86;
@ -419,7 +420,7 @@ st15:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof15; goto _test_eof15;
case 15: case 15:
#line 423 "shortcodes.c" #line 424 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr32; case 32: goto tr32;
case 37: goto tr33; case 37: goto tr33;
@ -449,7 +450,7 @@ st16:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof16; goto _test_eof16;
case 16: case 16:
#line 453 "shortcodes.c" #line 454 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st16; case 32: goto st16;
case 37: goto st17; case 37: goto st17;
@ -470,7 +471,7 @@ st17:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof17; goto _test_eof17;
case 17: case 17:
#line 474 "shortcodes.c" #line 475 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 123: goto tr25; case 123: goto tr25;
case 125: goto st18; case 125: goto st18;
@ -495,7 +496,7 @@ st19:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof19; goto _test_eof19;
case 19: case 19:
#line 499 "shortcodes.c" #line 500 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr39; case 32: goto tr39;
case 37: goto tr40; case 37: goto tr40;
@ -541,7 +542,7 @@ st20:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof20; goto _test_eof20;
case 20: case 20:
#line 545 "shortcodes.c" #line 546 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st20; case 32: goto st20;
case 34: goto tr44; case 34: goto tr44;
@ -571,7 +572,7 @@ st21:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof21; goto _test_eof21;
case 21: case 21:
#line 575 "shortcodes.c" #line 576 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr51; case 123: goto tr51;
@ -617,7 +618,7 @@ st23:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof23; goto _test_eof23;
case 23: case 23:
#line 621 "shortcodes.c" #line 622 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 123: goto tr25; case 123: goto tr25;
case 125: goto st24; case 125: goto st24;
@ -659,7 +660,7 @@ st25:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof25; goto _test_eof25;
case 25: case 25:
#line 663 "shortcodes.c" #line 664 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 123: goto tr25; case 123: goto tr25;
case 125: goto st26; case 125: goto st26;
@ -695,7 +696,7 @@ st27:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof27; goto _test_eof27;
case 27: case 27:
#line 699 "shortcodes.c" #line 700 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr58; case 123: goto tr58;
@ -722,7 +723,7 @@ st28:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof28; goto _test_eof28;
case 28: case 28:
#line 726 "shortcodes.c" #line 727 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 37: goto st29; case 37: goto st29;
@ -773,7 +774,7 @@ st31:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof31; goto _test_eof31;
case 31: case 31:
#line 777 "shortcodes.c" #line 778 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr64; case 32: goto tr64;
case 34: goto st22; case 34: goto st22;
@ -804,7 +805,7 @@ st32:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof32; goto _test_eof32;
case 32: case 32:
#line 808 "shortcodes.c" #line 809 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st32; case 32: goto st32;
case 34: goto st22; case 34: goto st22;
@ -826,7 +827,7 @@ st33:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof33; goto _test_eof33;
case 33: case 33:
#line 830 "shortcodes.c" #line 831 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr51; case 123: goto tr51;
@ -888,7 +889,7 @@ st143:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof143; goto _test_eof143;
case 143: case 143:
#line 892 "shortcodes.c" #line 893 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr51; case 123: goto tr51;
@ -904,7 +905,7 @@ st35:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof35; goto _test_eof35;
case 35: case 35:
#line 908 "shortcodes.c" #line 909 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr71; case 32: goto tr71;
case 34: goto st22; case 34: goto st22;
@ -951,7 +952,7 @@ st36:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof36; goto _test_eof36;
case 36: case 36:
#line 955 "shortcodes.c" #line 956 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st36; case 32: goto st36;
case 34: goto tr76; case 34: goto tr76;
@ -981,7 +982,7 @@ st37:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof37; goto _test_eof37;
case 37: case 37:
#line 985 "shortcodes.c" #line 986 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr81; case 32: goto tr81;
case 34: goto st22; case 34: goto st22;
@ -1019,7 +1020,7 @@ st38:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof38; goto _test_eof38;
case 38: case 38:
#line 1023 "shortcodes.c" #line 1024 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr51; case 123: goto tr51;
@ -1063,7 +1064,7 @@ st40:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof40; goto _test_eof40;
case 40: case 40:
#line 1067 "shortcodes.c" #line 1068 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st22; case 34: goto st22;
case 123: goto tr51; case 123: goto tr51;
@ -1090,7 +1091,7 @@ st42:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof42; goto _test_eof42;
case 42: case 42:
#line 1094 "shortcodes.c" #line 1095 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr88; case 32: goto tr88;
case 34: goto st22; case 34: goto st22;
@ -1120,7 +1121,7 @@ st43:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof43; goto _test_eof43;
case 43: case 43:
#line 1124 "shortcodes.c" #line 1125 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr88; case 32: goto tr88;
case 34: goto st22; case 34: goto st22;
@ -1152,7 +1153,7 @@ st44:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof44; goto _test_eof44;
case 44: case 44:
#line 1156 "shortcodes.c" #line 1157 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr76; case 34: goto tr76;
case 123: goto tr51; case 123: goto tr51;
@ -1195,7 +1196,7 @@ st46:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof46; goto _test_eof46;
case 46: case 46:
#line 1199 "shortcodes.c" #line 1200 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr95; case 32: goto tr95;
case 34: goto st22; case 34: goto st22;
@ -1242,7 +1243,7 @@ st47:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof47; goto _test_eof47;
case 47: case 47:
#line 1246 "shortcodes.c" #line 1247 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st47; case 32: goto st47;
case 34: goto tr98; case 34: goto tr98;
@ -1272,7 +1273,7 @@ st48:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof48; goto _test_eof48;
case 48: case 48:
#line 1276 "shortcodes.c" #line 1277 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr102; case 32: goto tr102;
case 34: goto st50; case 34: goto st50;
@ -1293,7 +1294,7 @@ st49:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof49; goto _test_eof49;
case 49: case 49:
#line 1297 "shortcodes.c" #line 1298 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr106; case 123: goto tr106;
@ -1339,7 +1340,7 @@ st51:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof51; goto _test_eof51;
case 51: case 51:
#line 1343 "shortcodes.c" #line 1344 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st51; case 32: goto st51;
case 34: goto tr109; case 34: goto tr109;
@ -1369,7 +1370,7 @@ st52:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof52; goto _test_eof52;
case 52: case 52:
#line 1373 "shortcodes.c" #line 1374 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr112; case 32: goto tr112;
case 37: goto tr113; case 37: goto tr113;
@ -1398,7 +1399,7 @@ st53:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof53; goto _test_eof53;
case 53: case 53:
#line 1402 "shortcodes.c" #line 1403 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr112; case 32: goto tr112;
case 37: goto tr113; case 37: goto tr113;
@ -1429,7 +1430,7 @@ st54:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof54; goto _test_eof54;
case 54: case 54:
#line 1433 "shortcodes.c" #line 1434 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr109; case 34: goto tr109;
case 123: goto tr25; case 123: goto tr25;
@ -1464,7 +1465,7 @@ st55:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof55; goto _test_eof55;
case 55: case 55:
#line 1468 "shortcodes.c" #line 1469 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr118; case 123: goto tr118;
@ -1491,7 +1492,7 @@ st56:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof56; goto _test_eof56;
case 56: case 56:
#line 1495 "shortcodes.c" #line 1496 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 37: goto st57; case 37: goto st57;
@ -1542,7 +1543,7 @@ st59:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof59; goto _test_eof59;
case 59: case 59:
#line 1546 "shortcodes.c" #line 1547 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr124; case 32: goto tr124;
case 34: goto st50; case 34: goto st50;
@ -1573,7 +1574,7 @@ st60:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof60; goto _test_eof60;
case 60: case 60:
#line 1577 "shortcodes.c" #line 1578 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st60; case 32: goto st60;
case 34: goto st50; case 34: goto st50;
@ -1595,7 +1596,7 @@ st61:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof61; goto _test_eof61;
case 61: case 61:
#line 1599 "shortcodes.c" #line 1600 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr106; case 123: goto tr106;
@ -1657,7 +1658,7 @@ st144:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof144; goto _test_eof144;
case 144: case 144:
#line 1661 "shortcodes.c" #line 1662 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr106; case 123: goto tr106;
@ -1673,7 +1674,7 @@ st63:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof63; goto _test_eof63;
case 63: case 63:
#line 1677 "shortcodes.c" #line 1678 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr131; case 32: goto tr131;
case 34: goto st50; case 34: goto st50;
@ -1720,7 +1721,7 @@ st64:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof64; goto _test_eof64;
case 64: case 64:
#line 1724 "shortcodes.c" #line 1725 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st64; case 32: goto st64;
case 34: goto tr136; case 34: goto tr136;
@ -1750,7 +1751,7 @@ st65:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof65; goto _test_eof65;
case 65: case 65:
#line 1754 "shortcodes.c" #line 1755 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr141; case 32: goto tr141;
case 34: goto st22; case 34: goto st22;
@ -1788,7 +1789,7 @@ st66:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof66; goto _test_eof66;
case 66: case 66:
#line 1792 "shortcodes.c" #line 1793 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr106; case 123: goto tr106;
@ -1815,7 +1816,7 @@ st68:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof68; goto _test_eof68;
case 68: case 68:
#line 1819 "shortcodes.c" #line 1820 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr144; case 32: goto tr144;
case 34: goto st50; case 34: goto st50;
@ -1862,7 +1863,7 @@ st69:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof69; goto _test_eof69;
case 69: case 69:
#line 1866 "shortcodes.c" #line 1867 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st50; case 34: goto st50;
case 123: goto tr106; case 123: goto tr106;
@ -1889,7 +1890,7 @@ st71:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof71; goto _test_eof71;
case 71: case 71:
#line 1893 "shortcodes.c" #line 1894 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr144; case 32: goto tr144;
case 34: goto st50; case 34: goto st50;
@ -1921,7 +1922,7 @@ st72:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof72; goto _test_eof72;
case 72: case 72:
#line 1925 "shortcodes.c" #line 1926 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr136; case 34: goto tr136;
case 123: goto tr106; case 123: goto tr106;
@ -1964,7 +1965,7 @@ st74:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof74; goto _test_eof74;
case 74: case 74:
#line 1968 "shortcodes.c" #line 1969 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr153; case 32: goto tr153;
case 34: goto st50; case 34: goto st50;
@ -2011,7 +2012,7 @@ st75:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof75; goto _test_eof75;
case 75: case 75:
#line 2015 "shortcodes.c" #line 2016 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st75; case 32: goto st75;
case 34: goto tr156; case 34: goto tr156;
@ -2041,7 +2042,7 @@ st76:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof76; goto _test_eof76;
case 76: case 76:
#line 2045 "shortcodes.c" #line 2046 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr159; case 32: goto tr159;
case 34: goto st50; case 34: goto st50;
@ -2062,7 +2063,7 @@ st77:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof77; goto _test_eof77;
case 77: case 77:
#line 2066 "shortcodes.c" #line 2067 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr160; case 32: goto tr160;
case 34: goto st50; case 34: goto st50;
@ -2092,7 +2093,7 @@ st78:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof78; goto _test_eof78;
case 78: case 78:
#line 2096 "shortcodes.c" #line 2097 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr160; case 32: goto tr160;
case 34: goto st50; case 34: goto st50;
@ -2124,7 +2125,7 @@ st79:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof79; goto _test_eof79;
case 79: case 79:
#line 2128 "shortcodes.c" #line 2129 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr156; case 34: goto tr156;
case 123: goto tr106; case 123: goto tr106;
@ -2148,7 +2149,7 @@ st80:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof80; goto _test_eof80;
case 80: case 80:
#line 2152 "shortcodes.c" #line 2153 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr164; case 32: goto tr164;
case 34: goto st22; case 34: goto st22;
@ -2178,7 +2179,7 @@ st81:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof81; goto _test_eof81;
case 81: case 81:
#line 2182 "shortcodes.c" #line 2183 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr164; case 32: goto tr164;
case 34: goto st22; case 34: goto st22;
@ -2210,7 +2211,7 @@ st82:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof82; goto _test_eof82;
case 82: case 82:
#line 2214 "shortcodes.c" #line 2215 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr98; case 34: goto tr98;
case 123: goto tr51; case 123: goto tr51;
@ -2234,7 +2235,7 @@ st83:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof83; goto _test_eof83;
case 83: case 83:
#line 2238 "shortcodes.c" #line 2239 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr168; case 32: goto tr168;
case 37: goto tr115; case 37: goto tr115;
@ -2263,7 +2264,7 @@ st84:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof84; goto _test_eof84;
case 84: case 84:
#line 2267 "shortcodes.c" #line 2268 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr168; case 32: goto tr168;
case 37: goto tr115; case 37: goto tr115;
@ -2294,7 +2295,7 @@ st85:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof85; goto _test_eof85;
case 85: case 85:
#line 2298 "shortcodes.c" #line 2299 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr44; case 34: goto tr44;
case 123: goto tr25; case 123: goto tr25;
@ -2336,7 +2337,7 @@ st87:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof87; goto _test_eof87;
case 87: case 87:
#line 2340 "shortcodes.c" #line 2341 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr173; case 32: goto tr173;
case 37: goto tr42; case 37: goto tr42;
@ -2382,7 +2383,7 @@ st88:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof88; goto _test_eof88;
case 88: case 88:
#line 2386 "shortcodes.c" #line 2387 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 123: goto tr1; case 123: goto tr1;
case 125: goto st89; case 125: goto st89;
@ -2407,7 +2408,7 @@ st90:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof90; goto _test_eof90;
case 90: case 90:
#line 2411 "shortcodes.c" #line 2412 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 123: goto tr177; case 123: goto tr177;
@ -2423,7 +2424,7 @@ st91:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof91; goto _test_eof91;
case 91: case 91:
#line 2427 "shortcodes.c" #line 2428 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 37: goto st92; case 37: goto st92;
@ -2459,7 +2460,7 @@ st93:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof93; goto _test_eof93;
case 93: case 93:
#line 2463 "shortcodes.c" #line 2464 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr181; case 32: goto tr181;
case 34: goto st7; case 34: goto st7;
@ -2506,7 +2507,7 @@ st94:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof94; goto _test_eof94;
case 94: case 94:
#line 2510 "shortcodes.c" #line 2511 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st94; case 32: goto st94;
case 34: goto tr186; case 34: goto tr186;
@ -2536,7 +2537,7 @@ st95:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof95; goto _test_eof95;
case 95: case 95:
#line 2540 "shortcodes.c" #line 2541 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr191; case 32: goto tr191;
case 34: goto st7; case 34: goto st7;
@ -2574,7 +2575,7 @@ st96:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof96; goto _test_eof96;
case 96: case 96:
#line 2578 "shortcodes.c" #line 2579 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 123: goto tr18; case 123: goto tr18;
@ -2618,7 +2619,7 @@ st98:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof98; goto _test_eof98;
case 98: case 98:
#line 2622 "shortcodes.c" #line 2623 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 123: goto tr18; case 123: goto tr18;
@ -2650,7 +2651,7 @@ st145:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof145; goto _test_eof145;
case 145: case 145:
#line 2654 "shortcodes.c" #line 2655 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st7; case 34: goto st7;
case 123: goto tr18; case 123: goto tr18;
@ -2666,7 +2667,7 @@ st100:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof100; goto _test_eof100;
case 100: case 100:
#line 2670 "shortcodes.c" #line 2671 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr197; case 32: goto tr197;
case 34: goto st7; case 34: goto st7;
@ -2696,7 +2697,7 @@ st101:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof101; goto _test_eof101;
case 101: case 101:
#line 2700 "shortcodes.c" #line 2701 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr197; case 32: goto tr197;
case 34: goto st7; case 34: goto st7;
@ -2728,7 +2729,7 @@ st102:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof102; goto _test_eof102;
case 102: case 102:
#line 2732 "shortcodes.c" #line 2733 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr186; case 34: goto tr186;
case 123: goto tr18; case 123: goto tr18;
@ -2770,7 +2771,7 @@ st104:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof104; goto _test_eof104;
case 104: case 104:
#line 2774 "shortcodes.c" #line 2775 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr204; case 32: goto tr204;
case 34: goto st7; case 34: goto st7;
@ -2817,7 +2818,7 @@ st105:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof105; goto _test_eof105;
case 105: case 105:
#line 2821 "shortcodes.c" #line 2822 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st105; case 32: goto st105;
case 34: goto tr207; case 34: goto tr207;
@ -2847,7 +2848,7 @@ st106:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof106; goto _test_eof106;
case 106: case 106:
#line 2851 "shortcodes.c" #line 2852 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr211; case 32: goto tr211;
case 34: goto st108; case 34: goto st108;
@ -2868,7 +2869,7 @@ st107:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof107; goto _test_eof107;
case 107: case 107:
#line 2872 "shortcodes.c" #line 2873 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 123: goto tr215; case 123: goto tr215;
@ -2914,7 +2915,7 @@ st109:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof109; goto _test_eof109;
case 109: case 109:
#line 2918 "shortcodes.c" #line 2919 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st109; case 32: goto st109;
case 34: goto tr218; case 34: goto tr218;
@ -2944,7 +2945,7 @@ st110:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof110; goto _test_eof110;
case 110: case 110:
#line 2948 "shortcodes.c" #line 2949 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr221; case 32: goto tr221;
case 37: goto tr222; case 37: goto tr222;
@ -2973,7 +2974,7 @@ st111:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof111; goto _test_eof111;
case 111: case 111:
#line 2977 "shortcodes.c" #line 2978 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr221; case 32: goto tr221;
case 37: goto tr222; case 37: goto tr222;
@ -3004,7 +3005,7 @@ st112:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof112; goto _test_eof112;
case 112: case 112:
#line 3008 "shortcodes.c" #line 3009 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr218; case 34: goto tr218;
case 123: goto tr1; case 123: goto tr1;
@ -3028,7 +3029,7 @@ st113:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof113; goto _test_eof113;
case 113: case 113:
#line 3032 "shortcodes.c" #line 3033 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 123: goto tr227; case 123: goto tr227;
@ -3044,7 +3045,7 @@ st114:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof114; goto _test_eof114;
case 114: case 114:
#line 3048 "shortcodes.c" #line 3049 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 37: goto st115; case 37: goto st115;
@ -3080,7 +3081,7 @@ st116:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof116; goto _test_eof116;
case 116: case 116:
#line 3084 "shortcodes.c" #line 3085 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr231; case 32: goto tr231;
case 34: goto st108; case 34: goto st108;
@ -3127,7 +3128,7 @@ st117:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof117; goto _test_eof117;
case 117: case 117:
#line 3131 "shortcodes.c" #line 3132 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st117; case 32: goto st117;
case 34: goto tr236; case 34: goto tr236;
@ -3157,7 +3158,7 @@ st118:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof118; goto _test_eof118;
case 118: case 118:
#line 3161 "shortcodes.c" #line 3162 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr241; case 32: goto tr241;
case 34: goto st7; case 34: goto st7;
@ -3195,7 +3196,7 @@ st119:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof119; goto _test_eof119;
case 119: case 119:
#line 3199 "shortcodes.c" #line 3200 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 123: goto tr215; case 123: goto tr215;
@ -3222,7 +3223,7 @@ st121:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof121; goto _test_eof121;
case 121: case 121:
#line 3226 "shortcodes.c" #line 3227 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr243; case 32: goto tr243;
case 34: goto st108; case 34: goto st108;
@ -3269,7 +3270,7 @@ st122:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof122; goto _test_eof122;
case 122: case 122:
#line 3273 "shortcodes.c" #line 3274 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 123: goto tr215; case 123: goto tr215;
@ -3301,7 +3302,7 @@ st146:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof146; goto _test_eof146;
case 146: case 146:
#line 3305 "shortcodes.c" #line 3306 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto st108; case 34: goto st108;
case 123: goto tr215; case 123: goto tr215;
@ -3317,7 +3318,7 @@ st124:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof124; goto _test_eof124;
case 124: case 124:
#line 3321 "shortcodes.c" #line 3322 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr243; case 32: goto tr243;
case 34: goto st108; case 34: goto st108;
@ -3349,7 +3350,7 @@ st125:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof125; goto _test_eof125;
case 125: case 125:
#line 3353 "shortcodes.c" #line 3354 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr236; case 34: goto tr236;
case 123: goto tr215; case 123: goto tr215;
@ -3391,7 +3392,7 @@ st127:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof127; goto _test_eof127;
case 127: case 127:
#line 3395 "shortcodes.c" #line 3396 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr252; case 32: goto tr252;
case 34: goto st108; case 34: goto st108;
@ -3438,7 +3439,7 @@ st128:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof128; goto _test_eof128;
case 128: case 128:
#line 3442 "shortcodes.c" #line 3443 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st128; case 32: goto st128;
case 34: goto tr255; case 34: goto tr255;
@ -3468,7 +3469,7 @@ st129:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof129; goto _test_eof129;
case 129: case 129:
#line 3472 "shortcodes.c" #line 3473 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr258; case 32: goto tr258;
case 34: goto st108; case 34: goto st108;
@ -3489,7 +3490,7 @@ st130:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof130; goto _test_eof130;
case 130: case 130:
#line 3493 "shortcodes.c" #line 3494 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr259; case 32: goto tr259;
case 34: goto st108; case 34: goto st108;
@ -3519,7 +3520,7 @@ st131:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof131; goto _test_eof131;
case 131: case 131:
#line 3523 "shortcodes.c" #line 3524 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr259; case 32: goto tr259;
case 34: goto st108; case 34: goto st108;
@ -3551,7 +3552,7 @@ st132:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof132; goto _test_eof132;
case 132: case 132:
#line 3555 "shortcodes.c" #line 3556 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr255; case 34: goto tr255;
case 123: goto tr215; case 123: goto tr215;
@ -3575,7 +3576,7 @@ st133:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof133; goto _test_eof133;
case 133: case 133:
#line 3579 "shortcodes.c" #line 3580 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr263; case 32: goto tr263;
case 34: goto st7; case 34: goto st7;
@ -3605,7 +3606,7 @@ st134:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof134; goto _test_eof134;
case 134: case 134:
#line 3609 "shortcodes.c" #line 3610 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr263; case 32: goto tr263;
case 34: goto st7; case 34: goto st7;
@ -3637,7 +3638,7 @@ st135:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof135; goto _test_eof135;
case 135: case 135:
#line 3641 "shortcodes.c" #line 3642 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr207; case 34: goto tr207;
case 123: goto tr18; case 123: goto tr18;
@ -3661,7 +3662,7 @@ st136:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof136; goto _test_eof136;
case 136: case 136:
#line 3665 "shortcodes.c" #line 3666 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr267; case 32: goto tr267;
case 37: goto tr224; case 37: goto tr224;
@ -3690,7 +3691,7 @@ st137:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof137; goto _test_eof137;
case 137: case 137:
#line 3694 "shortcodes.c" #line 3695 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr267; case 32: goto tr267;
case 37: goto tr224; case 37: goto tr224;
@ -3721,7 +3722,7 @@ st138:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof138; goto _test_eof138;
case 138: case 138:
#line 3725 "shortcodes.c" #line 3726 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 34: goto tr11; case 34: goto tr11;
case 123: goto tr1; case 123: goto tr1;
@ -3762,7 +3763,7 @@ st140:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof140; goto _test_eof140;
case 140: case 140:
#line 3766 "shortcodes.c" #line 3767 "shortcodes.c"
switch( (*p) ) { switch( (*p) ) {
case 32: goto tr272; case 32: goto tr272;
case 37: goto tr9; case 37: goto tr9;
@ -3933,7 +3934,7 @@ case 140:
_test_eof: {} _test_eof: {}
} }
#line 133 "shortcodes.rl" #line 134 "shortcodes.rl"
result.sccount = c_sc; result.sccount = c_sc;
return result; return result;

View File

@ -40,8 +40,8 @@ module Shortcodes
end end
struct Error struct Error
@position: UInt32 property position : UInt32
@code: UInt32 property code : UInt32
def initialize(@position, @code) def initialize(@position, @code)
end end
@ -52,9 +52,15 @@ module Shortcodes
property data : String = "" property data : String = ""
property matching : Int32 = 0 property matching : Int32 = 0
property args : Array(Arg) = [] of Arg property args : Array(Arg) = [] of Arg
property errors : Array(Error) = [] of Error
property whole : String = "" property whole : String = ""
def initialize(@name, @data, @matching, @args, @whole)
def initialize(
@name,
@data,
@matching,
@args,
@whole
)
end end
end end
@ -81,14 +87,6 @@ module Shortcodes
) )
end end
errors = [] of Error
(0...r.errcount).each do |k|
errors << Error.new(
r.errors[k].position,
r.errors[k].code,
)
end
result.shortcodes << Shortcode.new( result.shortcodes << Shortcode.new(
extract(sc.name, input), extract(sc.name, input),
extract(sc.data, input), extract(sc.data, input),
@ -97,10 +95,15 @@ module Shortcodes
extract(sc.whole, input), extract(sc.whole, input),
) )
end end
(0...r.errcount).each do |k|
result.errors << Error.new(
r.errors[k].position,
r.errors[k].code,
)
end
result result
end end
# ### Error codes # ### Error codes
# #
# You are closing the wrong shortcode. # You are closing the wrong shortcode.

View File

@ -122,6 +122,7 @@ sc_result parse(char *input, unsigned int len) {
char *pe = p + len; char *pe = p + len;
sc_result result; sc_result result;
result.errcount = 0;
shortcode *sc_list = result.sc; shortcode *sc_list = result.sc;
int c_sc = 0; int c_sc = 0;