123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191 |
- /* 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 "pascal.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)(pascal_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)(pascal_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 pascal_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 pascal_context_t *pcc_context__create(pcc_auxil_t auxil) {
- pascal_context_t *const ctx = (pascal_context_t *)PCC_MALLOC(auxil, sizeof(pascal_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(pascal_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(pascal_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(pascal_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(pascal_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(pascal_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(pascal_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(pascal_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 pcc_thunk_chunk_t *pcc_evaluate_rule_start(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_program(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_unit(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_uses(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_block(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_statements(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_declarations(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_declaration_part(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_interface_part(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_implementation_part(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_procedure_header(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_procedure_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_function_header(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_function_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument_list_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_types(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_type_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_constants(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_constant(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_const_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_field_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_vars(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_var_declaration(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_type(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_statement(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_compound(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_assignment(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_lvalue(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_field_access(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_array_accesses(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_array_access(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_procedure_call(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument_list(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_if_else(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_if(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_for(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_while(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_repeat(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_with(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_function_call(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_expression(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_negation(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_comparision(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_or_binary(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_or_expr(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_and_binary(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_and_expr(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_base_expr(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_nested_expression(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_primary(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_pointer_to(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_deref(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_identifier(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_string_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_string_character(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_boolean_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_integer_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_real_literal(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_comment(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_comment_character(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule__(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule___(pascal_context_t *ctx);
- static pcc_thunk_chunk_t *pcc_evaluate_rule_start(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "start", 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_program, &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_unit, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- {
- 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 L0004;
- ctx->cur += n;
- }
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0003;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- }
- 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, "start", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "start", 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_program(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "program", 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, 7) < 7 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'm'
- ) goto L0000;
- ctx->cur += 7;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_block, &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, "program", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "program", 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_unit(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "unit", 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] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[3] != 't'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 9) < 9 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 't' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'f' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[8] != 'e'
- ) goto L0000;
- ctx->cur += 9;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_interface_part, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 14) < 14 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'm' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'l' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'm' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[8] != 't' ||
- (ctx->buffer.buf + ctx->cur)[9] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[10] != 't' ||
- (ctx->buffer.buf + ctx->cur)[11] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[12] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[13] != 'n'
- ) goto L0000;
- ctx->cur += 14;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_implementation_part, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0000;
- ctx->cur += 3;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '.'
- ) goto L0000;
- ctx->cur++;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "unit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "unit", 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_uses(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "uses", 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] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[1] != 's' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[3] != 's'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ','
- ) goto L0001;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0001;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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 (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "uses", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "uses", 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_block(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "block", 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_declarations, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 5) < 5 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'b' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'n'
- ) goto L0000;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statements, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0000;
- ctx->cur += 3;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "block", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "block", 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_statements(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "statements", 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;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0001;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0001;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "statements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_declarations(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "declarations", 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;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_declaration_part, &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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "declarations", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_declaration_part(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "declaration_part", 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_uses, &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_types, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constants, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_vars, &chunk->thunks, NULL)) goto L0005;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_procedure_declaration, &chunk->thunks, NULL)) goto L0006;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_function_declaration, &chunk->thunks, NULL)) goto L0007;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "declaration_part", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "declaration_part", 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_interface_part(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "interface_part", 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_uses, &chunk->thunks, NULL)) goto L0003;
- goto L0002;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_types, &chunk->thunks, NULL)) goto L0004;
- goto L0002;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constants, &chunk->thunks, NULL)) goto L0005;
- goto L0002;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_vars, &chunk->thunks, NULL)) goto L0006;
- goto L0002;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_procedure_header, &chunk->thunks, NULL)) goto L0007;
- goto L0002;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_function_header, &chunk->thunks, NULL)) goto L0008;
- goto L0002;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- }
- 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, "interface_part", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_implementation_part(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "implementation_part", 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_declarations, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "implementation_part", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "implementation_part", 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_procedure_header(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "procedure_header", 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, 9) < 9 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[8] != 'e'
- ) goto L0002;
- ctx->cur += 9;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '('
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument_list_declaration, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ')'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 9) < 9 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[8] != 'e'
- ) goto L0003;
- ctx->cur += 9;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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, "procedure_header", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "procedure_header", 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_procedure_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "procedure_declaration", 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_procedure_header, &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_block, &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__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "procedure_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "procedure_declaration", 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_function_header(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "function_header", 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, 8) < 8 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'f' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[4] != 't' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'n'
- ) goto L0002;
- ctx->cur += 8;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '('
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument_list_declaration, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ')'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ':'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 8) < 8 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'f' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[4] != 't' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[6] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[7] != 'n'
- ) goto L0003;
- ctx->cur += 8;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ':'
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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, "function_header", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "function_header", 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_function_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "function_declaration", 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_function_header, &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_block, &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__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "function_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "function_declaration", 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_argument_list_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "argument_list_declaration", 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_argument_declaration, &chunk->thunks, NULL)) goto L0001;
- goto L0002;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- L0002:;
- }
- {
- int i;
- for (i = 0;; i++) {
- 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 L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument_declaration, &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, "argument_list_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "argument_declaration", 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, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'v' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'r'
- ) goto L0001;
- ctx->cur += 3;
- goto L0002;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- L0002:;
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ','
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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 L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "argument_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "argument_declaration", 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_types(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "types", 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] != 't' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'y' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- 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_type_declaration, &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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "types", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "types", 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_type_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "type_declaration", 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_identifier, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "type_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "type_declaration", 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_constants(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "constants", 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] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[3] != 's' ||
- (ctx->buffer.buf + ctx->cur)[4] != 't'
- ) goto L0000;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- 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_constant, &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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "constants", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "constants", 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_constant(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "constant", 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_identifier, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '='
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_const_literal, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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_identifier, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ':'
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '='
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_const_literal, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ';'
- ) goto L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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, "constant", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "constant", 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_const_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "const_literal", 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_literal, &chunk->thunks, NULL)) goto L0002;
- 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_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument_list, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- 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_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0004;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_field_literal, &chunk->thunks, NULL)) goto L0004;
- {
- int i;
- for (i = 0;; i++) {
- 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 L0005;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0005;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_field_literal, &chunk->thunks, NULL)) goto L0005;
- if (ctx->cur == p) break;
- continue;
- L0005:;
- 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 L0004;
- ctx->cur++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "const_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "const_literal", 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_field_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "field_literal", 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_identifier, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_literal, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "field_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "field_literal", 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_vars(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "vars", 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, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'v' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'r'
- ) goto L0000;
- ctx->cur += 3;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- {
- 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_var_declaration, &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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "vars", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "vars", 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_var_declaration(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "var_declaration", 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_identifier, &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_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ','
- ) goto L0001;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0001;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &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 (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ':'
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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__, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "var_declaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "var_declaration", 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_type(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "type", 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, 5) < 5 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'y'
- ) goto L0002;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '['
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_integer_literal, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != '.' ||
- (ctx->buffer.buf + ctx->cur)[1] != '.'
- ) goto L0002;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_integer_literal, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != ']'
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'f'
- ) goto L0002;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0002;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 6) < 6 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'c' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'd'
- ) goto L0003;
- ctx->cur += 6;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument_list_declaration, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- {
- 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 L0004;
- ctx->cur++;
- goto L0005;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- L0005:;
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0003;
- ctx->cur += 3;
- 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 L0006;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_type, &chunk->thunks, NULL)) goto L0006;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0007;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "type", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "type", 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_statement(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "statement", 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_compound, &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_procedure_call, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_assignment, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_if_else, &chunk->thunks, NULL)) goto L0005;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_if, &chunk->thunks, NULL)) goto L0006;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_for, &chunk->thunks, NULL)) goto L0007;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_while, &chunk->thunks, NULL)) goto L0008;
- goto L0001;
- L0008:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_repeat, &chunk->thunks, NULL)) goto L0009;
- goto L0001;
- L0009:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_with, &chunk->thunks, NULL)) goto L0010;
- goto L0001;
- L0010:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "statement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "statement", 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_compound(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "compound", 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] != 'b' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'g' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'n'
- ) goto L0000;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statements, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0000;
- ctx->cur += 3;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "compound", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "compound", 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_assignment(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "assignment", 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_lvalue, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != ':' ||
- (ctx->buffer.buf + ctx->cur)[1] != '='
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "assignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "assignment", 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_lvalue(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "lvalue", 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_field_access, &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_array_accesses, &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, "lvalue", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "lvalue", 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_field_access(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "field_access", 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_array_accesses, &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_lvalue, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "field_access", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "field_access", 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_array_accesses(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "array_accesses", 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_array_access, &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_identifier, &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, "array_accesses", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "array_accesses", 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_array_access(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "array_access", 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_identifier, &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_expression, &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, "array_access", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "array_access", 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_procedure_call(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "procedure_call", 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_identifier, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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_argument_list, &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, "procedure_call", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "procedure_call", 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_argument_list(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "argument_list", 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_argument, &chunk->thunks, NULL)) goto L0001;
- goto L0002;
- L0001:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- L0002:;
- }
- {
- int i;
- for (i = 0;; i++) {
- 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 L0003;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_argument, &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, "argument_list", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule_argument(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "argument", 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_expression, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "argument", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "argument", 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_if_else(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "if_else", 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, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'f'
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 't' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'h' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'n'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'l' ||
- (ctx->buffer.buf + ctx->cur)[2] != 's' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "if_else", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "if_else", 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_if(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "if", 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, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'f'
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 't' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'h' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'n'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "if", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "if", 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_for(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "for", 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, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'f' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'r'
- ) goto L0000;
- ctx->cur += 3;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != ':' ||
- (ctx->buffer.buf + ctx->cur)[1] != '='
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &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;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 't' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o'
- ) goto L0002;
- ctx->cur += 2;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 6) < 6 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'w' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[4] != 't' ||
- (ctx->buffer.buf + ctx->cur)[5] != 'o'
- ) goto L0003;
- ctx->cur += 6;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o'
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "for", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "for", 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_while(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "while", 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] != 'w' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'h' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'l' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'e'
- ) goto L0000;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o'
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "while", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "while", 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_repeat(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "repeat", 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, 6) < 6 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'p' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[5] != 't'
- ) goto L0000;
- ctx->cur += 6;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statements, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 5) < 5 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 't' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'l'
- ) goto L0000;
- ctx->cur += 5;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "repeat", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "repeat", 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_with(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "with", 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] != 'w' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[2] != 't' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'h'
- ) goto L0000;
- ctx->cur += 4;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lvalue, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0000;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o'
- ) goto L0000;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule___, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_statement, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "with", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "with", 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_function_call(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "function_call", 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_identifier, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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_argument_list, &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, "function_call", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "function_call", 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_expression(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "expression", 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_negation, &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_comparision, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "expression", 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_negation(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "negation", 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, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 't'
- ) goto L0000;
- ctx->cur += 3;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "negation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "negation", 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_comparision(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "comparision", 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_or_expr, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '='
- ) goto L0002;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0002;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &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_or_expr, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != '<' ||
- (ctx->buffer.buf + ctx->cur)[1] != '>'
- ) goto L0003;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0003;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0004;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0004;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != '>' ||
- (ctx->buffer.buf + ctx->cur)[1] != '='
- ) goto L0004;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0004;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0005;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0005;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != '<' ||
- (ctx->buffer.buf + ctx->cur)[1] != '='
- ) goto L0005;
- ctx->cur += 2;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0005;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0005;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0006;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0006;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '>'
- ) goto L0006;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0006;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0006;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0007;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0007;
- if (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '<'
- ) goto L0007;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0007;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0007;
- goto L0001;
- L0007:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "comparision", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "comparision", 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_or_binary(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "or_binary", 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_and_expr, &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;
- if (
- pcc_refill_buffer(ctx, 2) < 2 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r'
- ) goto L0002;
- ctx->cur += 2;
- 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++;
- 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++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_or_expr, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "or_binary", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "or_binary", 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_or_expr(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "or_expr", 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_or_binary, &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_and_expr, &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, "or_expr", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "or_expr", 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_and_binary(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "and_binary", 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_base_expr, &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;
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'n' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0002;
- ctx->cur += 3;
- 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++;
- 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++;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'd' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'i' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'v'
- ) goto L0005;
- ctx->cur += 3;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 3) < 3 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'm' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'o' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'd'
- ) goto L0006;
- ctx->cur += 3;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_and_expr, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "and_binary", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "and_binary", 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_and_expr(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "and_expr", 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_and_binary, &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_base_expr, &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, "and_expr", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "and_expr", 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_base_expr(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "base_expr", 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_primary, &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_nested_expression, &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, "base_expr", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "base_expr", 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_nested_expression(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "nested_expression", 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, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '('
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &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, "nested_expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "nested_expression", 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_primary(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "primary", 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_function_call, &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_pointer_to, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_deref, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_literal, &chunk->thunks, NULL)) goto L0005;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lvalue, &chunk->thunks, NULL)) goto L0006;
- goto L0001;
- L0006:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "primary", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "primary", 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_pointer_to(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "pointer_to", 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, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '@'
- ) goto L0000;
- ctx->cur++;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_identifier, &chunk->thunks, NULL)) goto L0000;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "pointer_to", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "pointer_to", 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_deref(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "deref", 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_identifier, &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, "deref", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "deref", 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_identifier(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "identifier", 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 >= 0x000041 && u <= 0x00005a) ||
- (u >= 0x000061 && u <= 0x00007a)
- )) goto L0000;
- ctx->cur += n;
- }
- {
- 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 >= 0x000041 && u <= 0x00005a) ||
- (u >= 0x000061 && u <= 0x00007a) ||
- (u >= 0x000030 && u <= 0x000039) ||
- u == 0x00005f
- )) 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, "identifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "identifier", 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_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "literal", 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_string_literal, &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_boolean_literal, &chunk->thunks, NULL)) goto L0003;
- goto L0001;
- L0003:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_real_literal, &chunk->thunks, NULL)) goto L0004;
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_integer_literal, &chunk->thunks, NULL)) goto L0005;
- goto L0001;
- L0005:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "literal", 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_string_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "string_literal", 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, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\''
- ) goto L0000;
- 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_string_character, &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 (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '\''
- ) goto L0000;
- ctx->cur++;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "string_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "string_literal", 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_string_character(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "string_character", 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 L0001;
- ctx->cur++;
- 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);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0000;
- ctx->cur += n;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "string_character", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "string_character", 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_boolean_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "boolean_literal", 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, 4) < 4 ||
- (ctx->buffer.buf + ctx->cur)[0] != 't' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'r' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'u' ||
- (ctx->buffer.buf + ctx->cur)[3] != 'e'
- ) goto L0002;
- ctx->cur += 4;
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- if (
- pcc_refill_buffer(ctx, 5) < 5 ||
- (ctx->buffer.buf + ctx->cur)[0] != 'f' ||
- (ctx->buffer.buf + ctx->cur)[1] != 'a' ||
- (ctx->buffer.buf + ctx->cur)[2] != 'l' ||
- (ctx->buffer.buf + ctx->cur)[3] != 's' ||
- (ctx->buffer.buf + ctx->cur)[4] != 'e'
- ) goto L0003;
- ctx->cur += 5;
- 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, "boolean_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "boolean_literal", 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_integer_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "integer_literal", 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++;
- {
- 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;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0003;
- if (!(
- (u >= 0x000030 && u <= 0x000039) ||
- (u >= 0x000041 && u <= 0x000046) ||
- (u >= 0x000061 && u <= 0x000066)
- )) goto L0003;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0003:;
- 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 L0002;
- }
- }
- goto L0001;
- L0002:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- {
- 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;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0005;
- if (!(
- (u >= 0x000030 && u <= 0x000039)
- )) 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;
- }
- if (i < 1) {
- ctx->cur = p0;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
- goto L0004;
- }
- }
- goto L0001;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0000;
- L0001:;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "integer_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "integer_literal", 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_real_literal(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "real_literal", 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;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0001;
- if (!(
- (u >= 0x000030 && u <= 0x000039)
- )) 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;
- }
- if (i < 1) {
- ctx->cur = p0;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
- 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;
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0002;
- if (!(
- (u >= 0x000030 && u <= 0x000039)
- )) goto L0002;
- ctx->cur += n;
- }
- if (ctx->cur == p) break;
- continue;
- L0002:;
- 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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "real_literal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "real_literal", 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_comment(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "comment", 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, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '{'
- ) goto L0000;
- 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_comment_character, &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 (
- pcc_refill_buffer(ctx, 1) < 1 ||
- ctx->buffer.buf[ctx->cur] != '}'
- ) goto L0000;
- ctx->cur++;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "comment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "comment", 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_comment_character(pascal_context_t *ctx) {
- pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
- chunk->pos = ctx->cur;
- PCC_DEBUG(PCC_DBG_EVALUATE, "comment_character", 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 L0001;
- ctx->cur++;
- 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);
- }
- {
- int u;
- const size_t n = pcc_get_char_as_utf32(ctx, &u);
- if (n == 0) goto L0000;
- ctx->cur += n;
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "comment_character", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "comment_character", 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__(pascal_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;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_comment, &chunk->thunks, NULL)) goto L0003;
- goto L0002;
- L0003:;
- 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 L0004;
- if (!(
- u == 0x000020 ||
- u == 0x000009 ||
- u == 0x00000a ||
- u == 0x00000d
- )) goto L0004;
- ctx->cur += n;
- }
- goto L0002;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- }
- 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;
- }
- static pcc_thunk_chunk_t *pcc_evaluate_rule___(pascal_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);
- {
- 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;
- {
- const size_t p = ctx->cur;
- const size_t n = chunk->thunks.len;
- if (!pcc_apply_rule(ctx, pcc_evaluate_rule_comment, &chunk->thunks, NULL)) goto L0003;
- goto L0002;
- L0003:;
- 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 L0004;
- if (!(
- u == 0x000020 ||
- u == 0x000009 ||
- u == 0x00000a ||
- u == 0x00000d
- )) goto L0004;
- ctx->cur += n;
- }
- goto L0002;
- L0004:;
- ctx->cur = p;
- pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
- goto L0001;
- L0002:;
- }
- 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;
- }
- }
- ctx->level--;
- PCC_DEBUG(PCC_DBG_MATCH, "__", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- return chunk;
- L0000:;
- ctx->level--;
- PCC_DEBUG(PCC_DBG_NOMATCH, "__", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
- pcc_thunk_chunk__destroy(ctx->auxil, chunk);
- return NULL;
- }
- pascal_context_t *pascal_create(void *auxil) {
- return pcc_context__create(auxil);
- }
- int pascal_parse(pascal_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_start, &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 pascal_destroy(pascal_context_t *ctx) {
- pcc_context__destroy(ctx);
- }
- int main() {
- pascal_context_t *ctx=pascal_create(NULL);
- while (pascal_parse(ctx, NULL)){;}
- pascal_destroy(ctx);
- return 0;
- }
|