12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422 |
- /* A packrat parser generated by PackCC 1.5.0 */
- #ifdef _MSC_VER
- #undef _CRT_SECURE_NO_WARNINGS
- #define _CRT_SECURE_NO_WARNINGS
- #endif /* _MSC_VER */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifndef _MSC_VER
- #if defined __GNUC__ && defined _WIN32 /* MinGW */
- #ifndef PCC_USE_SYSTEM_STRNLEN
- #define strnlen(str, maxlen) pcc_strnlen(str, maxlen)
- static size_t pcc_strnlen(const char *str, size_t maxlen) {
- size_t i;
- for (i = 0; i < maxlen && str[i]; i++);
- return i;
- }
- #endif /* !PCC_USE_SYSTEM_STRNLEN */
- #endif /* defined __GNUC__ && defined _WIN32 */
- #endif /* !_MSC_VER */
- #define PCC_DBG_EVALUATE 0
- #define PCC_DBG_MATCH 1
- #define PCC_DBG_NOMATCH 2
- #include "gvplain.h"
- #include <stdio.h>
- static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
- #define PCC_DEBUG(event, rule, level, pos, buffer, length) \
- fprintf(stdout, "%*s%s %s @%d [%.*s]\n", (int)(level * 2), "", dbg_str[event], rule, (int)pos, (int)length, buffer); fflush(stdout)
- /* NOTE: To guarantee the output order, stderr, which can lead a race condition with stdout, is not used. */
- #ifndef PCC_BUFFERSIZE
- #define PCC_BUFFERSIZE 256
- #endif /* !PCC_BUFFERSIZE */
- #ifndef PCC_ARRAYSIZE
- #define PCC_ARRAYSIZE 2
- #endif /* !PCC_ARRAYSIZE */
- #define VOID_VALUE (~(size_t)0)
- typedef enum pcc_bool_tag {
- PCC_FALSE = 0,
- PCC_TRUE
- } pcc_bool_t;
- typedef struct pcc_char_array_tag {
- char *buf;
- size_t max;
- size_t len;
- } pcc_char_array_t;
- typedef struct pcc_range_tag {
- size_t start;
- size_t end;
- } pcc_range_t;
- typedef int pcc_value_t;
- typedef void *pcc_auxil_t;
- typedef struct pcc_value_table_tag {
- pcc_value_t *buf;
- size_t max;
- size_t len;
- } pcc_value_table_t;
- typedef struct pcc_value_refer_table_tag {
- pcc_value_t **buf;
- size_t max;
- size_t len;
- } pcc_value_refer_table_t;
- typedef struct pcc_capture_tag {
- pcc_range_t range;
- char *string; /* mutable */
- } pcc_capture_t;
- typedef struct pcc_capture_table_tag {
- pcc_capture_t *buf;
- size_t max;
- size_t len;
- } pcc_capture_table_t;
- typedef struct pcc_capture_const_table_tag {
- const pcc_capture_t **buf;
- size_t max;
- size_t len;
- } pcc_capture_const_table_t;
- typedef struct pcc_thunk_tag pcc_thunk_t;
- typedef struct pcc_thunk_array_tag pcc_thunk_array_t;
- typedef void (*pcc_action_t)(gvplain_context_t *, pcc_thunk_t *, pcc_value_t *);
- typedef enum pcc_thunk_type_tag {
- PCC_THUNK_LEAF,
- PCC_THUNK_NODE
- } pcc_thunk_type_t;
- typedef struct pcc_thunk_leaf_tag {
- pcc_value_refer_table_t values;
- pcc_capture_const_table_t capts;
- pcc_capture_t capt0;
- pcc_action_t action;
- } pcc_thunk_leaf_t;
- typedef struct pcc_thunk_node_tag {
- const pcc_thunk_array_t *thunks; /* just a reference */
- pcc_value_t *value; /* just a reference */
- } pcc_thunk_node_t;
- typedef union pcc_thunk_data_tag {
- pcc_thunk_leaf_t leaf;
- pcc_thunk_node_t node;
- } pcc_thunk_data_t;
- struct pcc_thunk_tag {
- pcc_thunk_type_t type;
- pcc_thunk_data_t data;
- };
- struct pcc_thunk_array_tag {
- pcc_thunk_t **buf;
- size_t max;
- size_t len;
- };
- typedef struct pcc_thunk_chunk_tag {
- pcc_value_table_t values;
- pcc_capture_table_t capts;
- pcc_thunk_array_t thunks;
- size_t pos; /* the starting position in the character buffer */
- } pcc_thunk_chunk_t;
- typedef struct pcc_lr_entry_tag pcc_lr_entry_t;
- typedef enum pcc_lr_answer_type_tag {
- PCC_LR_ANSWER_LR,
- PCC_LR_ANSWER_CHUNK
- } pcc_lr_answer_type_t;
- typedef union pcc_lr_answer_data_tag {
- pcc_lr_entry_t *lr;
- pcc_thunk_chunk_t *chunk;
- } pcc_lr_answer_data_t;
- typedef struct pcc_lr_answer_tag pcc_lr_answer_t;
- struct pcc_lr_answer_tag {
- pcc_lr_answer_type_t type;
- pcc_lr_answer_data_t data;
- size_t pos; /* the absolute position in the input */
- pcc_lr_answer_t *hold;
- };
- typedef pcc_thunk_chunk_t *(*pcc_rule_t)(gvplain_context_t *);
- typedef struct pcc_rule_set_tag {
- pcc_rule_t *buf;
- size_t max;
- size_t len;
- } pcc_rule_set_t;
- typedef struct pcc_lr_head_tag pcc_lr_head_t;
- struct pcc_lr_head_tag {
- pcc_rule_t rule;
- pcc_rule_set_t invol;
- pcc_rule_set_t eval;
- pcc_lr_head_t *hold;
- };
- typedef struct pcc_lr_memo_tag {
- pcc_rule_t rule;
- pcc_lr_answer_t *answer;
- } pcc_lr_memo_t;
- typedef struct pcc_lr_memo_map_tag {
- pcc_lr_memo_t *buf;
- size_t max;
- size_t len;
- } pcc_lr_memo_map_t;
- typedef struct pcc_lr_table_entry_tag {
- pcc_lr_head_t *head; /* just a reference */
- pcc_lr_memo_map_t memos;
- pcc_lr_answer_t *hold_a;
- pcc_lr_head_t *hold_h;
- } pcc_lr_table_entry_t;
- typedef struct pcc_lr_table_tag {
- pcc_lr_table_entry_t **buf;
- size_t max;
- size_t len;
- } pcc_lr_table_t;
- struct pcc_lr_entry_tag {
- pcc_rule_t rule;
- pcc_thunk_chunk_t *seed; /* just a reference */
- pcc_lr_head_t *head; /* just a reference */
- };
- typedef struct pcc_lr_stack_tag {
- pcc_lr_entry_t **buf;
- size_t max;
- size_t len;
- } pcc_lr_stack_t;
- struct gvplain_context_tag {
- size_t pos; /* the position in the input of the first character currently buffered */
- size_t cur; /* the current parsing position in the character buffer */
- size_t level;
- pcc_char_array_t buffer;
- pcc_lr_table_t lrtable;
- pcc_lr_stack_t lrstack;
- pcc_auxil_t auxil;
- };
- #ifndef PCC_ERROR
- #define PCC_ERROR(auxil) pcc_error()
- static void pcc_error(void) {
- fprintf(stderr, "Syntax error\n");
- exit(1);
- }
- #endif /* !PCC_ERROR */
- #ifndef PCC_GETCHAR
- #define PCC_GETCHAR(auxil) getchar()
- #endif /* !PCC_GETCHAR */
- #ifndef PCC_MALLOC
- #define PCC_MALLOC(auxil, size) pcc_malloc_e(size)
- static void *pcc_malloc_e(size_t size) {
- void *const p = malloc(size);
- if (p == NULL) {
- fprintf(stderr, "Out of memory\n");
- exit(1);
- }
- return p;
- }
- #endif /* !PCC_MALLOC */
- #ifndef PCC_REALLOC
- #define PCC_REALLOC(auxil, ptr, size) pcc_realloc_e(ptr, size)
- static void *pcc_realloc_e(void *ptr, size_t size) {
- void *const p = realloc(ptr, size);
- if (p == NULL) {
- fprintf(stderr, "Out of memory\n");
- exit(1);
- }
- return p;
- }
- #endif /* !PCC_REALLOC */
- #ifndef PCC_FREE
- #define PCC_FREE(auxil, ptr) free(ptr)
- #endif /* !PCC_FREE */
- #ifndef PCC_DEBUG
- #define PCC_DEBUG(event, rule, level, pos, buffer, length) ((void)0)
- #endif /* !PCC_DEBUG */
- static char *pcc_strndup_e(pcc_auxil_t auxil, const char *str, size_t len) {
- const size_t m = strnlen(str, len);
- char *const s = (char *)PCC_MALLOC(auxil, m + 1);
- if (auxil) { }
- memcpy(s, str, m);
- s[m] = '\0';
- return s;
- }
- static void pcc_char_array__init(pcc_auxil_t auxil, pcc_char_array_t *array, size_t max) {
- array->len = 0;
- array->max = max;
- if (auxil) { }
- array->buf = (char *)PCC_MALLOC(auxil, array->max);
- }
- static void pcc_char_array__add(pcc_auxil_t auxil, pcc_char_array_t *array, char ch) {
- if (array->max <= array->len) {
- const size_t n = array->len + 1;
- size_t m = array->max;
- if (m == 0) m = 1;
- while (m < n && m != 0) m <<= 1;
- if (m == 0) m = n;
- if (auxil) { }
- array->buf = (char *)PCC_REALLOC(auxil, array->buf, m);
- array->max = m;
- }
- array->buf[array->len++] = ch;
- }
- static void pcc_char_array__term(pcc_auxil_t auxil, pcc_char_array_t *array) {
- PCC_FREE(auxil, array->buf);
- }
- static void pcc_value_table__init(pcc_auxil_t auxil, pcc_value_table_t *table, size_t max) {
- table->len = 0;
- table->max = max;
- table->buf = (pcc_value_t *)PCC_MALLOC(auxil, sizeof(pcc_value_t) * table->max);
- if (auxil) { }
- return;
- }
- static void pcc_value_table__resize(pcc_auxil_t auxil, pcc_value_table_t *table, size_t len) {
- if (table->max < len) {
- size_t m = table->max;
- if (m == 0) m = 1;
- while (m < len && m != 0) m <<= 1;
- if (m == 0) m = len;
- table->buf = (pcc_value_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t) * m);
- table->max = m;
- }
- table->len = len;
- }
- static void pcc_value_table__term(pcc_auxil_t auxil, pcc_value_table_t *table) {
- PCC_FREE(auxil, table->buf);
- }
- static void pcc_value_refer_table__init(pcc_auxil_t auxil, pcc_value_refer_table_t *table, size_t max) {
- table->len = 0;
- table->max = max;
- table->buf = (pcc_value_t **)PCC_MALLOC(auxil, sizeof(pcc_value_t *) * table->max);
- }
- static void pcc_value_refer_table__resize(pcc_auxil_t auxil, pcc_value_refer_table_t *table, size_t len) {
- size_t i;
- if (table->max < len) {
- size_t m = table->max;
- if (m == 0) m = 1;
- while (m < len && m != 0) m <<= 1;
- if (m == 0) m = len;
- table->buf = (pcc_value_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t *) * m);
- table->max = m;
- }
- for (i = table->len; i < len; i++) table->buf[i] = NULL;
- table->len = len;
- }
- static void pcc_value_refer_table__term(pcc_auxil_t auxil, pcc_value_refer_table_t *table) {
- PCC_FREE(auxil, table->buf);
- }
- static void pcc_capture_table__init(pcc_auxil_t auxil, pcc_capture_table_t *table, size_t max) {
- table->len = 0;
- table->max = max;
- table->buf = (pcc_capture_t *)PCC_MALLOC(auxil, sizeof(pcc_capture_t) * table->max);
- }
- static void pcc_capture_table__resize(pcc_auxil_t auxil, pcc_capture_table_t *table, size_t len) {
- size_t i;
- for (i = len; i < table->len; i++) PCC_FREE(auxil, table->buf[i].string);
- if (table->max < len) {
- size_t m = table->max;
- if (m == 0) m = 1;
- while (m < len && m != 0) m <<= 1;
- if (m == 0) m = len;
- table->buf = (pcc_capture_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_capture_t) * m);
- table->max = m;
- }
- for (i = table->len; i < len; i++) {
- table->buf[i].range.start = 0;
- table->buf[i].range.end = 0;
- table->buf[i].string = NULL;
- }
- table->len = len;
- }
- static void pcc_capture_table__term(pcc_auxil_t auxil, pcc_capture_table_t *table) {
- while (table->len > 0) {
- table->len--;
- PCC_FREE(auxil, table->buf[table->len].string);
- }
- PCC_FREE(auxil, table->buf);
- }
- static void pcc_capture_const_table__init(pcc_auxil_t auxil, pcc_capture_const_table_t *table, size_t max) {
- table->len = 0;
- table->max = max;
- table->buf = (const pcc_capture_t **)PCC_MALLOC(auxil, sizeof(const pcc_capture_t *) * table->max);
- }
- static void pcc_capture_const_table__resize(pcc_auxil_t auxil, pcc_capture_const_table_t *table, size_t len) {
- size_t i;
- if (table->max < len) {
- size_t m = table->max;
- if (m == 0) m = 1;
- while (m < len && m != 0) m <<= 1;
- if (m == 0) m = len;
- table->buf = (const pcc_capture_t **)PCC_REALLOC(auxil, (pcc_capture_t **)table->buf, sizeof(const pcc_capture_t *) * m);
- table->max = m;
- }
- for (i = table->len; i < len; i++) table->buf[i] = NULL;
- table->len = len;
- }
- static void pcc_capture_const_table__term(pcc_auxil_t auxil, pcc_capture_const_table_t *table) {
- PCC_FREE(auxil, table->buf);
- }
- static pcc_thunk_t *pcc_thunk__create_leaf(pcc_auxil_t auxil, pcc_action_t action, size_t valuec, size_t captc) {
- pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t));
- thunk->type = PCC_THUNK_LEAF;
- pcc_value_refer_table__init(auxil, &thunk->data.leaf.values, valuec);
- pcc_value_refer_table__resize(auxil, &thunk->data.leaf.values, valuec);
- pcc_capture_const_table__init(auxil, &thunk->data.leaf.capts, captc);
- pcc_capture_const_table__resize(auxil, &thunk->data.leaf.capts, captc);
- thunk->data.leaf.capt0.range.start = 0;
- thunk->data.leaf.capt0.range.end = 0;
- thunk->data.leaf.capt0.string = NULL;
- thunk->data.leaf.action = action;
- return thunk;
- }
- static pcc_thunk_t *pcc_thunk__create_node(pcc_auxil_t auxil, const pcc_thunk_array_t *thunks, pcc_value_t *value) {
- pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t));
- thunk->type = PCC_THUNK_NODE;
- thunk->data.node.thunks = thunks;
- thunk->data.node.value = value;
- return thunk;
- }
- static void pcc_thunk__destroy(pcc_auxil_t auxil, pcc_thunk_t *thunk) {
- if (thunk == NULL) return;
- switch (thunk->type) {
- case PCC_THUNK_LEAF:
- PCC_FREE(auxil, thunk->data.leaf.capt0.string);
- pcc_capture_const_table__term(auxil, &thunk->data.leaf.capts);
- pcc_value_refer_table__term(auxil, &thunk->data.leaf.values);
- break;
- case PCC_THUNK_NODE:
- break;
- default: /* unknown */
- break;
- }
- PCC_FREE(auxil, thunk);
- }
- static void pcc_thunk_array__init(pcc_auxil_t auxil, pcc_thunk_array_t *array, size_t max) {
- array->len = 0;
- array->max = max;
- array->buf = (pcc_thunk_t **)PCC_MALLOC(auxil, sizeof(pcc_thunk_t *) * array->max);
- }
- static void pcc_thunk_array__add(pcc_auxil_t auxil, pcc_thunk_array_t *array, pcc_thunk_t *thunk) {
- if (array->max <= array->len) {
- const size_t n = array->len + 1;
- size_t m = array->max;
- if (m == 0) m = 1;
- while (m < n && m != 0) m <<= 1;
- if (m == 0) m = n;
- array->buf = (pcc_thunk_t **)PCC_REALLOC(auxil, array->buf, sizeof(pcc_thunk_t *) * m);
- array->max = m;
- }
- array->buf[array->len++] = thunk;
- }
- static void pcc_thunk_array__revert(pcc_auxil_t auxil, pcc_thunk_array_t *array, size_t len) {
- while (array->len > len) {
- array->len--;
- pcc_thunk__destroy(auxil, array->buf[array->len]);
- }
- }
- static void pcc_thunk_array__term(pcc_auxil_t auxil, pcc_thunk_array_t *array) {
- while (array->len > 0) {
- array->len--;
- pcc_thunk__destroy(auxil, array->buf[array->len]);
- }
- PCC_FREE(auxil, array->buf);
- }
- static pcc_thunk_chunk_t *pcc_thunk_chunk__create(pcc_auxil_t auxil) {
- pcc_thunk_chunk_t *const chunk = (pcc_thunk_chunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_chunk_t));
- pcc_value_table__init(auxil, &chunk->values, PCC_ARRAYSIZE);
- pcc_capture_table__init(auxil, &chunk->capts, PCC_ARRAYSIZE);
- pcc_thunk_array__init(auxil, &chunk->thunks, PCC_ARRAYSIZE);
- chunk->pos = 0;
- return chunk;
- }
- static void pcc_thunk_chunk__destroy(pcc_auxil_t auxil, pcc_thunk_chunk_t *chunk) {
- if (chunk == NULL) return;
- pcc_thunk_array__term(auxil, &chunk->thunks);
- pcc_capture_table__term(auxil, &chunk->capts);
- pcc_value_table__term(auxil, &chunk->values);
- PCC_FREE(auxil, chunk);
- }
- static void pcc_rule_set__init(pcc_auxil_t auxil, pcc_rule_set_t *set, size_t max) {
- set->len = 0;
- set->max = max;
- set->buf = (pcc_rule_t *)PCC_MALLOC(auxil, sizeof(pcc_rule_t) * set->max);
- }
- static size_t pcc_rule_set__index(pcc_auxil_t auxil, const pcc_rule_set_t *set, pcc_rule_t rule) {
- size_t i;
- for (i = 0; i < set->len; i++) {
- if (set->buf[i] == rule) return i;
- }
- return VOID_VALUE;
- }
- static pcc_bool_t pcc_rule_set__add(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) {
- const size_t i = pcc_rule_set__index(auxil, set, rule);
- if (i != VOID_VALUE) return PCC_FALSE;
- if (set->max <= set->len) {
- const size_t n = set->len + 1;
- size_t m = set->max;
- if (m == 0) m = 1;
- while (m < n && m != 0) m <<= 1;
- if (m == 0) m = n;
- set->buf = (pcc_rule_t *)PCC_REALLOC(auxil, set->buf, sizeof(pcc_rule_t) * m);
- set->max = m;
- }
- set->buf[set->len++] = rule;
- return PCC_TRUE;
- }
- static pcc_bool_t pcc_rule_set__remove(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) {
- const size_t i = pcc_rule_set__index(auxil, set, rule);
- if (i == VOID_VALUE) return PCC_FALSE;
- memmove(set->buf + i, set->buf + (i + 1), sizeof(pcc_rule_t) * (set->len - (i + 1)));
- return PCC_TRUE;
- }
- static void pcc_rule_set__clear(pcc_auxil_t auxil, pcc_rule_set_t *set) {
- set->len = 0;
- }
- static void pcc_rule_set__copy(pcc_auxil_t auxil, pcc_rule_set_t *set, const pcc_rule_set_t *src) {
- size_t i;
- pcc_rule_set__clear(auxil, set);
- for (i = 0; i < src->len; i++) {
- pcc_rule_set__add(auxil, set, src->buf[i]);
- }
- }
- static void pcc_rule_set__term(pcc_auxil_t auxil, pcc_rule_set_t *set) {
- PCC_FREE(auxil, set->buf);
- }
- static pcc_lr_head_t *pcc_lr_head__create(pcc_auxil_t auxil, pcc_rule_t rule) {
- pcc_lr_head_t *const head = (pcc_lr_head_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_head_t));
- head->rule = rule;
- pcc_rule_set__init(auxil, &head->invol, PCC_ARRAYSIZE);
- pcc_rule_set__init(auxil, &head->eval, PCC_ARRAYSIZE);
- head->hold = NULL;
- return head;
- }
- static void pcc_lr_head__destroy(pcc_auxil_t auxil, pcc_lr_head_t *head) {
- if (head == NULL) return;
- pcc_lr_head__destroy(auxil, head->hold);
- pcc_rule_set__term(auxil, &head->eval);
- pcc_rule_set__term(auxil, &head->invol);
- PCC_FREE(auxil, head);
- }
- static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr);
- static pcc_lr_answer_t *pcc_lr_answer__create(pcc_auxil_t auxil, pcc_lr_answer_type_t type, size_t pos) {
- pcc_lr_answer_t *answer = (pcc_lr_answer_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_answer_t));
- answer->type = type;
- answer->pos = pos;
- answer->hold = NULL;
- switch (answer->type) {
- case PCC_LR_ANSWER_LR:
- answer->data.lr = NULL;
- break;
- case PCC_LR_ANSWER_CHUNK:
- answer->data.chunk = NULL;
- break;
- default: /* unknown */
- PCC_FREE(auxil, answer);
- answer = NULL;
- }
- return answer;
- }
- static void pcc_lr_answer__set_chunk(pcc_auxil_t auxil, pcc_lr_answer_t *answer, pcc_thunk_chunk_t *chunk) {
- pcc_lr_answer_t *const a = pcc_lr_answer__create(auxil, answer->type, answer->pos);
- switch (answer->type) {
- case PCC_LR_ANSWER_LR:
- a->data.lr = answer->data.lr;
- break;
- case PCC_LR_ANSWER_CHUNK:
- a->data.chunk = answer->data.chunk;
- break;
- default: /* unknown */
- break;
- }
- a->hold = answer->hold;
- answer->hold = a;
- answer->type = PCC_LR_ANSWER_CHUNK;
- answer->data.chunk = chunk;
- }
- static void pcc_lr_answer__destroy(pcc_auxil_t auxil, pcc_lr_answer_t *answer) {
- if (answer == NULL) return;
- pcc_lr_answer__destroy(auxil, answer->hold);
- switch (answer->type) {
- case PCC_LR_ANSWER_LR:
- pcc_lr_entry__destroy(auxil, answer->data.lr);
- break;
- case PCC_LR_ANSWER_CHUNK:
- pcc_thunk_chunk__destroy(auxil, answer->data.chunk);
- break;
- default: /* unknown */
- break;
- }
- PCC_FREE(auxil, answer);
- }
- static void pcc_lr_memo_map__init(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, size_t max) {
- map->len = 0;
- map->max = max;
- map->buf = (pcc_lr_memo_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_memo_t) * map->max);
- }
- static size_t pcc_lr_memo_map__index(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) {
- size_t i;
- for (i = 0; i < map->len; i++) {
- if (map->buf[i].rule == rule) return i;
- }
- return VOID_VALUE;
- }
- static void pcc_lr_memo_map__put(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule, pcc_lr_answer_t *answer) {
- const size_t i = pcc_lr_memo_map__index(auxil, map, rule);
- if (i != VOID_VALUE) {
- pcc_lr_answer__destroy(auxil, map->buf[i].answer);
- map->buf[i].answer = answer;
- }
- else {
- if (map->max <= map->len) {
- const size_t n = map->len + 1;
- size_t m = map->max;
- if (m == 0) m = 1;
- while (m < n && m != 0) m <<= 1;
- if (m == 0) m = n;
- map->buf = (pcc_lr_memo_t *)PCC_REALLOC(auxil, map->buf, sizeof(pcc_lr_memo_t) * m);
- map->max = m;
- }
- map->buf[map->len].rule = rule;
- map->buf[map->len].answer = answer;
- map->len++;
- }
- }
- static pcc_lr_answer_t *pcc_lr_memo_map__get(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) {
- const size_t i = pcc_lr_memo_map__index(auxil, map, rule);
- return (i != VOID_VALUE) ? map->buf[i].answer : NULL;
- }
- static void pcc_lr_memo_map__term(pcc_auxil_t auxil, pcc_lr_memo_map_t *map) {
- while (map->len > 0) {
- map->len--;
- pcc_lr_answer__destroy(auxil, map->buf[map->len].answer);
- }
- PCC_FREE(auxil, map->buf);
- }
- static pcc_lr_table_entry_t *pcc_lr_table_entry__create(pcc_auxil_t auxil) {
- pcc_lr_table_entry_t *const entry = (pcc_lr_table_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t));
- entry->head = NULL;
- pcc_lr_memo_map__init(auxil, &entry->memos, PCC_ARRAYSIZE);
- entry->hold_a = NULL;
- entry->hold_h = NULL;
- return entry;
- }
- static void pcc_lr_table_entry__destroy(pcc_auxil_t auxil, pcc_lr_table_entry_t *entry) {
- if (entry == NULL) return;
- pcc_lr_head__destroy(auxil, entry->hold_h);
- pcc_lr_answer__destroy(auxil, entry->hold_a);
- pcc_lr_memo_map__term(auxil, &entry->memos);
- PCC_FREE(auxil, entry);
- }
- static void pcc_lr_table__init(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t max) {
- table->len = 0;
- table->max = max;
- table->buf = (pcc_lr_table_entry_t **)PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t *) * table->max);
- }
- static void pcc_lr_table__resize(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t len) {
- size_t i;
- for (i = len; i < table->len; i++) pcc_lr_table_entry__destroy(auxil, table->buf[i]);
- if (table->max < len) {
- size_t m = table->max;
- if (m == 0) m = 1;
- while (m < len && m != 0) m <<= 1;
- if (m == 0) m = len;
- table->buf = (pcc_lr_table_entry_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_lr_table_entry_t *) * m);
- table->max = m;
- }
- for (i = table->len; i < len; i++) table->buf[i] = NULL;
- table->len = len;
- }
- static void pcc_lr_table__set_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) {
- if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1);
- if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil);
- table->buf[index]->head = head;
- }
- static void pcc_lr_table__hold_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) {
- if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1);
- if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil);
- head->hold = table->buf[index]->hold_h;
- table->buf[index]->hold_h = head;
- }
- static void pcc_lr_table__set_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule, pcc_lr_answer_t *answer) {
- if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1);
- if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil);
- pcc_lr_memo_map__put(auxil, &table->buf[index]->memos, rule, answer);
- }
- static void pcc_lr_table__hold_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_answer_t *answer) {
- if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1);
- if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil);
- answer->hold = table->buf[index]->hold_a;
- table->buf[index]->hold_a = answer;
- }
- static pcc_lr_head_t *pcc_lr_table__get_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index) {
- if (index >= table->len || table->buf[index] == NULL) return NULL;
- return table->buf[index]->head;
- }
- static pcc_lr_answer_t *pcc_lr_table__get_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule) {
- if (index >= table->len || table->buf[index] == NULL) return NULL;
- return pcc_lr_memo_map__get(auxil, &table->buf[index]->memos, rule);
- }
- static void pcc_lr_table__shift(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t count) {
- size_t i;
- if (count > table->len) count = table->len;
- for (i = 0; i < count; i++) pcc_lr_table_entry__destroy(auxil, table->buf[i]);
- memmove(table->buf, table->buf + count, sizeof(pcc_lr_table_entry_t *) * (table->len - count));
- table->len -= count;
- }
- static void pcc_lr_table__term(pcc_auxil_t auxil, pcc_lr_table_t *table) {
- while (table->len > 0) {
- table->len--;
- pcc_lr_table_entry__destroy(auxil, table->buf[table->len]);
- }
- PCC_FREE(auxil, table->buf);
- }
- static pcc_lr_entry_t *pcc_lr_entry__create(pcc_auxil_t auxil, pcc_rule_t rule) {
- pcc_lr_entry_t *const lr = (pcc_lr_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t));
- lr->rule = rule;
- lr->seed = NULL;
- lr->head = NULL;
- return lr;
- }
- static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr) {
- PCC_FREE(auxil, lr);
- }
- static void pcc_lr_stack__init(pcc_auxil_t auxil, pcc_lr_stack_t *stack, size_t max) {
- stack->len = 0;
- stack->max = max;
- stack->buf = (pcc_lr_entry_t **)PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t *) * stack->max);
- }
- static void pcc_lr_stack__push(pcc_auxil_t auxil, pcc_lr_stack_t *stack, pcc_lr_entry_t *lr) {
- if (stack->max <= stack->len) {
- const size_t n = stack->len + 1;
- size_t m = stack->max;
- if (m == 0) m = 1;
- while (m < n && m != 0) m <<= 1;
- if (m == 0) m = n;
- stack->buf = (pcc_lr_entry_t **)PCC_REALLOC(auxil, stack->buf, sizeof(pcc_lr_entry_t *) * m);
- stack->max = m;
- }
- stack->buf[stack->len++] = lr;
- }
- static pcc_lr_entry_t *pcc_lr_stack__pop(pcc_auxil_t auxil, pcc_lr_stack_t *stack) {
- return stack->buf[--stack->len];
- }
- static void pcc_lr_stack__term(pcc_auxil_t auxil, pcc_lr_stack_t *stack) {
- PCC_FREE(auxil, stack->buf);
- }
- static gvplain_context_t *pcc_context__create(pcc_auxil_t auxil) {
- gvplain_context_t *const ctx = (gvplain_context_t *)PCC_MALLOC(auxil, sizeof(gvplain_context_t));
- ctx->pos = 0;
- ctx->cur = 0;
- ctx->level = 0;
- pcc_char_array__init(auxil, &ctx->buffer, PCC_BUFFERSIZE);
- pcc_lr_table__init(auxil, &ctx->lrtable, PCC_BUFFERSIZE);
- pcc_lr_stack__init(auxil, &ctx->lrstack, PCC_ARRAYSIZE);
- ctx->auxil = auxil;
- return ctx;
- }
- static void pcc_context__destroy(gvplain_context_t *ctx) {
- if (ctx == NULL) return;
- pcc_lr_stack__term(ctx->auxil, &ctx->lrstack);
- pcc_lr_table__term(ctx->auxil, &ctx->lrtable);
- pcc_char_array__term(ctx->auxil, &ctx->buffer);
- PCC_FREE(ctx->auxil, ctx);
- }
- static size_t pcc_refill_buffer(gvplain_context_t *ctx, size_t num) {
- if (ctx->buffer.len >= ctx->cur + num) return ctx->buffer.len - ctx->cur;
- while (ctx->buffer.len < ctx->cur + num) {
- const int c = PCC_GETCHAR(ctx->auxil);
- if (c == EOF) break;
- pcc_char_array__add(ctx->auxil, &ctx->buffer, (char)c);
- }
- return ctx->buffer.len - ctx->cur;
- }
- static void pcc_commit_buffer(gvplain_context_t *ctx) {
- memmove(ctx->buffer.buf, ctx->buffer.buf + ctx->cur, ctx->buffer.len - ctx->cur);
- ctx->buffer.len -= ctx->cur;
- ctx->pos += ctx->cur;
- pcc_lr_table__shift(ctx->auxil, &ctx->lrtable, ctx->cur);
- ctx->cur = 0;
- }
- static const char *pcc_get_capture_string(gvplain_context_t *ctx, const pcc_capture_t *capt) {
- if (capt->string == NULL)
- ((pcc_capture_t *)capt)->string =
- pcc_strndup_e(ctx->auxil, ctx->buffer.buf + capt->range.start, capt->range.end - capt->range.start);
- return capt->string;
- }
- static size_t pcc_get_char_as_utf32(gvplain_context_t *ctx, int *out) { /* with checking UTF-8 validity */
- int c, u;
- size_t n;
- if (pcc_refill_buffer(ctx, 1) < 1) return 0;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur];
- n = (c < 0x80) ? 1 :
- ((c & 0xe0) == 0xc0) ? 2 :
- ((c & 0xf0) == 0xe0) ? 3 :
- ((c & 0xf8) == 0xf0) ? 4 : 0;
- if (n < 1) return 0;
- if (pcc_refill_buffer(ctx, n) < n) return 0;
- switch (n) {
- case 1:
- u = c;
- break;
- case 2:
- u = c & 0x1f;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- if (u < 0x80) return 0;
- break;
- case 3:
- u = c & 0x0f;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- if (u < 0x800) return 0;
- break;
- case 4:
- u = c & 0x07;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 3];
- if ((c & 0xc0) != 0x80) return 0;
- u <<= 6; u |= c & 0x3f;
- if (u < 0x10000 || u > 0x10ffff) return 0;
- break;
- default:
- return 0;
- }
- if (out) *out = u;
- return n;
- }
- static pcc_bool_t pcc_apply_rule(gvplain_context_t *ctx, pcc_rule_t rule, pcc_thunk_array_t *thunks, pcc_value_t *value) {
- static pcc_value_t null;
- pcc_thunk_chunk_t *c = NULL;
- const size_t p = ctx->pos + ctx->cur;
- pcc_bool_t b = PCC_TRUE;
- pcc_lr_answer_t *a = pcc_lr_table__get_answer(ctx->auxil, &ctx->lrtable, p, rule);
- pcc_lr_head_t *h = pcc_lr_table__get_head(ctx->auxil, &ctx->lrtable, p);
- if (h != NULL) {
- if (a == NULL && rule != h->rule && pcc_rule_set__index(ctx->auxil, &h->invol, rule) == VOID_VALUE) {
- b = PCC_FALSE;
- c = NULL;
- }
- else if (pcc_rule_set__remove(ctx->auxil, &h->eval, rule)) {
- b = PCC_FALSE;
- c = rule(ctx);
- a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur);
- a->data.chunk = c;
- pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a);
- }
- }
- if (b) {
- if (a != NULL) {
- ctx->cur = a->pos - ctx->pos;
- switch (a->type) {
- case PCC_LR_ANSWER_LR:
- if (a->data.lr->head == NULL) {
- a->data.lr->head = pcc_lr_head__create(ctx->auxil, rule);
- pcc_lr_table__hold_head(ctx->auxil, &ctx->lrtable, p, a->data.lr->head);
- }
- {
- size_t i = ctx->lrstack.len;
- while (i > 0) {
- i--;
- if (ctx->lrstack.buf[i]->head == a->data.lr->head) break;
- ctx->lrstack.buf[i]->head = a->data.lr->head;
- pcc_rule_set__add(ctx->auxil, &a->data.lr->head->invol, ctx->lrstack.buf[i]->rule);
- }
- }
- c = a->data.lr->seed;
- break;
- case PCC_LR_ANSWER_CHUNK:
- c = a->data.chunk;
- break;
- default: /* unknown */
- break;
- }
- }
- else {
- pcc_lr_entry_t *const e = pcc_lr_entry__create(ctx->auxil, rule);
- pcc_lr_stack__push(ctx->auxil, &ctx->lrstack, e);
- a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_LR, p);
- a->data.lr = e;
- pcc_lr_table__set_answer(ctx->auxil, &ctx->lrtable, p, rule, a);
- c = rule(ctx);
- pcc_lr_stack__pop(ctx->auxil, &ctx->lrstack);
- a->pos = ctx->pos + ctx->cur;
- if (e->head == NULL) {
- pcc_lr_answer__set_chunk(ctx->auxil, a, c);
- }
- else {
- e->seed = c;
- h = a->data.lr->head;
- if (h->rule != rule) {
- c = a->data.lr->seed;
- a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur);
- a->data.chunk = c;
- pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a);
- }
- else {
- pcc_lr_answer__set_chunk(ctx->auxil, a, a->data.lr->seed);
- if (a->data.chunk == NULL) {
- c = NULL;
- }
- else {
- pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, h);
- for (;;) {
- ctx->cur = p - ctx->pos;
- pcc_rule_set__copy(ctx->auxil, &h->eval, &h->invol);
- c = rule(ctx);
- if (c == NULL || ctx->pos + ctx->cur <= a->pos) break;
- pcc_lr_answer__set_chunk(ctx->auxil, a, c);
- a->pos = ctx->pos + ctx->cur;
- }
- pcc_thunk_chunk__destroy(ctx->auxil, c);
- pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, NULL);
- ctx->cur = a->pos - ctx->pos;
- c = a->data.chunk;
- }
- }
- }
- }
- }
- if (c == NULL) return PCC_FALSE;
- if (value == NULL) value = &null;
- memset(value, 0, sizeof(pcc_value_t)); /* in case */
- pcc_thunk_array__add(ctx->auxil, thunks, pcc_thunk__create_node(ctx->auxil, &c->thunks, value));
- return PCC_TRUE;
- }
- static void pcc_do_action(gvplain_context_t *ctx, const pcc_thunk_array_t *thunks, pcc_value_t *value) {
- size_t i;
- for (i = 0; i < thunks->len; i++) {
- pcc_thunk_t *const thunk = thunks->buf[i];
- switch (thunk->type) {
- case PCC_THUNK_LEAF:
- thunk->data.leaf.action(ctx, thunk, value);
- break;
- case PCC_THUNK_NODE:
- pcc_do_action(ctx, thunk->data.node.thunks, thunk->data.node.value);
- break;
- default: /* unknown */
- break;
- }
- }
- }
- static void pcc_action_nodes_0(gvplain_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) {
- #define auxil (__pcc_ctx->auxil)
- #define __ (*__pcc_out)
- #define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
- #define _0s ((const size_t)__pcc_in->data.leaf.capt0.range.start)
- #define _0e ((const size_t)__pcc_in->data.leaf.capt0.range.end)
- printf("node: \"%s\"\n",_0);
- #undef _0e
- #undef _0s
- #undef _0
- #undef __
- #undef auxil
- }
- static void pcc_action_edges_el_0(gvplain_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) {
- #define auxil (__pcc_ctx->auxil)
- #define __ (*__pcc_out)
- #define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
- #define _0s ((const size_t)__pcc_in->data.leaf.capt0.range.start)
- #define _0e ((const size_t)__pcc_in->data.leaf.capt0.range.end)
- printf("edge-with-edgelabel: \"%s\"\n",_0);
- #undef _0e
- #undef _0s
- #undef _0
- #undef __
- #undef auxil
- }
- static void pcc_action_edges_wl_0(gvplain_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) {
- #define auxil (__pcc_ctx->auxil)
- #define __ (*__pcc_out)
- #define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
- #define _0s ((const size_t)__pcc_in->data.leaf.capt0.range.start)
- #define _0e ((const size_t)__pcc_in->data.leaf.capt0.range.end)
- printf("edge-without-edgelabel: \"%s\"\n",_0);
- #undef _0e
- #undef _0s
- #undef _0
- #undef __
- #undef auxil
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_gvplain(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_lines(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_linegraph(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_scale(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_width(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_height(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_nodes(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_name(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_name_char(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_x(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_y(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_width(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_height(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_label(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_char(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_style(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_shape(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_color(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_fillcolor(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges_el(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges_wl(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_tail(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_tail_char(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_head(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_head_char(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_pair(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_n(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_x(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_y(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_style(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_color(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_label(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_char(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_xl(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_yl(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_linestop(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_fpnum(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_digit(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_eol(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule__(gvplain_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_gvplain(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "gvplain", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lines, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "gvplain", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "gvplain", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_lines(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "lines", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_linegraph, &chunk->thunks, NULL)) goto L0000;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nodes, &chunk->thunks, NULL)) goto L0001;
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edges, &chunk->thunks, NULL)) goto L0002;
- if (ctx->cur == p) break;
- continue;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_linestop, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "lines", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "lines", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_linegraph(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "linegraph", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (
- pcc_refill_buffer(ctx, 5) < 5 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'h'
- ) goto L0000;
- ctx->cur += 5;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_scale, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_width, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_height, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "linegraph", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "linegraph", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_scale(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "scale", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "scale", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "scale", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_width(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_height(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_nodes(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "nodes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0000;
- ctx->cur += 4;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_name, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_x, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_y, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_width, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_height, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_label, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_style, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_shape, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_color, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_fillcolor, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_nodes_0, 0, 0);
- thunk->data.leaf.capt0.range.start = chunk->pos;
- thunk->data.leaf.capt0.range.end = ctx->cur;
- pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "nodes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "nodes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_name(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_name", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_name_char, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0006;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0005;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_name", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_name_char(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_name_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0002;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0004;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'b'
- ) goto L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0005;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'f'
- ) goto L0005;
- ctx->cur++;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0006;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'n'
- ) goto L0006;
- ctx->cur++;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0007;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'r'
- ) goto L0007;
- ctx->cur++;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0008;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 't'
- ) goto L0008;
- ctx->cur++;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0010;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0009;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0009;
- ctx->cur += n;
- }
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_name_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_name_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_x(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_y(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_width(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_width", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_height(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_height", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_label(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_label", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_node_char, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0006;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0005;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_label", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_char(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0002;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0004;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'b'
- ) goto L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0005;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'f'
- ) goto L0005;
- ctx->cur++;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0006;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'n'
- ) goto L0006;
- ctx->cur++;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0007;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'r'
- ) goto L0007;
- ctx->cur++;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0008;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 't'
- ) goto L0008;
- ctx->cur++;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0010;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0009;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0009;
- ctx->cur += n;
- }
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "node_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_style(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_style", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0002;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_style", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_shape(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_shape", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0002;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_shape", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_color(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_color", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0002;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_color", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_node_fillcolor(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "node_fillcolor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0002;
- if (!(
- u == 0x00000a
- )) goto L0002;
- ctx->cur += n;
- }
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "node_fillcolor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edges", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edges_el, &chunk->thunks, NULL)) goto L0002;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edges_wl, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edges", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edges", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges_el(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edges_el", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0000;
- ctx->cur += 4;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_tail, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_head, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_n, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- {
- const size_t p0 = ctx->cur;
- const size_t n0 = chunk->thunks.len;
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_pair, &chunk->thunks, NULL)) goto L0001;
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- if (i < 1) {
- ctx->cur = p0;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
- goto L0000;
- }
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_label, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_xl, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_yl, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_style, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_color, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_edges_el_0, 0, 0);
- thunk->data.leaf.capt0.range.start = chunk->pos;
- thunk->data.leaf.capt0.range.end = ctx->cur;
- pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edges_el", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edges_el", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edges_wl(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edges_wl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0000;
- ctx->cur += 4;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_tail, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_head, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_n, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- {
- const size_t p0 = ctx->cur;
- const size_t n0 = chunk->thunks.len;
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_pair, &chunk->thunks, NULL)) goto L0001;
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- if (i < 1) {
- ctx->cur = p0;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
- goto L0000;
- }
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_style, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_color, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_edges_wl_0, 0, 0);
- thunk->data.leaf.capt0.range.start = chunk->pos;
- thunk->data.leaf.capt0.range.end = ctx->cur;
- pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edges_wl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edges_wl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_tail(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_tail", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_tail_char, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0006;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0005;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_tail", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_tail_char(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_tail_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0002;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0004;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'b'
- ) goto L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0005;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'f'
- ) goto L0005;
- ctx->cur++;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0006;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'n'
- ) goto L0006;
- ctx->cur++;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0007;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'r'
- ) goto L0007;
- ctx->cur++;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0008;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 't'
- ) goto L0008;
- ctx->cur++;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0010;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0009;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0009;
- ctx->cur += n;
- }
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_tail_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_tail_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_head(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_head", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_head_char, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0006;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0005;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_head", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_head_char(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_head_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0002;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0004;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'b'
- ) goto L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0005;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'f'
- ) goto L0005;
- ctx->cur++;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0006;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'n'
- ) goto L0006;
- ctx->cur++;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0007;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'r'
- ) goto L0007;
- ctx->cur++;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0008;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 't'
- ) goto L0008;
- ctx->cur++;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0010;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0009;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0009;
- ctx->cur += n;
- }
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_head_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_head_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_pair(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_x, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_y, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0000;
- ctx->cur++;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_n(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_n", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0002;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_n", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_x(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_x", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_y(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_y", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_style(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_style", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0002;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_style", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_color(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_color", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_eol, &chunk->thunks, NULL)) goto L0002;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_color", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_label(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_label", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_edge_char, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ' '
- ) goto L0006;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0005;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_label", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_char(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0002;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0002;
- ctx->cur++;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0003;
- ctx->cur++;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0004;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'b'
- ) goto L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0005;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'f'
- ) goto L0005;
- ctx->cur++;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0006;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'n'
- ) goto L0006;
- ctx->cur++;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0007;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 'r'
- ) goto L0007;
- ctx->cur++;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\\'
- ) goto L0008;
- ctx->cur++;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != 't'
- ) goto L0008;
- ctx->cur++;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\"'
- ) goto L0010;
- ctx->cur++;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0009;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0009;
- ctx->cur += n;
- }
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_xl(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_xl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_xl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_xl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_edge_yl(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "edge_yl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "edge_yl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "edge_yl", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_linestop(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "linestop", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 's' ||
- (ctx->buffer.buf + ctx->cur)[1] != 't' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'p'
- ) goto L0000;
- ctx->cur += 4;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "linestop", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "linestop", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_fpnum(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- const size_t p0 = ctx->cur;
- const size_t n0 = chunk->thunks.len;
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digit, &chunk->thunks, NULL)) goto L0001;
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- if (i < 1) {
- ctx->cur = p0;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
- goto L0000;
- }
- }
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '.'
- ) goto L0002;
- ctx->cur++;
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digit, &chunk->thunks, NULL)) goto L0003;
- if (ctx->cur == p) break;
- continue;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- goto L0004;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- L0004:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_digit(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0000;
- if (!(
- (u >= 0x000030 && u <= 0x000039)
- )) goto L0000;
- ctx->cur += n;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_eol(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "eol", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0000;
- if (!(
- u == 0x00000a
- )) goto L0000;
- ctx->cur += n;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "eol", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "eol", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule__(gvplain_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
- ctx->level++;
- pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
- pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
- {
- int i;
- for (i = 0;; i++) {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- if (!(
- u == 0x000020 ||
- u == 0x000009 ||
- u == 0x00000a ||
- u == 0x00000d
- )) goto L0001;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- break;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- gvplain_context_t *gvplain_create(void *auxil) {
- return pcc_context__create(auxil);
- }
- int gvplain_parse(gvplain_context_t *ctx, int *ret) {
- pcc_thunk_array_t thunks;
- pcc_thunk_array__init(ctx->auxil, &thunks, PCC_ARRAYSIZE);
- if (pcc_apply_rule(ctx, pcc_evaluate_rule_gvplain, &thunks, ret))
- pcc_do_action(ctx, &thunks, ret);
- else
- PCC_ERROR(ctx->auxil);
- pcc_commit_buffer(ctx);
- pcc_thunk_array__term(ctx->auxil, &thunks);
- return pcc_refill_buffer(ctx, 1) >= 1;
- }
- void gvplain_destroy(gvplain_context_t *ctx) {
- pcc_context__destroy(ctx);
- }
- int main() {
- gvplain_context_t *ctx=gvplain_create(NULL);
- while (gvplain_parse(ctx, NULL)){;}
- gvplain_destroy(ctx);
- return 0;
- }
|