123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739 |
- diff --git a/src/pregen/DAAP.u b/src/pregen/DAAP.u
- new file mode 100644
- index 0000000..3de527b
- --- /dev/null
- +++ b/src/pregen/DAAP.u
- @@ -0,0 +1,6 @@
- +DAAPParser.c : DAAP.g
- +./DAAP.tokens : DAAP.g
- +DAAPParser.h : DAAP.g
- +DAAPLexer.c : DAAP.g
- +DAAPLexer.h : DAAP.g
- +ANTLR_PRODUCTS += DAAPParser.c ./DAAP.tokens DAAPParser.h DAAPLexer.c DAAPLexer.h
- \ No newline at end of file
- diff --git a/src/pregen/DAAP2SQL.c b/src/pregen/DAAP2SQL.c
- new file mode 100644
- index 0000000..04d6153
- --- /dev/null
- +++ b/src/pregen/DAAP2SQL.c
- @@ -0,0 +1,975 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP2SQL.g
- + * - On : 2016-01-01 12:23:43
- + * - for the tree parser : DAAP2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +
- +/* =============================================================================
- + * This is what the grammar programmer asked us to put at the top of every file.
- + */
- +
- + #include <stdio.h>
- + #include <stdlib.h>
- + #include <string.h>
- + #include <limits.h>
- + #include <errno.h>
- +
- + #include "logger.h"
- + #include "db.h"
- + #include "daap_query.h"
- +
- +/* End of Header action.
- + * =============================================================================
- + */
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "DAAP2SQL.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pDAAP2SQL_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pDAAP2SQL_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pDAAP2SQL_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pDAAP2SQL_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef BACKTRACKING
- +#undef ADAPTOR
- +#undef RULEMEMO
- +#undef SEEK
- +#undef INDEX
- +#undef DBG
- +
- +#define PARSER ctx->pTreeParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define INPUT PARSER->ctnstream
- +#define ISTREAM INPUT->tnstream->istream
- +#define STRSTREAM INPUT->tnstream
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) ISTREAM->_LA(ISTREAM, n)
- +#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR INPUT->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define DBG RECOGNIZER->debugger
- +
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 DAAP2SQLTokenNames[8+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "NEWLINE",
- + (pANTLR3_UINT8) "OPOR",
- + (pANTLR3_UINT8) "OPAND",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "QUOTE",
- + (pANTLR3_UINT8) "ESCAPED"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static pANTLR3_STRING query (pDAAP2SQL ctx);
- +static DAAP2SQL_expr_return expr (pDAAP2SQL ctx);
- +static void DAAP2SQLFree(pDAAP2SQL ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "DAAP2SQL.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new DAAP2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pDAAP2SQL
- +DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return DAAP2SQLNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new DAAP2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pDAAP2SQL
- +DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pDAAP2SQL ctx; /* Context structure we will build and return */
- +
- + ctx = (pDAAP2SQL) ANTLR3_CALLOC(1, sizeof(DAAP2SQL));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in DAAP2SQL.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base Tree parser/recognizer, using the supplied tree node stream
- + */
- + ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state);
- + /* Install the implementation of our DAAP2SQL interface
- + */
- + ctx->query = query;
- + ctx->expr = expr;
- + ctx->free = DAAP2SQLFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- +
- +
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = DAAP2SQLTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + DAAP2SQLFree(pDAAP2SQL ctx)
- + {
- + /* Free any scope memory
- + */
- +
- +
- + // Free this parser
- + //
- + ctx->pTreeParser->free(ctx->pTreeParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this tree parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return DAAP2SQLTokenNames;
- +}
- +
- +
- + struct dmap_query_field_map {
- + char *dmap_field;
- + char *db_col;
- + int as_int;
- + };
- +
- + /* gperf static hash, daap_query.gperf */
- + #include "daap_query_hash.c"
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_expr95 */
- +static ANTLR3_BITWORD FOLLOW_OPAND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_expr95 = { FOLLOW_OPAND_in_expr95_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr118 */
- +static ANTLR3_BITWORD FOLLOW_OPOR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr118 = { FOLLOW_OPOR_in_expr118_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expr140 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_expr140_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_expr140 = { FOLLOW_STR_in_expr140_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start query
- + * DAAP2SQL.g:50:1: query returns [ pANTLR3_STRING result ] : e= expr ;
- + */
- +static pANTLR3_STRING
- +query(pDAAP2SQL ctx)
- +{
- + pANTLR3_STRING result = NULL;
- +
- + DAAP2SQL_expr_return e;
- + #undef RETURN_TYPE_e
- + #define RETURN_TYPE_e DAAP2SQL_expr_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + result= NULL;
- + {
- + // DAAP2SQL.g:52:2: (e= expr )
- + // DAAP2SQL.g:52:4: e= expr
- + {
- + FOLLOWPUSH(FOLLOW_expr_in_query70);
- + e=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + {
- +
- + if (!e.valid)
- + {
- + result= NULL;
- + }
- + else
- + {
- + result= e.result->factory->newRaw(e.result->factory);
- + result->append8(result, "(");
- + result->appendS(result, e.result);
- + result->append8(result, ")");
- + }
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulequeryEx; /* Prevent compiler warnings */
- + rulequeryEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return result;
- +}
- +/* $ANTLR end query */
- +
- +/**
- + * $ANTLR start expr
- + * DAAP2SQL.g:68:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR );
- + */
- +static DAAP2SQL_expr_return
- +expr(pDAAP2SQL ctx)
- +{
- + DAAP2SQL_expr_return retval;
- +
- + pANTLR3_BASE_TREE STR1;
- + DAAP2SQL_expr_return a;
- + #undef RETURN_TYPE_a
- + #define RETURN_TYPE_a DAAP2SQL_expr_return
- +
- + DAAP2SQL_expr_return b;
- + #undef RETURN_TYPE_b
- + #define RETURN_TYPE_b DAAP2SQL_expr_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.result= NULL; retval.valid= 1;
- + STR1 = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + {
- + // DAAP2SQL.g:70:2: ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR )
- +
- + ANTLR3_UINT32 alt1;
- +
- + alt1=3;
- +
- + switch ( LA(1) )
- + {
- + case OPAND:
- + {
- + alt1=1;
- + }
- + break;
- + case OPOR:
- + {
- + alt1=2;
- + }
- + break;
- + case STR:
- + {
- + alt1=3;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // DAAP2SQL.g:70:4: ^( OPAND a= expr b= expr )
- + {
- + MATCHT(OPAND, &FOLLOW_OPAND_in_expr95);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr101);
- + a=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr107);
- + b=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (a.valid && b.valid)
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->append8(retval.result, "(");
- + retval.result->appendS(retval.result, a.result);
- + retval.result->append8(retval.result, " AND ");
- + retval.result->appendS(retval.result, b.result);
- + retval.result->append8(retval.result, ")");
- + }
- + else if (a.valid)
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->appendS(retval.result, a.result);
- + }
- + else if (b.valid)
- + {
- + retval.result= b.result->factory->newRaw(b.result->factory);
- + retval.result->appendS(retval.result, b.result);
- + }
- + else
- + {
- + retval.valid= 0;
- + }
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // DAAP2SQL.g:96:4: ^( OPOR a= expr b= expr )
- + {
- + MATCHT(OPOR, &FOLLOW_OPOR_in_expr118);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr124);
- + a=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr130);
- + b=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (a.valid && b.valid)
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->append8(retval.result, "(");
- + retval.result->appendS(retval.result, a.result);
- + retval.result->append8(retval.result, " OR ");
- + retval.result->appendS(retval.result, b.result);
- + retval.result->append8(retval.result, ")");
- + }
- + else if (a.valid)
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->appendS(retval.result, a.result);
- + }
- + else if (b.valid)
- + {
- + retval.result= b.result->factory->newRaw(b.result->factory);
- + retval.result->appendS(retval.result, b.result);
- + }
- + else
- + {
- + retval.valid= 0;
- + }
- +
- + }
- +
- + }
- + break;
- + case 3:
- + // DAAP2SQL.g:122:4: STR
- + {
- + STR1 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expr140);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + pANTLR3_STRING str;
- + pANTLR3_UINT8 field;
- + pANTLR3_UINT8 val;
- + pANTLR3_UINT8 escaped;
- + ANTLR3_UINT8 op;
- + int neg_op;
- + const struct dmap_query_field_map *dqfm;
- + char *end;
- + long long llval;
- +
- + escaped = NULL;
- +
- + retval.result= (STR1->getText(STR1))->factory->newRaw((STR1->getText(STR1))->factory);
- +
- + str = (STR1->getText(STR1))->toUTF8((STR1->getText(STR1)));
- +
- + /* NOTE: the lexer delivers the string without quotes
- + which may not be obvious from the grammar due to embedded code
- + */
- +
- + /* Make daap.songalbumid:0 a no-op */
- + if (strcmp((char *)str->chars, "daap.songalbumid:0") == 0)
- + {
- + retval.result->append8(retval.result, "1 = 1");
- +
- + goto STR_out;
- + }
- +
- + field = str->chars;
- +
- + val = field;
- + while ((*val != '\0') && ((*val == '.')
- + || (*val == '-')
- + || ((*val >= 'a') && (*val <= 'z'))
- + || ((*val >= 'A') && (*val <= 'Z'))
- + || ((*val >= '0') && (*val <= '9'))))
- + {
- + val++;
- + }
- +
- + if (*field == '\0')
- + {
- + DPRINTF(E_LOG, L_DAAP, "No field name found in clause '%s'\n", field);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + if (*val == '\0')
- + {
- + DPRINTF(E_LOG, L_DAAP, "No operator found in clause '%s'\n", field);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + op = *val;
- + *val = '\0';
- + val++;
- +
- + if (op == '!')
- + {
- + if (*val == '\0')
- + {
- + DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '%s%c'\n", field, op);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + neg_op = 1;
- + op = *val;
- + val++;
- + }
- + else
- + neg_op = 0;
- +
- + /* Lookup DMAP field in the query field map */
- + dqfm = daap_query_field_lookup((char *)field, strlen((char *)field));
- + if (!dqfm)
- + {
- + DPRINTF(E_LOG, L_DAAP, "DMAP field '%s' is not a valid field in queries\n", field);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + /* Empty values OK for string fields, NOK for integer */
- + if (*val == '\0')
- + {
- + if (dqfm->as_int)
- + {
- + DPRINTF(E_LOG, L_DAAP, "No value given in clause '%s%s%c'\n", field, (neg_op) ? "!" : "", op);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + /* No need to exclude empty artist and album, as forked-daapd makes sure there always exists an artist/album. */
- + if (neg_op && op == ':'
- + && (strcmp((char *)field, "daap.songalbumartist") == 0
- + || strcmp((char *)field, "daap.songartist") == 0
- + || strcmp((char *)field, "daap.songalbum") == 0))
- + {
- + DPRINTF(E_DBG, L_DAAP, "Ignoring clause '%s%s%c'\n", field, (neg_op) ? "!" : "", op);
- + retval.valid= 0;
- + goto STR_result_valid_0;
- + }
- +
- + /* Need to check against NULL too */
- + if (op == ':')
- + retval.result->append8(retval.result, "(");
- + }
- +
- + /* Int field: check integer conversion */
- + if (dqfm->as_int)
- + {
- + errno = 0;
- + llval = strtoll((const char *)val, &end, 10);
- +
- + if (((errno == ERANGE) && ((llval == LLONG_MAX) || (llval == LLONG_MIN)))
- + || ((errno != 0) && (llval == 0)))
- + {
- + DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not convert to an integer type\n",
- + val, field, (neg_op) ? "!" : "", op, val);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + if (end == (char *)val)
- + {
- + DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not represent an integer value\n",
- + val, field, (neg_op) ? "!" : "", op, val);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + *end = '\0'; /* Cut out potential garbage - we're being kind */
- +
- + /* forked-daapd only has media_kind = 1 for music - so remove media_kind = 32 to imporve select query performance. */
- + if (llval == 32
- + && (strcmp((char *)field, "com.apple.itunes.mediakind") == 0
- + || strcmp((char *)field, "com.apple.itunes.extended-media-kind") == 0))
- + {
- + DPRINTF(E_DBG, L_DAAP, "Ignoring clause '%s%s%c%s'\n", field, (neg_op) ? "!" : "", op, val);
- +
- + if (neg_op)
- + retval.result->append8(retval.result, "1 = 1");
- + else
- + retval.result->append8(retval.result, "1 = 0");
- +
- + goto STR_out;
- + }
- + }
- + /* String field: escape string, check for '*' */
- + else
- + {
- + if (op != ':')
- + {
- + DPRINTF(E_LOG, L_DAAP, "Operation '%c' not valid for string values\n", op);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + escaped = (pANTLR3_UINT8)db_escape_string((char *)val);
- + if (!escaped)
- + {
- + DPRINTF(E_LOG, L_DAAP, "Could not escape value\n");
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + }
- +
- + val = escaped;
- +
- + if (val[0] == '*')
- + {
- + op = '%';
- + val[0] = '%';
- + }
- +
- + if (val[0] && val[1] && val[strlen((char *)val) - 1] == '*')
- + {
- + op = '%';
- + val[strlen((char *)val) - 1] = '%';
- + }
- + }
- +
- + retval.result->append8(retval.result, dqfm->db_col);
- +
- + switch(op)
- + {
- + case ':':
- + if (neg_op)
- + retval.result->append8(retval.result, " <> ");
- + else
- + retval.result->append8(retval.result, " = ");
- + break;
- +
- + case '+':
- + if (neg_op)
- + retval.result->append8(retval.result, " <= ");
- + else
- + retval.result->append8(retval.result, " > ");
- + break;
- +
- + case '-':
- + if (neg_op)
- + retval.result->append8(retval.result, " >= ");
- + else
- + retval.result->append8(retval.result, " < ");
- + break;
- +
- + case '%':
- + retval.result->append8(retval.result, " LIKE ");
- + break;
- +
- + default:
- + if (neg_op)
- + DPRINTF(E_LOG, L_DAAP, "Missing or unknown operator '%c' in clause '%s!%c%s'\n", op, field, op, val);
- + else
- + DPRINTF(E_LOG, L_DAAP, "Unknown operator '%c' in clause '%s%c%s'\n", op, field, op, val);
- + retval.valid= 0;
- + goto STR_result_valid_0; /* ABORT */
- + break;
- + }
- +
- + if (!dqfm->as_int)
- + retval.result->append8(retval.result, "'");
- +
- + retval.result->append8(retval.result, (const char *)val);
- +
- + if (!dqfm->as_int)
- + retval.result->append8(retval.result, "'");
- +
- + /* For empty string value, we need to check against NULL too */
- + if ((*val == '\0') && (op == ':'))
- + {
- + if (neg_op)
- + retval.result->append8(retval.result, " AND ");
- + else
- + retval.result->append8(retval.result, " OR ");
- +
- + retval.result->append8(retval.result, dqfm->db_col);
- +
- + if (neg_op)
- + retval.result->append8(retval.result, " IS NOT NULL");
- + else
- + retval.result->append8(retval.result, " IS NULL");
- +
- + retval.result->append8(retval.result, ")");
- + }
- +
- + STR_result_valid_0: /* bail out label */
- + ;
- +
- + if (escaped)
- + free(escaped);
- +
- + STR_out: /* get out of here */
- + ;
- +
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexprEx; /* Prevent compiler warnings */
- + ruleexprEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end expr */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/DAAP2SQL.h b/src/pregen/DAAP2SQL.h
- new file mode 100644
- index 0000000..e829049
- --- /dev/null
- +++ b/src/pregen/DAAP2SQL.h
- @@ -0,0 +1,195 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP2SQL.g
- + * - On : 2016-01-01 12:23:43
- + * - for the tree parser : DAAP2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The tree parser DAAP2SQL has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pDAAP2SQL, which is returned from a call to DAAP2SQLNew().
- + *
- + * The methods in pDAAP2SQL are as follows:
- + *
- + * - pANTLR3_STRING pDAAP2SQL->query(pDAAP2SQL)
- + * - DAAP2SQL_expr_return pDAAP2SQL->expr(pDAAP2SQL)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _DAAP2SQL_H
- +#define _DAAP2SQL_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct DAAP2SQL_Ctx_struct DAAP2SQL, * pDAAP2SQL;
- +
- +
- +
- + #include <stdio.h>
- + #include <stdlib.h>
- + #include <string.h>
- + #include <limits.h>
- + #include <errno.h>
- +
- + #include "logger.h"
- + #include "db.h"
- + #include "daap_query.h"
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct DAAP2SQL_expr_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING result;
- + int valid;
- +}
- + DAAP2SQL_expr_return;
- +
- +
- +
- +/** Context tracking structure for DAAP2SQL
- + */
- +struct DAAP2SQL_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_TREE_PARSER pTreeParser;
- +
- +
- + pANTLR3_STRING (*query) (struct DAAP2SQL_Ctx_struct * ctx);
- + DAAP2SQL_expr_return (*expr) (struct DAAP2SQL_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct DAAP2SQL_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pDAAP2SQL DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
- +ANTLR3_API pDAAP2SQL DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the tree parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STR 9
- +#define QUOTE 10
- +#define NEWLINE 4
- +#define LPAR 7
- +#define OPOR 5
- +#define RPAR 8
- +#define ESCAPED 11
- +#define OPAND 6
- +#define EOF -1
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for DAAP2SQL
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/DAAP2SQL.u b/src/pregen/DAAP2SQL.u
- new file mode 100644
- index 0000000..385d80b
- --- /dev/null
- +++ b/src/pregen/DAAP2SQL.u
- @@ -0,0 +1,5 @@
- +DAAP2SQL.g: DAAP.tokens
- +DAAP2SQL.c : DAAP2SQL.g
- +./DAAP2SQL.tokens : DAAP2SQL.g
- +DAAP2SQL.h : DAAP2SQL.g
- +ANTLR_PRODUCTS += DAAP2SQL.c ./DAAP2SQL.tokens DAAP2SQL.h
- \ No newline at end of file
- diff --git a/src/pregen/DAAPLexer.c b/src/pregen/DAAPLexer.c
- new file mode 100644
- index 0000000..eab3ff4
- --- /dev/null
- +++ b/src/pregen/DAAPLexer.c
- @@ -0,0 +1,1101 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP.g
- + * - On : 2016-01-01 12:23:41
- + * - for the lexer : DAAPLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "DAAPLexer.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pDAAPLexer_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pDAAPLexer_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pDAAPLexer_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pDAAPLexer_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +
- +/* Macros for accessing things in a lexer
- + */
- +#undef LEXER
- +#undef RECOGNIZER
- +#undef RULEMEMO
- +#undef GETCHARINDEX
- +#undef GETLINE
- +#undef GETCHARPOSITIONINLINE
- +#undef EMIT
- +#undef EMITNEW
- +#undef MATCHC
- +#undef MATCHS
- +#undef MATCHRANGE
- +#undef LTOKEN
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef INPUT
- +#undef STRSTREAM
- +#undef LA
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef LRECOVER
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef BACKTRACKING
- +#undef MATCHANY
- +#undef MEMOIZE
- +#undef HAVEPARSEDRULE
- +#undef GETTEXT
- +#undef INDEX
- +#undef SEEK
- +#undef PUSHSTREAM
- +#undef POPSTREAM
- +#undef SETTEXT
- +#undef SETTEXT8
- +
- +#define LEXER ctx->pLexer
- +#define RECOGNIZER LEXER->rec
- +#define LEXSTATE RECOGNIZER->state
- +#define TOKSOURCE LEXSTATE->tokSource
- +#define GETCHARINDEX() LEXER->getCharIndex(LEXER)
- +#define GETLINE() LEXER->getLine(LEXER)
- +#define GETTEXT() LEXER->getText(LEXER)
- +#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
- +#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)
- +#define EMITNEW(t) LEXER->emitNew(LEXER, t)
- +#define MATCHC(c) LEXER->matchc(LEXER, c)
- +#define MATCHS(s) LEXER->matchs(LEXER, s)
- +#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)
- +#define MATCHANY() LEXER->matchAny(LEXER)
- +#define LTOKEN LEXSTATE->token
- +#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)
- +#define BACKTRACKING LEXSTATE->backtracking
- +#define FAILEDFLAG LEXSTATE->failed
- +#define INPUT LEXER->input
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)
- +#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION LEXSTATE->exception
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define LRECOVER() LEXER->recover(LEXER)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)
- +#define POPSTREAM() LEXER->popCharStream(LEXER)
- +#define SETTEXT(str) LEXSTATE->text = str
- +#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)
- +#define USER1 LEXSTATE->user1
- +#define USER2 LEXSTATE->user2
- +#define USER3 LEXSTATE->user3
- +#define CUSTOM LEXSTATE->custom
- +#define RULEMEMO LEXSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +/* If we have been told we can rely on the standard 8 bit or 16 bit input
- + * stream, then we can define our macros to use the direct pointers
- + * in the input object, which is much faster than indirect calls. This
- + * is really only significant to lexers with a lot of fragment rules (which
- + * do not place LA(1) in a temporary at the moment) and even then
- + * only if there is a lot of input (order of say 1M or so).
- + */
- +#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
- +
- +# ifdef ANTLR3_INLINE_INPUT_ASCII
- +
- +/* 8 bit "ASCII" (actually any 8 bit character set) */
- +
- +# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT8)(INPUT->data))
- +
- +# else
- +
- +# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT16)(INPUT->data))
- +
- +# endif
- +
- +# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
- +# define CONSUME() \
- +{ \
- + if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \
- + { \
- + INPUT->charPositionInLine++; \
- + if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \
- + { \
- + INPUT->line++; \
- + INPUT->charPositionInLine = 0; \
- + INPUT->currentLine = (void *)(NEXTCHAR + 1); \
- + } \
- + INPUT->nextChar = (void *)(NEXTCHAR + 1); \
- + } \
- +}
- +
- +#else
- +
- +// Pick up the input character by calling the input stream implementation.
- +//
- +#define CONSUME() INPUT->istream->consume(INPUT->istream)
- +#define LA(n) INPUT->istream->_LA(INPUT->istream, n)
- +
- +#endif
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +/* Forward declare the locally static matching functions we have generated and any predicate functions.
- + */
- +static ANTLR3_INLINE void mQUOTE (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mLPAR (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mRPAR (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mOPAND (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mOPOR (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mNEWLINE (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mSTR (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mESCAPED (pDAAPLexer ctx);
- +static ANTLR3_INLINE void mTokens (pDAAPLexer ctx);
- +static void DAAPLexerFree(pDAAPLexer ctx);
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +
- +
- +
- +static void
- +DAAPLexerFree (pDAAPLexer ctx)
- +{
- + LEXER->free(LEXER);
- +
- + ANTLR3_FREE(ctx);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "DAAP.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +
- +/** \brief Create a new lexer called DAAPLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \return
- + * - Success pDAAPLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pDAAPLexer DAAPLexerNew
- +(pANTLR3_INPUT_STREAM instream)
- +{
- + // See if we can create a new lexer with the standard constructor
- + //
- + return DAAPLexerNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new lexer called DAAPLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \param[state] state Previously created shared recognizer stat
- + * \return
- + * - Success pDAAPLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pDAAPLexer DAAPLexerNewSSD
- +(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pDAAPLexer ctx; // Context structure we will build and return
- +
- + ctx = (pDAAPLexer) ANTLR3_CALLOC(1, sizeof(DAAPLexer));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for lexer context
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * in base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 lexer function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in DAAPLexer.h here so you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base lexer, using the supplied input stream
- + */
- + ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
- +
- + /* Check that we allocated the memory correctly
- + */
- + if (ctx->pLexer == NULL)
- + {
- + ANTLR3_FREE(ctx);
- + return NULL;
- + }
- + /* Install the implementation of our DAAPLexer interface
- + */
- + ctx->mQUOTE = mQUOTE;
- + ctx->mLPAR = mLPAR;
- + ctx->mRPAR = mRPAR;
- + ctx->mOPAND = mOPAND;
- + ctx->mOPOR = mOPOR;
- + ctx->mNEWLINE = mNEWLINE;
- + ctx->mSTR = mSTR;
- + ctx->mESCAPED = mESCAPED;
- + ctx->mTokens = mTokens;
- +
- + /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
- + * it will call mTokens() in this generated code, and will pass it the ctx
- + * pointer of this lexer, not the context of the base lexer, so store that now.
- + */
- + ctx->pLexer->ctx = ctx;
- +
- + /**Install the token matching function
- + */
- + ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
- +
- + ctx->getGrammarFileName = getGrammarFileName;
- + ctx->free = DAAPLexerFree;
- +
- +
- +
- +
- +
- + /* Return the newly built lexer to the caller
- + */
- + return ctx;
- +}
- +
- +
- +/* =========================================================================
- + * Functions to match the lexer grammar defined tokens from the input stream
- + */
- +
- +// Comes from: 40:7: ( '\\'' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start QUOTE
- + *
- + * Looks to match the characters the constitute the token QUOTE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mQUOTE(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = QUOTE;
- +
- +
- + // DAAP.g:40:7: ( '\\'' )
- + // DAAP.g:40:9: '\\''
- + {
- + MATCHC('\'');
- + if (HASEXCEPTION())
- + {
- + goto ruleQUOTEEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleQUOTEEx; /* Prevent compiler warnings */
- + ruleQUOTEEx: ;
- +
- +}
- +// $ANTLR end QUOTE
- +
- +// Comes from: 41:6: ( '(' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LPAR
- + *
- + * Looks to match the characters the constitute the token LPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLPAR(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = LPAR;
- +
- +
- + // DAAP.g:41:6: ( '(' )
- + // DAAP.g:41:8: '('
- + {
- + MATCHC('(');
- + if (HASEXCEPTION())
- + {
- + goto ruleLPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLPAREx; /* Prevent compiler warnings */
- + ruleLPAREx: ;
- +
- +}
- +// $ANTLR end LPAR
- +
- +// Comes from: 42:6: ( ')' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start RPAR
- + *
- + * Looks to match the characters the constitute the token RPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mRPAR(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = RPAR;
- +
- +
- + // DAAP.g:42:6: ( ')' )
- + // DAAP.g:42:8: ')'
- + {
- + MATCHC(')');
- + if (HASEXCEPTION())
- + {
- + goto ruleRPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleRPAREx; /* Prevent compiler warnings */
- + ruleRPAREx: ;
- +
- +}
- +// $ANTLR end RPAR
- +
- +// Comes from: 44:7: ( '+' | ' ' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start OPAND
- + *
- + * Looks to match the characters the constitute the token OPAND
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mOPAND(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = OPAND;
- +
- +
- + // DAAP.g:44:7: ( '+' | ' ' )
- + // DAAP.g:
- + {
- + if ( LA(1) == ' ' || LA(1) == '+' )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleOPANDEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleOPANDEx; /* Prevent compiler warnings */
- + ruleOPANDEx: ;
- +
- +}
- +// $ANTLR end OPAND
- +
- +// Comes from: 45:6: ( ',' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start OPOR
- + *
- + * Looks to match the characters the constitute the token OPOR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mOPOR(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = OPOR;
- +
- +
- + // DAAP.g:45:6: ( ',' )
- + // DAAP.g:45:8: ','
- + {
- + MATCHC(',');
- + if (HASEXCEPTION())
- + {
- + goto ruleOPOREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleOPOREx; /* Prevent compiler warnings */
- + ruleOPOREx: ;
- +
- +}
- +// $ANTLR end OPOR
- +
- +// Comes from: 47:9: ( ( '\\r' )? '\\n' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start NEWLINE
- + *
- + * Looks to match the characters the constitute the token NEWLINE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mNEWLINE(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = NEWLINE;
- +
- +
- + // DAAP.g:47:9: ( ( '\\r' )? '\\n' )
- + // DAAP.g:47:11: ( '\\r' )? '\\n'
- + {
- +
- + // DAAP.g:47:11: ( '\\r' )?
- + {
- + int alt1=2;
- + switch ( LA(1) )
- + {
- + case '\r':
- + {
- + alt1=1;
- + }
- + break;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // DAAP.g:47:11: '\\r'
- + {
- + MATCHC('\r');
- + if (HASEXCEPTION())
- + {
- + goto ruleNEWLINEEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- + MATCHC('\n');
- + if (HASEXCEPTION())
- + {
- + goto ruleNEWLINEEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleNEWLINEEx; /* Prevent compiler warnings */
- + ruleNEWLINEEx: ;
- +
- +}
- +// $ANTLR end NEWLINE
- +
- +// Comes from: 55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start STR
- + *
- + * Looks to match the characters the constitute the token STR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mSTR(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- + pANTLR3_COMMON_TOKEN esc;
- + ANTLR3_UINT32 reg;
- +
- +
- + esc = NULL;
- +
- + _type = STR;
- +
- + pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory);
- +
- + // DAAP.g:55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
- + // DAAP.g:55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE
- + {
- + /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + // DAAP.g:55:10: (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+
- + {
- + int cnt2=0;
- +
- + for (;;)
- + {
- + int alt2=3;
- + {
- + /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
- + */
- + int LA2_0 = LA(1);
- + if ( (((LA2_0 >= 0x0000) && (LA2_0 <= '&')) || ((LA2_0 >= '(') && (LA2_0 <= '[')) || ((LA2_0 >= ']') && (LA2_0 <= 0xFFFF))) )
- + {
- + alt2=1;
- + }
- + else if ( (LA2_0 == '\\') )
- + {
- + alt2=2;
- + }
- +
- + }
- + switch (alt2)
- + {
- + case 1:
- + // DAAP.g:55:12: reg=~ ( '\\\\' | '\\'' )
- + {
- + reg= LA(1);
- + if ( ((LA(1) >= 0x0000) && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleSTREx;
- + }
- +
- + {
- + unesc->addc(unesc, reg);
- + }
- +
- + }
- + break;
- + case 2:
- + // DAAP.g:56:6: esc= ESCAPED
- + {
- + /* 56:6: esc= ESCAPED */
- + {
- + ANTLR3_MARKER escStart118 = GETCHARINDEX();
- + mESCAPED(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory);
- + esc->setType(esc, ANTLR3_TOKEN_INVALID);
- + esc->setStartIndex(esc, escStart118);
- + esc->setStopIndex(esc, GETCHARINDEX()-1);
- + esc->input = INPUT;
- + }
- + {
- + unesc->appendS(unesc, GETTEXT());
- + }
- +
- + }
- + break;
- +
- + default:
- +
- + if ( cnt2 >= 1 )
- + {
- + goto loop2;
- + }
- + /* mismatchedSetEx()
- + */
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
- +
- +
- + goto ruleSTREx;
- + }
- + cnt2++;
- + }
- + loop2: ; /* Jump to here if this rule does not match */
- + }
- + /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + {
- + SETTEXT(unesc);
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleSTREx; /* Prevent compiler warnings */
- + ruleSTREx: ;
- +
- + esc = NULL;
- +
- +}
- +// $ANTLR end STR
- +
- +// Comes from: 59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start ESCAPED
- + *
- + * Looks to match the characters the constitute the token ESCAPED
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mESCAPED(pDAAPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // DAAP.g:59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
- + // DAAP.g:59:11: '\\\\' ( '\\\\' | '\\'' )
- + {
- + MATCHC('\\');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- +
- + // DAAP.g:60:3: ( '\\\\' | '\\'' )
- + {
- + int alt3=2;
- + switch ( LA(1) )
- + {
- + case '\\':
- + {
- + alt3=1;
- + }
- + break;
- + case '\'':
- + {
- + alt3=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleESCAPEDEx;
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // DAAP.g:60:5: '\\\\'
- + {
- + MATCHC('\\');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- + {
- + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\"));
- + }
- +
- + }
- + break;
- + case 2:
- + // DAAP.g:61:5: '\\''
- + {
- + MATCHC('\'');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- + {
- + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'"));
- + }
- +
- + }
- + break;
- +
- + }
- + }
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleESCAPEDEx; /* Prevent compiler warnings */
- + ruleESCAPEDEx: ;
- +
- +}
- +// $ANTLR end ESCAPED
- +
- +/** This is the entry point in to the lexer from an object that
- + * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
- + */
- +static void
- +mTokens(pDAAPLexer ctx)
- +{
- + {
- + // DAAP.g:1:8: ( QUOTE | LPAR | RPAR | OPAND | OPOR | NEWLINE | STR )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=7;
- +
- + switch ( LA(1) )
- + {
- + case '\'':
- + {
- +
- + {
- + int LA4_1 = LA(2);
- + if ( (((LA4_1 >= 0x0000) && (LA4_1 <= '&')) || ((LA4_1 >= '(') && (LA4_1 <= 0xFFFF))) )
- + {
- + alt4=7;
- + }
- + else
- + {
- + alt4=1; }
- + }
- + }
- + break;
- + case '(':
- + {
- + alt4=2;
- + }
- + break;
- + case ')':
- + {
- + alt4=3;
- + }
- + break;
- + case ' ':
- + case '+':
- + {
- + alt4=4;
- + }
- + break;
- + case ',':
- + {
- + alt4=5;
- + }
- + break;
- + case '\n':
- + case '\r':
- + {
- + alt4=6;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // DAAP.g:1:10: QUOTE
- + {
- + /* 1:10: QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // DAAP.g:1:16: LPAR
- + {
- + /* 1:16: LPAR */
- + mLPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 3:
- + // DAAP.g:1:21: RPAR
- + {
- + /* 1:21: RPAR */
- + mRPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 4:
- + // DAAP.g:1:26: OPAND
- + {
- + /* 1:26: OPAND */
- + mOPAND(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 5:
- + // DAAP.g:1:32: OPOR
- + {
- + /* 1:32: OPOR */
- + mOPOR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 6:
- + // DAAP.g:1:37: NEWLINE
- + {
- + /* 1:37: NEWLINE */
- + mNEWLINE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 7:
- + // DAAP.g:1:45: STR
- + {
- + /* 1:45: STR */
- + mSTR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- +
- +
- + goto ruleTokensEx; /* Prevent compiler warnings */
- +ruleTokensEx: ;
- +}
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +/* End of Lexer code
- + * ================================================
- + * ================================================
- + */
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/DAAPLexer.h b/src/pregen/DAAPLexer.h
- new file mode 100644
- index 0000000..685a0bc
- --- /dev/null
- +++ b/src/pregen/DAAPLexer.h
- @@ -0,0 +1,188 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP.g
- + * - On : 2016-01-01 12:23:41
- + * - for the lexer : DAAPLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The lexer DAAPLexer has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pDAAPLexer, which is returned from a call to DAAPLexerNew().
- + *
- + * As this is a generated lexer, it is unlikely you will call it 'manually'. However
- + * the methods are provided anyway.
- + * * The methods in pDAAPLexer are as follows:
- + *
- + * - void pDAAPLexer->QUOTE(pDAAPLexer)
- + * - void pDAAPLexer->LPAR(pDAAPLexer)
- + * - void pDAAPLexer->RPAR(pDAAPLexer)
- + * - void pDAAPLexer->OPAND(pDAAPLexer)
- + * - void pDAAPLexer->OPOR(pDAAPLexer)
- + * - void pDAAPLexer->NEWLINE(pDAAPLexer)
- + * - void pDAAPLexer->STR(pDAAPLexer)
- + * - void pDAAPLexer->ESCAPED(pDAAPLexer)
- + * - void pDAAPLexer->Tokens(pDAAPLexer)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _DAAPLexer_H
- +#define _DAAPLexer_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct DAAPLexer_Ctx_struct DAAPLexer, * pDAAPLexer;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +
- +/** Context tracking structure for DAAPLexer
- + */
- +struct DAAPLexer_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_LEXER pLexer;
- +
- +
- + void (*mQUOTE) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mLPAR) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mRPAR) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mOPAND) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mOPOR) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mNEWLINE) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mSTR) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mESCAPED) (struct DAAPLexer_Ctx_struct * ctx);
- + void (*mTokens) (struct DAAPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)();
- + void (*free) (struct DAAPLexer_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pDAAPLexer DAAPLexerNew (pANTLR3_INPUT_STREAM instream);
- +ANTLR3_API pDAAPLexer DAAPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the lexer will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STR 9
- +#define QUOTE 10
- +#define NEWLINE 4
- +#define LPAR 7
- +#define OPOR 5
- +#define RPAR 8
- +#define ESCAPED 11
- +#define OPAND 6
- +#define EOF -1
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for DAAPLexer
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/DAAPParser.c b/src/pregen/DAAPParser.c
- new file mode 100644
- index 0000000..1091f05
- --- /dev/null
- +++ b/src/pregen/DAAPParser.c
- @@ -0,0 +1,1014 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP.g
- + * - On : 2016-01-01 12:23:41
- + * - for the parser : DAAPParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "DAAPParser.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pDAAPParser_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pDAAPParser_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pDAAPParser_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pDAAPParser_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef MEMOIZE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef INDEX
- +#undef ADAPTOR
- +#undef SEEK
- +#undef RULEMEMO
- +#undef DBG
- +
- +#define PARSER ctx->pParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define INPUT PARSER->tstream
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(INPUT->istream)
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) INPUT->istream->_LA(ISTREAM, n)
- +#define LT(n) INPUT->_LT(INPUT, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR ctx->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 DAAPParserTokenNames[8+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "NEWLINE",
- + (pANTLR3_UINT8) "OPOR",
- + (pANTLR3_UINT8) "OPAND",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "QUOTE",
- + (pANTLR3_UINT8) "ESCAPED"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static DAAPParser_query_return query (pDAAPParser ctx);
- +static DAAPParser_expr_return expr (pDAAPParser ctx);
- +static DAAPParser_aexpr_return aexpr (pDAAPParser ctx);
- +static DAAPParser_crit_return crit (pDAAPParser ctx);
- +static void DAAPParserFree(pDAAPParser ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "DAAP.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new DAAPParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pDAAPParser
- +DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return DAAPParserNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new DAAPParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pDAAPParser
- +DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pDAAPParser ctx; /* Context structure we will build and return */
- +
- + ctx = (pDAAPParser) ANTLR3_CALLOC(1, sizeof(DAAPParser));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in DAAPParser.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base parser/recognizer, using the supplied token stream
- + */
- + ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
- + /* Install the implementation of our DAAPParser interface
- + */
- + ctx->query = query;
- + ctx->expr = expr;
- + ctx->aexpr = aexpr;
- + ctx->crit = crit;
- + ctx->free = DAAPParserFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- + ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
- + ctx->vectors = antlr3VectorFactoryNew(0);
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = DAAPParserTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + DAAPParserFree(pDAAPParser ctx)
- + {
- + /* Free any scope memory
- + */
- +
- + ctx->vectors->close(ctx->vectors);
- + /* We created the adaptor so we must free it
- + */
- + ADAPTOR->free(ADAPTOR);
- + // Free this parser
- + //
- + ctx->pParser->free(ctx->pParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return DAAPParserTokenNames;
- +}
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */
- +static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */
- +static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr62 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr62_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr62 = { FOLLOW_aexpr_in_expr62_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr65 */
- +static ANTLR3_BITWORD FOLLOW_OPOR_in_expr65_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr65 = { FOLLOW_OPOR_in_expr65_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr68 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr68_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr68 = { FOLLOW_aexpr_in_expr68_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr80 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr80_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr80 = { FOLLOW_crit_in_aexpr80_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_aexpr83 */
- +static ANTLR3_BITWORD FOLLOW_OPAND_in_aexpr83_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_aexpr83 = { FOLLOW_OPAND_in_aexpr83_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr86 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr86_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr86 = { FOLLOW_crit_in_aexpr86_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit98 */
- +static ANTLR3_BITWORD FOLLOW_LPAR_in_crit98_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit98 = { FOLLOW_LPAR_in_crit98_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit100 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_crit100_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit100 = { FOLLOW_expr_in_crit100_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit102 */
- +static ANTLR3_BITWORD FOLLOW_RPAR_in_crit102_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit102 = { FOLLOW_RPAR_in_crit102_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit112 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_crit112_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_crit112 = { FOLLOW_STR_in_crit112_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start query
- + * DAAP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
- + */
- +static DAAPParser_query_return
- +query(pDAAPParser ctx)
- +{
- + DAAPParser_query_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN NEWLINE2;
- + pANTLR3_COMMON_TOKEN EOF3;
- + DAAPParser_expr_return expr1;
- + #undef RETURN_TYPE_expr1
- + #define RETURN_TYPE_expr1 DAAPParser_expr_return
- +
- + pANTLR3_BASE_TREE NEWLINE2_tree;
- + pANTLR3_BASE_TREE EOF3_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + NEWLINE2 = NULL;
- + EOF3 = NULL;
- + expr1.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + NEWLINE2_tree = NULL;
- + EOF3_tree = NULL;
- +
- + stream_NEWLINE = NULL;
- + #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); }
- + stream_EOF = NULL;
- + #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); }
- + stream_expr = NULL;
- + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
- +
- + retval.tree = NULL;
- + {
- + // DAAP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
- + // DAAP.g:27:9: expr ( NEWLINE )? EOF
- + {
- + FOLLOWPUSH(FOLLOW_expr_in_query42);
- + expr1=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);
- +
- + // DAAP.g:27:14: ( NEWLINE )?
- + {
- + int alt1=2;
- + switch ( LA(1) )
- + {
- + case NEWLINE:
- + {
- + alt1=1;
- + }
- + break;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // DAAP.g:27:14: NEWLINE
- + {
- + NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44);
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47);
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : expr
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 27:27: -> expr
- + {
- + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulequeryEx; /* Prevent compiler warnings */
- + rulequeryEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
- + if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
- + if (stream_expr != NULL) stream_expr->free(stream_expr);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end query */
- +
- +/**
- + * $ANTLR start expr
- + * DAAP.g:30:1: expr : aexpr ( OPOR aexpr )* ;
- + */
- +static DAAPParser_expr_return
- +expr(pDAAPParser ctx)
- +{
- + DAAPParser_expr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN OPOR5;
- + DAAPParser_aexpr_return aexpr4;
- + #undef RETURN_TYPE_aexpr4
- + #define RETURN_TYPE_aexpr4 DAAPParser_aexpr_return
- +
- + DAAPParser_aexpr_return aexpr6;
- + #undef RETURN_TYPE_aexpr6
- + #define RETURN_TYPE_aexpr6 DAAPParser_aexpr_return
- +
- + pANTLR3_BASE_TREE OPOR5_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + OPOR5 = NULL;
- + aexpr4.tree = NULL;
- +
- + aexpr6.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + OPOR5_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // DAAP.g:30:6: ( aexpr ( OPOR aexpr )* )
- + // DAAP.g:30:8: aexpr ( OPOR aexpr )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expr62);
- + aexpr4=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);
- +
- + // DAAP.g:30:14: ( OPOR aexpr )*
- +
- + for (;;)
- + {
- + int alt2=2;
- + switch ( LA(1) )
- + {
- + case OPOR:
- + {
- + alt2=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // DAAP.g:30:15: OPOR aexpr
- + {
- + OPOR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OPOR, &FOLLOW_OPOR_in_expr65);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + OPOR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPOR5));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPOR5_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expr68);
- + aexpr6=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop2; /* break out of the loop */
- + break;
- + }
- + }
- + loop2: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexprEx; /* Prevent compiler warnings */
- + ruleexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end expr */
- +
- +/**
- + * $ANTLR start aexpr
- + * DAAP.g:33:1: aexpr : crit ( OPAND crit )* ;
- + */
- +static DAAPParser_aexpr_return
- +aexpr(pDAAPParser ctx)
- +{
- + DAAPParser_aexpr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN OPAND8;
- + DAAPParser_crit_return crit7;
- + #undef RETURN_TYPE_crit7
- + #define RETURN_TYPE_crit7 DAAPParser_crit_return
- +
- + DAAPParser_crit_return crit9;
- + #undef RETURN_TYPE_crit9
- + #define RETURN_TYPE_crit9 DAAPParser_crit_return
- +
- + pANTLR3_BASE_TREE OPAND8_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + OPAND8 = NULL;
- + crit7.tree = NULL;
- +
- + crit9.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + OPAND8_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // DAAP.g:33:7: ( crit ( OPAND crit )* )
- + // DAAP.g:33:9: crit ( OPAND crit )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_aexpr80);
- + crit7=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);
- +
- + // DAAP.g:33:14: ( OPAND crit )*
- +
- + for (;;)
- + {
- + int alt3=2;
- + switch ( LA(1) )
- + {
- + case OPAND:
- + {
- + alt3=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // DAAP.g:33:15: OPAND crit
- + {
- + OPAND8 = (pANTLR3_COMMON_TOKEN) MATCHT(OPAND, &FOLLOW_OPAND_in_aexpr83);
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + OPAND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPAND8));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPAND8_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_aexpr86);
- + crit9=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop3; /* break out of the loop */
- + break;
- + }
- + }
- + loop3: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleaexprEx; /* Prevent compiler warnings */
- + ruleaexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end aexpr */
- +
- +/**
- + * $ANTLR start crit
- + * DAAP.g:36:1: crit : ( LPAR expr RPAR -> expr | STR );
- + */
- +static DAAPParser_crit_return
- +crit(pDAAPParser ctx)
- +{
- + DAAPParser_crit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN LPAR10;
- + pANTLR3_COMMON_TOKEN RPAR12;
- + pANTLR3_COMMON_TOKEN STR13;
- + DAAPParser_expr_return expr11;
- + #undef RETURN_TYPE_expr11
- + #define RETURN_TYPE_expr11 DAAPParser_expr_return
- +
- + pANTLR3_BASE_TREE LPAR10_tree;
- + pANTLR3_BASE_TREE RPAR12_tree;
- + pANTLR3_BASE_TREE STR13_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + LPAR10 = NULL;
- + RPAR12 = NULL;
- + STR13 = NULL;
- + expr11.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + LPAR10_tree = NULL;
- + RPAR12_tree = NULL;
- + STR13_tree = NULL;
- +
- + stream_RPAR = NULL;
- + #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
- + stream_LPAR = NULL;
- + #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
- + stream_expr = NULL;
- + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // DAAP.g:36:6: ( LPAR expr RPAR -> expr | STR )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=2;
- +
- + switch ( LA(1) )
- + {
- + case LPAR:
- + {
- + alt4=1;
- + }
- + break;
- + case STR:
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulecritEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // DAAP.g:36:8: LPAR expr RPAR
- + {
- + LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit98);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);
- +
- + FOLLOWPUSH(FOLLOW_expr_in_crit100);
- + expr11=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
- + RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit102);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : expr
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 36:24: -> expr
- + {
- + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- + case 2:
- + // DAAP.g:37:4: STR
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + STR13 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit112);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + STR13_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR13));
- + ADAPTOR->addChild(ADAPTOR, root_0, STR13_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulecritEx; /* Prevent compiler warnings */
- + rulecritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
- + if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
- + if (stream_expr != NULL) stream_expr->free(stream_expr);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end crit */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/DAAPParser.h b/src/pregen/DAAPParser.h
- new file mode 100644
- index 0000000..e206694
- --- /dev/null
- +++ b/src/pregen/DAAPParser.h
- @@ -0,0 +1,226 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : DAAP.g
- + * - On : 2016-01-01 12:23:41
- + * - for the parser : DAAPParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The parser DAAPParser has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pDAAPParser, which is returned from a call to DAAPParserNew().
- + *
- + * The methods in pDAAPParser are as follows:
- + *
- + * - DAAPParser_query_return pDAAPParser->query(pDAAPParser)
- + * - DAAPParser_expr_return pDAAPParser->expr(pDAAPParser)
- + * - DAAPParser_aexpr_return pDAAPParser->aexpr(pDAAPParser)
- + * - DAAPParser_crit_return pDAAPParser->crit(pDAAPParser)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _DAAPParser_H
- +#define _DAAPParser_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct DAAPParser_Ctx_struct DAAPParser, * pDAAPParser;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct DAAPParser_query_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + DAAPParser_query_return;
- +
- +typedef struct DAAPParser_expr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + DAAPParser_expr_return;
- +
- +typedef struct DAAPParser_aexpr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + DAAPParser_aexpr_return;
- +
- +typedef struct DAAPParser_crit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + DAAPParser_crit_return;
- +
- +
- +
- +/** Context tracking structure for DAAPParser
- + */
- +struct DAAPParser_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_PARSER pParser;
- +
- +
- + DAAPParser_query_return (*query) (struct DAAPParser_Ctx_struct * ctx);
- + DAAPParser_expr_return (*expr) (struct DAAPParser_Ctx_struct * ctx);
- + DAAPParser_aexpr_return (*aexpr) (struct DAAPParser_Ctx_struct * ctx);
- + DAAPParser_crit_return (*crit) (struct DAAPParser_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct DAAPParser_Ctx_struct * ctx);
- + /* @headerFile.members() */
- + pANTLR3_BASE_TREE_ADAPTOR adaptor;
- + pANTLR3_VECTOR_FACTORY vectors;
- + /* End @headerFile.members() */
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pDAAPParser DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream);
- +ANTLR3_API pDAAPParser DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STR 9
- +#define QUOTE 10
- +#define LPAR 7
- +#define NEWLINE 4
- +#define OPOR 5
- +#define RPAR 8
- +#define ESCAPED 11
- +#define OPAND 6
- +#define EOF -1
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for DAAPParser
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/RSP.u b/src/pregen/RSP.u
- new file mode 100644
- index 0000000..89256ff
- --- /dev/null
- +++ b/src/pregen/RSP.u
- @@ -0,0 +1,6 @@
- +RSPParser.c : RSP.g
- +./RSP.tokens : RSP.g
- +RSPParser.h : RSP.g
- +RSPLexer.c : RSP.g
- +RSPLexer.h : RSP.g
- +ANTLR_PRODUCTS += RSPParser.c ./RSP.tokens RSPParser.h RSPLexer.c RSPLexer.h
- \ No newline at end of file
- diff --git a/src/pregen/RSP2SQL.c b/src/pregen/RSP2SQL.c
- new file mode 100644
- index 0000000..40958f9
- --- /dev/null
- +++ b/src/pregen/RSP2SQL.c
- @@ -0,0 +1,2546 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP2SQL.g
- + * - On : 2016-01-01 12:23:43
- + * - for the tree parser : RSP2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +
- +/* =============================================================================
- + * This is what the grammar programmer asked us to put at the top of every file.
- + */
- +
- + /* Needs #define _GNU_SOURCE for strptime() */
- +
- + #include <stdio.h>
- + #include <string.h>
- + #include <time.h>
- + #include <stdint.h>
- +
- + #include "logger.h"
- + #include "db.h"
- + #include "misc.h"
- + #include "rsp_query.h"
- +
- +/* End of Header action.
- + * =============================================================================
- + */
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "RSP2SQL.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pRSP2SQL_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pRSP2SQL_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pRSP2SQL_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pRSP2SQL_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef BACKTRACKING
- +#undef ADAPTOR
- +#undef RULEMEMO
- +#undef SEEK
- +#undef INDEX
- +#undef DBG
- +
- +#define PARSER ctx->pTreeParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define INPUT PARSER->ctnstream
- +#define ISTREAM INPUT->tnstream->istream
- +#define STRSTREAM INPUT->tnstream
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) ISTREAM->_LA(ISTREAM, n)
- +#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR INPUT->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define DBG RECOGNIZER->debugger
- +
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 RSP2SQLTokenNames[30+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "NEWLINE",
- + (pANTLR3_UINT8) "OR",
- + (pANTLR3_UINT8) "AND",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "FIELD",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "NOT",
- + (pANTLR3_UINT8) "EQUAL",
- + (pANTLR3_UINT8) "INCLUDES",
- + (pANTLR3_UINT8) "STARTSW",
- + (pANTLR3_UINT8) "ENDSW",
- + (pANTLR3_UINT8) "INT",
- + (pANTLR3_UINT8) "LESS",
- + (pANTLR3_UINT8) "GREATER",
- + (pANTLR3_UINT8) "LTE",
- + (pANTLR3_UINT8) "GTE",
- + (pANTLR3_UINT8) "BEFORE",
- + (pANTLR3_UINT8) "AFTER",
- + (pANTLR3_UINT8) "DATE",
- + (pANTLR3_UINT8) "TODAY",
- + (pANTLR3_UINT8) "DAY",
- + (pANTLR3_UINT8) "WEEK",
- + (pANTLR3_UINT8) "MONTH",
- + (pANTLR3_UINT8) "YEAR",
- + (pANTLR3_UINT8) "QUOTE",
- + (pANTLR3_UINT8) "WS",
- + (pANTLR3_UINT8) "DIGIT19",
- + (pANTLR3_UINT8) "DIGIT09",
- + (pANTLR3_UINT8) "ESCAPED"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static pANTLR3_STRING query (pRSP2SQL ctx);
- +static RSP2SQL_expr_return expr (pRSP2SQL ctx);
- +static RSP2SQL_strcrit_return strcrit (pRSP2SQL ctx);
- +static pANTLR3_COMMON_TOKEN strop (pRSP2SQL ctx);
- +static RSP2SQL_intcrit_return intcrit (pRSP2SQL ctx);
- +static pANTLR3_COMMON_TOKEN intop (pRSP2SQL ctx);
- +static RSP2SQL_datecrit_return datecrit (pRSP2SQL ctx);
- +static pANTLR3_COMMON_TOKEN dateop (pRSP2SQL ctx);
- +static RSP2SQL_datespec_return datespec (pRSP2SQL ctx);
- +static RSP2SQL_dateref_return dateref (pRSP2SQL ctx);
- +static RSP2SQL_dateintval_return dateintval (pRSP2SQL ctx);
- +static void RSP2SQLFree(pRSP2SQL ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "RSP2SQL.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new RSP2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pRSP2SQL
- +RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return RSP2SQLNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new RSP2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pRSP2SQL
- +RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pRSP2SQL ctx; /* Context structure we will build and return */
- +
- + ctx = (pRSP2SQL) ANTLR3_CALLOC(1, sizeof(RSP2SQL));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in RSP2SQL.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base Tree parser/recognizer, using the supplied tree node stream
- + */
- + ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state);
- + /* Install the implementation of our RSP2SQL interface
- + */
- + ctx->query = query;
- + ctx->expr = expr;
- + ctx->strcrit = strcrit;
- + ctx->strop = strop;
- + ctx->intcrit = intcrit;
- + ctx->intop = intop;
- + ctx->datecrit = datecrit;
- + ctx->dateop = dateop;
- + ctx->datespec = datespec;
- + ctx->dateref = dateref;
- + ctx->dateintval = dateintval;
- + ctx->free = RSP2SQLFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- +
- +
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = RSP2SQLTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + RSP2SQLFree(pRSP2SQL ctx)
- + {
- + /* Free any scope memory
- + */
- +
- +
- + // Free this parser
- + //
- + ctx->pTreeParser->free(ctx->pTreeParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this tree parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return RSP2SQLTokenNames;
- +}
- +
- +
- + #define RSP_TYPE_STRING 0
- + #define RSP_TYPE_INT 1
- + #define RSP_TYPE_DATE 2
- +
- + struct rsp_query_field_map {
- + char *rsp_field;
- + int field_type;
- + /* RSP fields are named after the DB columns - or vice versa */
- + };
- +
- + /* gperf static hash, rsp_query.gperf */
- + #include "rsp_query_hash.c"
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_expr95 */
- +static ANTLR3_BITWORD FOLLOW_AND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_AND_in_expr95 = { FOLLOW_AND_in_expr95_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr118 */
- +static ANTLR3_BITWORD FOLLOW_OR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr118 = { FOLLOW_OR_in_expr118_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr144 */
- +static ANTLR3_BITWORD FOLLOW_strcrit_in_expr144_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr144 = { FOLLOW_strcrit_in_expr144_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr154 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_expr154_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr154 = { FOLLOW_NOT_in_expr154_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr160 */
- +static ANTLR3_BITWORD FOLLOW_strcrit_in_expr160_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr160 = { FOLLOW_strcrit_in_expr160_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr174 */
- +static ANTLR3_BITWORD FOLLOW_intcrit_in_expr174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr174 = { FOLLOW_intcrit_in_expr174_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr184 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_expr184_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr184 = { FOLLOW_NOT_in_expr184_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr190 */
- +static ANTLR3_BITWORD FOLLOW_intcrit_in_expr190_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr190 = { FOLLOW_intcrit_in_expr190_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_expr204 */
- +static ANTLR3_BITWORD FOLLOW_datecrit_in_expr204_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_expr204 = { FOLLOW_datecrit_in_expr204_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit233 */
- +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit233_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit233 = { FOLLOW_strop_in_strcrit233_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit239 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit239_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit239 = { FOLLOW_FIELD_in_strcrit239_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit245 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit245_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit245 = { FOLLOW_STR_in_strcrit245_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_strop274 */
- +static ANTLR3_BITWORD FOLLOW_EQUAL_in_strop274_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_strop274 = { FOLLOW_EQUAL_in_strop274_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_strop287 */
- +static ANTLR3_BITWORD FOLLOW_INCLUDES_in_strop287_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_strop287 = { FOLLOW_INCLUDES_in_strop287_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STARTSW_in_strop300 */
- +static ANTLR3_BITWORD FOLLOW_STARTSW_in_strop300_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STARTSW_in_strop300 = { FOLLOW_STARTSW_in_strop300_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENDSW_in_strop313 */
- +static ANTLR3_BITWORD FOLLOW_ENDSW_in_strop313_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENDSW_in_strop313 = { FOLLOW_ENDSW_in_strop313_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit342 */
- +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit342 = { FOLLOW_intop_in_intcrit342_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit348 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit348_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit348 = { FOLLOW_FIELD_in_intcrit348_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit354 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit354_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit354 = { FOLLOW_INT_in_intcrit354_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_intop383 */
- +static ANTLR3_BITWORD FOLLOW_EQUAL_in_intop383_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_intop383 = { FOLLOW_EQUAL_in_intop383_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LESS_in_intop396 */
- +static ANTLR3_BITWORD FOLLOW_LESS_in_intop396_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_LESS_in_intop396 = { FOLLOW_LESS_in_intop396_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GREATER_in_intop409 */
- +static ANTLR3_BITWORD FOLLOW_GREATER_in_intop409_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_GREATER_in_intop409 = { FOLLOW_GREATER_in_intop409_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LTE_in_intop422 */
- +static ANTLR3_BITWORD FOLLOW_LTE_in_intop422_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_LTE_in_intop422 = { FOLLOW_LTE_in_intop422_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GTE_in_intop435 */
- +static ANTLR3_BITWORD FOLLOW_GTE_in_intop435_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_GTE_in_intop435 = { FOLLOW_GTE_in_intop435_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit464 */
- +static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit464_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit464 = { FOLLOW_dateop_in_datecrit464_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit470 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit470_bits[] = { ANTLR3_UINT64_LIT(0x0000000001FEF860) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit470 = { FOLLOW_FIELD_in_datecrit470_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit476 */
- +static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit476 = { FOLLOW_datespec_in_datecrit476_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateop505 */
- +static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateop505_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateop505 = { FOLLOW_BEFORE_in_dateop505_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateop518 */
- +static ANTLR3_BITWORD FOLLOW_AFTER_in_dateop518_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateop518 = { FOLLOW_AFTER_in_dateop518_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec546 */
- +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec546_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec546 = { FOLLOW_dateref_in_datespec546_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec560 */
- +static ANTLR3_BITWORD FOLLOW_dateop_in_datespec560_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec560 = { FOLLOW_dateop_in_datespec560_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec566 */
- +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec566_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec566 = { FOLLOW_dateref_in_datespec566_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec572 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_datespec572_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec572 = { FOLLOW_INT_in_datespec572_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec578 */
- +static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec578_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec578 = { FOLLOW_dateintval_in_datespec578_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateref607 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateref607_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateref607 = { FOLLOW_DATE_in_dateref607_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_TODAY_in_dateref616 */
- +static ANTLR3_BITWORD FOLLOW_TODAY_in_dateref616_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_TODAY_in_dateref616 = { FOLLOW_TODAY_in_dateref616_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DAY_in_dateintval640 */
- +static ANTLR3_BITWORD FOLLOW_DAY_in_dateintval640_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DAY_in_dateintval640 = { FOLLOW_DAY_in_dateintval640_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_WEEK_in_dateintval649 */
- +static ANTLR3_BITWORD FOLLOW_WEEK_in_dateintval649_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_WEEK_in_dateintval649 = { FOLLOW_WEEK_in_dateintval649_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_MONTH_in_dateintval658 */
- +static ANTLR3_BITWORD FOLLOW_MONTH_in_dateintval658_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_MONTH_in_dateintval658 = { FOLLOW_MONTH_in_dateintval658_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_YEAR_in_dateintval667 */
- +static ANTLR3_BITWORD FOLLOW_YEAR_in_dateintval667_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_YEAR_in_dateintval667 = { FOLLOW_YEAR_in_dateintval667_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start query
- + * RSP2SQL.g:56:1: query returns [ pANTLR3_STRING result ] : e= expr ;
- + */
- +static pANTLR3_STRING
- +query(pRSP2SQL ctx)
- +{
- + pANTLR3_STRING result = NULL;
- +
- + RSP2SQL_expr_return e;
- + #undef RETURN_TYPE_e
- + #define RETURN_TYPE_e RSP2SQL_expr_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + result= NULL;
- + {
- + // RSP2SQL.g:58:2: (e= expr )
- + // RSP2SQL.g:58:4: e= expr
- + {
- + FOLLOWPUSH(FOLLOW_expr_in_query70);
- + e=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + {
- +
- + if (!e.valid)
- + {
- + result= NULL;
- + }
- + else
- + {
- + result= e.result->factory->newRaw(e.result->factory);
- + result->append8(result, "(");
- + result->appendS(result, e.result);
- + result->append8(result, ")");
- + }
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulequeryEx; /* Prevent compiler warnings */
- + rulequeryEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return result;
- +}
- +/* $ANTLR end query */
- +
- +/**
- + * $ANTLR start expr
- + * RSP2SQL.g:74:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit );
- + */
- +static RSP2SQL_expr_return
- +expr(pRSP2SQL ctx)
- +{
- + RSP2SQL_expr_return retval;
- +
- + RSP2SQL_expr_return a;
- + #undef RETURN_TYPE_a
- + #define RETURN_TYPE_a RSP2SQL_expr_return
- +
- + RSP2SQL_expr_return b;
- + #undef RETURN_TYPE_b
- + #define RETURN_TYPE_b RSP2SQL_expr_return
- +
- + RSP2SQL_strcrit_return c;
- + #undef RETURN_TYPE_c
- + #define RETURN_TYPE_c RSP2SQL_strcrit_return
- +
- + RSP2SQL_intcrit_return i;
- + #undef RETURN_TYPE_i
- + #define RETURN_TYPE_i RSP2SQL_intcrit_return
- +
- + RSP2SQL_datecrit_return d;
- + #undef RETURN_TYPE_d
- + #define RETURN_TYPE_d RSP2SQL_datecrit_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.result= NULL; retval.valid= 1;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + {
- + // RSP2SQL.g:76:2: ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit )
- +
- + ANTLR3_UINT32 alt1;
- +
- + alt1=7;
- +
- + switch ( LA(1) )
- + {
- + case AND:
- + {
- + alt1=1;
- + }
- + break;
- + case OR:
- + {
- + alt1=2;
- + }
- + break;
- + case EQUAL:
- + {
- + switch ( LA(2) )
- + {
- + case DOWN:
- + {
- + switch ( LA(3) )
- + {
- + case FIELD:
- + {
- + switch ( LA(4) )
- + {
- + case INT:
- + {
- + alt1=5;
- + }
- + break;
- + case STR:
- + {
- + alt1=3;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 10;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 8;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + {
- + alt1=3;
- + }
- + break;
- + case NOT:
- + {
- + switch ( LA(2) )
- + {
- + case DOWN:
- + {
- + switch ( LA(3) )
- + {
- + case EQUAL:
- + {
- + switch ( LA(4) )
- + {
- + case DOWN:
- + {
- + switch ( LA(5) )
- + {
- + case FIELD:
- + {
- + switch ( LA(6) )
- + {
- + case STR:
- + {
- + alt1=4;
- + }
- + break;
- + case INT:
- + {
- + alt1=6;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 15;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 14;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 11;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- + case LESS:
- + case GREATER:
- + case LTE:
- + case GTE:
- + {
- + alt1=6;
- + }
- + break;
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + {
- + alt1=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 9;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 5;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + }
- + break;
- + case LESS:
- + case GREATER:
- + case LTE:
- + case GTE:
- + {
- + alt1=5;
- + }
- + break;
- + case BEFORE:
- + case AFTER:
- + {
- + alt1=7;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleexprEx;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // RSP2SQL.g:76:4: ^( AND a= expr b= expr )
- + {
- + MATCHT(AND, &FOLLOW_AND_in_expr95);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr101);
- + a=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr107);
- + b=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (!a.valid || !b.valid)
- + {
- + retval.valid= 0;
- + }
- + else
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->append8(retval.result, "(");
- + retval.result->appendS(retval.result, a.result);
- + retval.result->append8(retval.result, " AND ");
- + retval.result->appendS(retval.result, b.result);
- + retval.result->append8(retval.result, ")");
- + }
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:92:4: ^( OR a= expr b= expr )
- + {
- + MATCHT(OR, &FOLLOW_OR_in_expr118);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr124);
- + a=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expr_in_expr130);
- + b=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (!a.valid || !b.valid)
- + {
- + retval.valid= 0;
- + }
- + else
- + {
- + retval.result= a.result->factory->newRaw(a.result->factory);
- + retval.result->append8(retval.result, "(");
- + retval.result->appendS(retval.result, a.result);
- + retval.result->append8(retval.result, " OR ");
- + retval.result->appendS(retval.result, b.result);
- + retval.result->append8(retval.result, ")");
- + }
- +
- + }
- +
- + }
- + break;
- + case 3:
- + // RSP2SQL.g:108:4: c= strcrit
- + {
- + FOLLOWPUSH(FOLLOW_strcrit_in_expr144);
- + c=strcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + retval.valid= c.valid;
- + retval.result= c.result;
- +
- + }
- +
- + }
- + break;
- + case 4:
- + // RSP2SQL.g:113:4: ^( NOT c= strcrit )
- + {
- + MATCHT(NOT, &FOLLOW_NOT_in_expr154);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_strcrit_in_expr160);
- + c=strcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (!c.valid)
- + {
- + retval.valid= 0;
- + }
- + else
- + {
- + retval.result= c.result->factory->newRaw(c.result->factory);
- + retval.result->append8(retval.result, "(NOT ");
- + retval.result->appendS(retval.result, c.result);
- + retval.result->append8(retval.result, ")");
- + }
- +
- + }
- +
- + }
- + break;
- + case 5:
- + // RSP2SQL.g:127:4: i= intcrit
- + {
- + FOLLOWPUSH(FOLLOW_intcrit_in_expr174);
- + i=intcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + retval.valid= i.valid;
- + retval.result= i.result;
- +
- + }
- +
- + }
- + break;
- + case 6:
- + // RSP2SQL.g:132:4: ^( NOT i= intcrit )
- + {
- + MATCHT(NOT, &FOLLOW_NOT_in_expr184);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_intcrit_in_expr190);
- + i=intcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + if (!i.valid)
- + {
- + retval.valid= 0;
- + }
- + else
- + {
- + retval.result= i.result->factory->newRaw(i.result->factory);
- + retval.result->append8(retval.result, "(NOT ");
- + retval.result->appendS(retval.result, i.result);
- + retval.result->append8(retval.result, ")");
- + }
- +
- + }
- +
- + }
- + break;
- + case 7:
- + // RSP2SQL.g:146:4: d= datecrit
- + {
- + FOLLOWPUSH(FOLLOW_datecrit_in_expr204);
- + d=datecrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + {
- +
- + retval.valid= d.valid;
- + retval.result= d.result;
- +
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexprEx; /* Prevent compiler warnings */
- + ruleexprEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end expr */
- +
- +/**
- + * $ANTLR start strcrit
- + * RSP2SQL.g:153:1: strcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= strop f= FIELD s= STR ) ;
- + */
- +static RSP2SQL_strcrit_return
- +strcrit(pRSP2SQL ctx)
- +{
- + RSP2SQL_strcrit_return retval;
- +
- + pANTLR3_BASE_TREE f;
- + pANTLR3_BASE_TREE s;
- + pANTLR3_COMMON_TOKEN o;
- + #undef RETURN_TYPE_o
- + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.result= NULL; retval.valid= 1;
- + f = NULL;
- + s = NULL;
- + o = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + // RSP2SQL.g:155:2: ( ^(o= strop f= FIELD s= STR ) )
- + // RSP2SQL.g:155:4: ^(o= strop f= FIELD s= STR )
- + {
- + FOLLOWPUSH(FOLLOW_strop_in_strcrit233);
- + o=strop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit239);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + s = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_strcrit245);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + {
- +
- + char *op;
- + const struct rsp_query_field_map *rqfp;
- + pANTLR3_STRING field;
- + char *escaped;
- + ANTLR3_UINT32 optok;
- +
- + escaped = NULL;
- +
- + op = NULL;
- + optok = o->getType(o);
- + switch (optok)
- + {
- + case EQUAL:
- + op = " = ";
- + break;
- +
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + op = " LIKE ";
- + break;
- + }
- +
- + field = f->getText(f);
- +
- + /* Field lookup */
- + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
- + if (!rqfp)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
- + retval.valid= 0;
- + goto strcrit_valid_0; /* ABORT */
- + }
- +
- + /* Check field type */
- + if (rqfp->field_type != RSP_TYPE_STRING)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a string field\n", field->chars);
- + retval.valid= 0;
- + goto strcrit_valid_0; /* ABORT */
- + }
- +
- + escaped = db_escape_string((char *)s->getText(s)->chars);
- + if (!escaped)
- + {
- + DPRINTF(E_LOG, L_RSP, "Could not escape value\n");
- + retval.valid= 0;
- + goto strcrit_valid_0; /* ABORT */
- + }
- +
- + retval.result= field->factory->newRaw(field->factory);
- + retval.result->append8(retval.result, "f.");
- + retval.result->appendS(retval.result, field);
- + retval.result->append8(retval.result, op);
- + retval.result->append8(retval.result, "'");
- + if ((optok == INCLUDES) || (optok == STARTSW))
- + retval.result->append8(retval.result, "%");
- +
- + retval.result->append8(retval.result, escaped);
- +
- + if ((optok == INCLUDES) || (optok == ENDSW))
- + retval.result->append8(retval.result, "%");
- + retval.result->append8(retval.result, "'");
- +
- + strcrit_valid_0:
- + ;
- +
- + if (escaped)
- + free(escaped);
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulestrcritEx; /* Prevent compiler warnings */
- + rulestrcritEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end strcrit */
- +
- +/**
- + * $ANTLR start strop
- + * RSP2SQL.g:229:1: strop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW );
- + */
- +static pANTLR3_COMMON_TOKEN
- +strop(pRSP2SQL ctx)
- +{
- + pANTLR3_COMMON_TOKEN op = NULL;
- +
- + pANTLR3_BASE_TREE n;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + op= NULL;
- + n = NULL;
- +
- + {
- + {
- + // RSP2SQL.g:231:2: (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW )
- +
- + ANTLR3_UINT32 alt2;
- +
- + alt2=4;
- +
- + switch ( LA(1) )
- + {
- + case EQUAL:
- + {
- + alt2=1;
- + }
- + break;
- + case INCLUDES:
- + {
- + alt2=2;
- + }
- + break;
- + case STARTSW:
- + {
- + alt2=3;
- + }
- + break;
- + case ENDSW:
- + {
- + alt2=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulestropEx;
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // RSP2SQL.g:231:4: n= EQUAL
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_strop274);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:233:4: n= INCLUDES
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_strop287);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 3:
- + // RSP2SQL.g:235:4: n= STARTSW
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(STARTSW, &FOLLOW_STARTSW_in_strop300);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 4:
- + // RSP2SQL.g:237:4: n= ENDSW
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(ENDSW, &FOLLOW_ENDSW_in_strop313);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulestropEx; /* Prevent compiler warnings */
- + rulestropEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return op;
- +}
- +/* $ANTLR end strop */
- +
- +/**
- + * $ANTLR start intcrit
- + * RSP2SQL.g:241:1: intcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= intop f= FIELD i= INT ) ;
- + */
- +static RSP2SQL_intcrit_return
- +intcrit(pRSP2SQL ctx)
- +{
- + RSP2SQL_intcrit_return retval;
- +
- + pANTLR3_BASE_TREE f;
- + pANTLR3_BASE_TREE i;
- + pANTLR3_COMMON_TOKEN o;
- + #undef RETURN_TYPE_o
- + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.result= NULL; retval.valid= 1;
- + f = NULL;
- + i = NULL;
- + o = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + // RSP2SQL.g:243:2: ( ^(o= intop f= FIELD i= INT ) )
- + // RSP2SQL.g:243:4: ^(o= intop f= FIELD i= INT )
- + {
- + FOLLOWPUSH(FOLLOW_intop_in_intcrit342);
- + o=intop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit348);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + i = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_intcrit354);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + {
- +
- + char *op;
- + const struct rsp_query_field_map *rqfp;
- + pANTLR3_STRING field;
- +
- + op = NULL;
- + switch (o->getType(o))
- + {
- + case EQUAL:
- + op = " = ";
- + break;
- +
- + case LESS:
- + op = " < ";
- + break;
- +
- + case GREATER:
- + op = " > ";
- + break;
- +
- + case LTE:
- + op = " <= ";
- + break;
- +
- + case GTE:
- + op = " >= ";
- + break;
- + }
- +
- + field = f->getText(f);
- +
- + /* Field lookup */
- + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
- + if (!rqfp)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
- + retval.valid= 0;
- + goto intcrit_valid_0; /* ABORT */
- + }
- +
- + /* Check field type */
- + if (rqfp->field_type != RSP_TYPE_INT)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not an integer field\n", field->chars);
- + retval.valid= 0;
- + goto intcrit_valid_0; /* ABORT */
- + }
- +
- + retval.result= field->factory->newRaw(field->factory);
- + retval.result->append8(retval.result, "f.");
- + retval.result->appendS(retval.result, field);
- + retval.result->append8(retval.result, op);
- + retval.result->appendS(retval.result, i->getText(i));
- +
- + intcrit_valid_0:
- + ;
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintcritEx; /* Prevent compiler warnings */
- + ruleintcritEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end intcrit */
- +
- +/**
- + * $ANTLR start intop
- + * RSP2SQL.g:303:1: intop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE );
- + */
- +static pANTLR3_COMMON_TOKEN
- +intop(pRSP2SQL ctx)
- +{
- + pANTLR3_COMMON_TOKEN op = NULL;
- +
- + pANTLR3_BASE_TREE n;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + op= NULL;
- + n = NULL;
- +
- + {
- + {
- + // RSP2SQL.g:305:2: (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE )
- +
- + ANTLR3_UINT32 alt3;
- +
- + alt3=5;
- +
- + switch ( LA(1) )
- + {
- + case EQUAL:
- + {
- + alt3=1;
- + }
- + break;
- + case LESS:
- + {
- + alt3=2;
- + }
- + break;
- + case GREATER:
- + {
- + alt3=3;
- + }
- + break;
- + case LTE:
- + {
- + alt3=4;
- + }
- + break;
- + case GTE:
- + {
- + alt3=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleintopEx;
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // RSP2SQL.g:305:4: n= EQUAL
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_intop383);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:307:4: n= LESS
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(LESS, &FOLLOW_LESS_in_intop396);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 3:
- + // RSP2SQL.g:309:4: n= GREATER
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(GREATER, &FOLLOW_GREATER_in_intop409);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 4:
- + // RSP2SQL.g:311:4: n= LTE
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(LTE, &FOLLOW_LTE_in_intop422);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 5:
- + // RSP2SQL.g:313:4: n= GTE
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(GTE, &FOLLOW_GTE_in_intop435);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintopEx; /* Prevent compiler warnings */
- + ruleintopEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return op;
- +}
- +/* $ANTLR end intop */
- +
- +/**
- + * $ANTLR start datecrit
- + * RSP2SQL.g:317:1: datecrit returns [ pANTLR3_STRING result, int valid ] : ^(o= dateop f= FIELD d= datespec ) ;
- + */
- +static RSP2SQL_datecrit_return
- +datecrit(pRSP2SQL ctx)
- +{
- + RSP2SQL_datecrit_return retval;
- +
- + pANTLR3_BASE_TREE f;
- + pANTLR3_COMMON_TOKEN o;
- + #undef RETURN_TYPE_o
- + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
- +
- + RSP2SQL_datespec_return d;
- + #undef RETURN_TYPE_d
- + #define RETURN_TYPE_d RSP2SQL_datespec_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.result= NULL; retval.valid= 1;
- + f = NULL;
- + o = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + // RSP2SQL.g:319:2: ( ^(o= dateop f= FIELD d= datespec ) )
- + // RSP2SQL.g:319:4: ^(o= dateop f= FIELD d= datespec )
- + {
- + FOLLOWPUSH(FOLLOW_dateop_in_datecrit464);
- + o=dateop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit470);
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_datespec_in_datecrit476);
- + d=datespec(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + {
- +
- + char *op;
- + const struct rsp_query_field_map *rqfp;
- + pANTLR3_STRING field;
- + char buf[32];
- + int ret;
- +
- + op = NULL;
- + switch (o->getType(o))
- + {
- + case BEFORE:
- + op = " < ";
- + break;
- +
- + case AFTER:
- + op = " > ";
- + break;
- + }
- +
- + field = f->getText(f);
- +
- + /* Field lookup */
- + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
- + if (!rqfp)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
- + retval.valid= 0;
- + goto datecrit_valid_0; /* ABORT */
- + }
- +
- + /* Check field type */
- + if (rqfp->field_type != RSP_TYPE_DATE)
- + {
- + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a date field\n", field->chars);
- + retval.valid= 0;
- + goto datecrit_valid_0; /* ABORT */
- + }
- +
- + ret = snprintf(buf, sizeof(buf), "%ld", d.date);
- + if ((ret < 0) || (ret >= sizeof(buf)))
- + {
- + DPRINTF(E_LOG, L_RSP, "Date %ld too large for buffer, oops!\n", d.date);
- + retval.valid= 0;
- + goto datecrit_valid_0; /* ABORT */
- + }
- +
- + retval.result= field->factory->newRaw(field->factory);
- + retval.result->append8(retval.result, "f.");
- + retval.result->appendS(retval.result, field);
- + retval.result->append8(retval.result, op);
- + retval.result->append8(retval.result, buf);
- +
- + datecrit_valid_0:
- + ;
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatecritEx; /* Prevent compiler warnings */
- + ruledatecritEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end datecrit */
- +
- +/**
- + * $ANTLR start dateop
- + * RSP2SQL.g:377:1: dateop returns [ pANTLR3_COMMON_TOKEN op ] : (n= BEFORE | n= AFTER );
- + */
- +static pANTLR3_COMMON_TOKEN
- +dateop(pRSP2SQL ctx)
- +{
- + pANTLR3_COMMON_TOKEN op = NULL;
- +
- + pANTLR3_BASE_TREE n;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + op= NULL;
- + n = NULL;
- +
- + {
- + {
- + // RSP2SQL.g:379:2: (n= BEFORE | n= AFTER )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=2;
- +
- + switch ( LA(1) )
- + {
- + case BEFORE:
- + {
- + alt4=1;
- + }
- + break;
- + case AFTER:
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledateopEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // RSP2SQL.g:379:4: n= BEFORE
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateop505);
- + if (HASEXCEPTION())
- + {
- + goto ruledateopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:381:4: n= AFTER
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(AFTER, &FOLLOW_AFTER_in_dateop518);
- + if (HASEXCEPTION())
- + {
- + goto ruledateopEx;
- + }
- +
- + {
- + op= n->getToken(n);
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledateopEx; /* Prevent compiler warnings */
- + ruledateopEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return op;
- +}
- +/* $ANTLR end dateop */
- +
- +/**
- + * $ANTLR start datespec
- + * RSP2SQL.g:385:1: datespec returns [ time_t date, int valid ] : (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) );
- + */
- +static RSP2SQL_datespec_return
- +datespec(pRSP2SQL ctx)
- +{
- + RSP2SQL_datespec_return retval;
- +
- + pANTLR3_BASE_TREE m;
- + RSP2SQL_dateref_return r;
- + #undef RETURN_TYPE_r
- + #define RETURN_TYPE_r RSP2SQL_dateref_return
- +
- + pANTLR3_COMMON_TOKEN o;
- + #undef RETURN_TYPE_o
- + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
- +
- + RSP2SQL_dateintval_return i;
- + #undef RETURN_TYPE_i
- + #define RETURN_TYPE_i RSP2SQL_dateintval_return
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.date= 0; retval.valid= 1;
- + m = NULL;
- + o = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + {
- + // RSP2SQL.g:387:2: (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) )
- +
- + ANTLR3_UINT32 alt5;
- +
- + alt5=2;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + case TODAY:
- + {
- + alt5=1;
- + }
- + break;
- + case BEFORE:
- + case AFTER:
- + {
- + alt5=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledatespecEx;
- + }
- +
- + switch (alt5)
- + {
- + case 1:
- + // RSP2SQL.g:387:4: r= dateref
- + {
- + FOLLOWPUSH(FOLLOW_dateref_in_datespec546);
- + r=dateref(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + {
- +
- + if (!r.valid)
- + retval.valid= 0;
- + else
- + retval.date= r.date;
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:394:4: ^(o= dateop r= dateref m= INT i= dateintval )
- + {
- + FOLLOWPUSH(FOLLOW_dateop_in_datespec560);
- + o=dateop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_dateref_in_datespec566);
- + r=dateref(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + m = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_datespec572);
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_dateintval_in_datespec578);
- + i=dateintval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + {
- +
- + int32_t val;
- + int ret;
- +
- + if (!r.valid || !i.valid)
- + {
- + retval.valid= 0;
- + goto datespec_valid_0; /* ABORT */
- + }
- +
- + ret = safe_atoi32((char *)m->getText(m)->chars, &val);
- + if (ret < 0)
- + {
- + DPRINTF(E_LOG, L_RSP, "Could not convert '%s' to integer\n", (char *)m->getText(m));
- + retval.valid= 0;
- + goto datespec_valid_0; /* ABORT */
- + }
- +
- + switch (o->getType(o))
- + {
- + case BEFORE:
- + retval.date= r.date - (val * i.period);
- + break;
- +
- + case AFTER:
- + retval.date= r.date + (val * i.period);
- + break;
- + }
- +
- + datespec_valid_0:
- + ;
- +
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatespecEx; /* Prevent compiler warnings */
- + ruledatespecEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end datespec */
- +
- +/**
- + * $ANTLR start dateref
- + * RSP2SQL.g:429:1: dateref returns [ time_t date, int valid ] : (n= DATE | TODAY );
- + */
- +static RSP2SQL_dateref_return
- +dateref(pRSP2SQL ctx)
- +{
- + RSP2SQL_dateref_return retval;
- +
- + pANTLR3_BASE_TREE n;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.date= 0; retval.valid= 1;
- + n = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + {
- + // RSP2SQL.g:431:2: (n= DATE | TODAY )
- +
- + ANTLR3_UINT32 alt6;
- +
- + alt6=2;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + {
- + alt6=1;
- + }
- + break;
- + case TODAY:
- + {
- + alt6=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 6;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledaterefEx;
- + }
- +
- + switch (alt6)
- + {
- + case 1:
- + // RSP2SQL.g:431:4: n= DATE
- + {
- + n = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateref607);
- + if (HASEXCEPTION())
- + {
- + goto ruledaterefEx;
- + }
- +
- + {
- +
- + struct tm tm;
- + char *ret;
- +
- + ret = strptime((char *)n->getText(n), "%Y-%m-%d", &tm);
- + if (!ret)
- + {
- + DPRINTF(E_LOG, L_RSP, "Date '%s' could not be interpreted\n", (char *)n->getText(n));
- + retval.valid= 0;
- + goto dateref_valid_0; /* ABORT */
- + }
- + else
- + {
- + if (*ret != '\0')
- + DPRINTF(E_LOG, L_RSP, "Garbage at end of date '%s' ?!\n", (char *)n->getText(n));
- +
- + retval.date= mktime(&tm);
- + if (retval.date == (time_t) -1)
- + {
- + DPRINTF(E_LOG, L_RSP, "Date '%s' could not be converted to an epoch\n", (char *)n->getText(n));
- + retval.valid= 0;
- + goto dateref_valid_0; /* ABORT */
- + }
- + }
- +
- + dateref_valid_0:
- + ;
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:460:4: TODAY
- + {
- + MATCHT(TODAY, &FOLLOW_TODAY_in_dateref616);
- + if (HASEXCEPTION())
- + {
- + goto ruledaterefEx;
- + }
- +
- + {
- + retval.date= time(NULL);
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledaterefEx; /* Prevent compiler warnings */
- + ruledaterefEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateref */
- +
- +/**
- + * $ANTLR start dateintval
- + * RSP2SQL.g:464:1: dateintval returns [ time_t period, int valid ] : ( DAY | WEEK | MONTH | YEAR );
- + */
- +static RSP2SQL_dateintval_return
- +dateintval(pRSP2SQL ctx)
- +{
- + RSP2SQL_dateintval_return retval;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.period= 0; retval.valid= 1;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + {
- + // RSP2SQL.g:466:2: ( DAY | WEEK | MONTH | YEAR )
- +
- + ANTLR3_UINT32 alt7;
- +
- + alt7=4;
- +
- + switch ( LA(1) )
- + {
- + case DAY:
- + {
- + alt7=1;
- + }
- + break;
- + case WEEK:
- + {
- + alt7=2;
- + }
- + break;
- + case MONTH:
- + {
- + alt7=3;
- + }
- + break;
- + case YEAR:
- + {
- + alt7=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 7;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledateintvalEx;
- + }
- +
- + switch (alt7)
- + {
- + case 1:
- + // RSP2SQL.g:466:4: DAY
- + {
- + MATCHT(DAY, &FOLLOW_DAY_in_dateintval640);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + {
- + retval.period= 24 * 60 * 60;
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP2SQL.g:468:4: WEEK
- + {
- + MATCHT(WEEK, &FOLLOW_WEEK_in_dateintval649);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + {
- + retval.period= 7 * 24 * 60 * 60;
- + }
- +
- + }
- + break;
- + case 3:
- + // RSP2SQL.g:470:4: MONTH
- + {
- + MATCHT(MONTH, &FOLLOW_MONTH_in_dateintval658);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + {
- + retval.period= 30 * 24 * 60 * 60;
- + }
- +
- + }
- + break;
- + case 4:
- + // RSP2SQL.g:472:4: YEAR
- + {
- + MATCHT(YEAR, &FOLLOW_YEAR_in_dateintval667);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + {
- + retval.period= 365 * 24 * 60 * 60;
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledateintvalEx; /* Prevent compiler warnings */
- + ruledateintvalEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateintval */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/RSP2SQL.h b/src/pregen/RSP2SQL.h
- new file mode 100644
- index 0000000..08ac7bb
- --- /dev/null
- +++ b/src/pregen/RSP2SQL.h
- @@ -0,0 +1,291 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP2SQL.g
- + * - On : 2016-01-01 12:23:43
- + * - for the tree parser : RSP2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The tree parser RSP2SQL has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pRSP2SQL, which is returned from a call to RSP2SQLNew().
- + *
- + * The methods in pRSP2SQL are as follows:
- + *
- + * - pANTLR3_STRING pRSP2SQL->query(pRSP2SQL)
- + * - RSP2SQL_expr_return pRSP2SQL->expr(pRSP2SQL)
- + * - RSP2SQL_strcrit_return pRSP2SQL->strcrit(pRSP2SQL)
- + * - pANTLR3_COMMON_TOKEN pRSP2SQL->strop(pRSP2SQL)
- + * - RSP2SQL_intcrit_return pRSP2SQL->intcrit(pRSP2SQL)
- + * - pANTLR3_COMMON_TOKEN pRSP2SQL->intop(pRSP2SQL)
- + * - RSP2SQL_datecrit_return pRSP2SQL->datecrit(pRSP2SQL)
- + * - pANTLR3_COMMON_TOKEN pRSP2SQL->dateop(pRSP2SQL)
- + * - RSP2SQL_datespec_return pRSP2SQL->datespec(pRSP2SQL)
- + * - RSP2SQL_dateref_return pRSP2SQL->dateref(pRSP2SQL)
- + * - RSP2SQL_dateintval_return pRSP2SQL->dateintval(pRSP2SQL)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _RSP2SQL_H
- +#define _RSP2SQL_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct RSP2SQL_Ctx_struct RSP2SQL, * pRSP2SQL;
- +
- +
- +
- + /* Needs #define _GNU_SOURCE for strptime() */
- +
- + #include <stdio.h>
- + #include <string.h>
- + #include <time.h>
- + #include <stdint.h>
- +
- + #include "logger.h"
- + #include "db.h"
- + #include "misc.h"
- + #include "rsp_query.h"
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct RSP2SQL_expr_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING result;
- + int valid;
- +}
- + RSP2SQL_expr_return;
- +
- +typedef struct RSP2SQL_strcrit_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING result;
- + int valid;
- +}
- + RSP2SQL_strcrit_return;
- +
- +typedef struct RSP2SQL_intcrit_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING result;
- + int valid;
- +}
- + RSP2SQL_intcrit_return;
- +
- +typedef struct RSP2SQL_datecrit_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING result;
- + int valid;
- +}
- + RSP2SQL_datecrit_return;
- +
- +typedef struct RSP2SQL_datespec_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + time_t date;
- + int valid;
- +}
- + RSP2SQL_datespec_return;
- +
- +typedef struct RSP2SQL_dateref_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + time_t date;
- + int valid;
- +}
- + RSP2SQL_dateref_return;
- +
- +typedef struct RSP2SQL_dateintval_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + time_t period;
- + int valid;
- +}
- + RSP2SQL_dateintval_return;
- +
- +
- +
- +/** Context tracking structure for RSP2SQL
- + */
- +struct RSP2SQL_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_TREE_PARSER pTreeParser;
- +
- +
- + pANTLR3_STRING (*query) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_expr_return (*expr) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_strcrit_return (*strcrit) (struct RSP2SQL_Ctx_struct * ctx);
- + pANTLR3_COMMON_TOKEN (*strop) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_intcrit_return (*intcrit) (struct RSP2SQL_Ctx_struct * ctx);
- + pANTLR3_COMMON_TOKEN (*intop) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_datecrit_return (*datecrit) (struct RSP2SQL_Ctx_struct * ctx);
- + pANTLR3_COMMON_TOKEN (*dateop) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_datespec_return (*datespec) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_dateref_return (*dateref) (struct RSP2SQL_Ctx_struct * ctx);
- + RSP2SQL_dateintval_return (*dateintval) (struct RSP2SQL_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct RSP2SQL_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pRSP2SQL RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
- +ANTLR3_API pRSP2SQL RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the tree parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STARTSW 14
- +#define WEEK 26
- +#define TODAY 24
- +#define YEAR 28
- +#define ENDSW 15
- +#define GTE 20
- +#define BEFORE 21
- +#define DAY 25
- +#define INT 16
- +#define NOT 11
- +#define AFTER 22
- +#define AND 6
- +#define EOF -1
- +#define LTE 19
- +#define MONTH 27
- +#define DIGIT19 31
- +#define INCLUDES 13
- +#define STR 10
- +#define QUOTE 29
- +#define GREATER 18
- +#define WS 30
- +#define LPAR 7
- +#define NEWLINE 4
- +#define EQUAL 12
- +#define OR 5
- +#define LESS 17
- +#define FIELD 9
- +#define RPAR 8
- +#define ESCAPED 33
- +#define DATE 23
- +#define DIGIT09 32
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for RSP2SQL
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/RSP2SQL.u b/src/pregen/RSP2SQL.u
- new file mode 100644
- index 0000000..53d8cda
- --- /dev/null
- +++ b/src/pregen/RSP2SQL.u
- @@ -0,0 +1,5 @@
- +RSP2SQL.g: RSP.tokens
- +RSP2SQL.c : RSP2SQL.g
- +./RSP2SQL.tokens : RSP2SQL.g
- +RSP2SQL.h : RSP2SQL.g
- +ANTLR_PRODUCTS += RSP2SQL.c ./RSP2SQL.tokens RSP2SQL.h
- \ No newline at end of file
- diff --git a/src/pregen/RSPLexer.c b/src/pregen/RSPLexer.c
- new file mode 100644
- index 0000000..2e3faae
- --- /dev/null
- +++ b/src/pregen/RSPLexer.c
- @@ -0,0 +1,4867 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP.g
- + * - On : 2016-01-01 12:23:42
- + * - for the lexer : RSPLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "RSPLexer.h"
- +/* ----------------------------------------- */
- +
- +
- +/** String literals used by RSPLexer that we must do things like MATCHS() with.
- + * C will normally just lay down 8 bit characters, and you can use L"xxx" to
- + * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so
- + * we perform this little trick of defining the literals as arrays of UINT32
- + * and passing in the address of these.
- + */
- +static ANTLR3_UCHAR lit_1[] = { 0x61, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_2[] = { 0x6F, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_3[] = { 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_4[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_5[] = { 0x65, 0x6E, 0x64, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_6[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_7[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_8[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_9[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_10[] = { 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_11[] = { 0x64, 0x61, 0x79, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_12[] = { 0x77, 0x65, 0x65, 0x6B, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_13[] = { 0x77, 0x65, 0x65, 0x6B, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_14[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_15[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_16[] = { 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_17[] = { 0x79, 0x65, 0x61, 0x72, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_18[] = { 0x74, 0x6F, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pRSPLexer_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pRSPLexer_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pRSPLexer_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pRSPLexer_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +
- +/* Macros for accessing things in a lexer
- + */
- +#undef LEXER
- +#undef RECOGNIZER
- +#undef RULEMEMO
- +#undef GETCHARINDEX
- +#undef GETLINE
- +#undef GETCHARPOSITIONINLINE
- +#undef EMIT
- +#undef EMITNEW
- +#undef MATCHC
- +#undef MATCHS
- +#undef MATCHRANGE
- +#undef LTOKEN
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef INPUT
- +#undef STRSTREAM
- +#undef LA
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef LRECOVER
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef BACKTRACKING
- +#undef MATCHANY
- +#undef MEMOIZE
- +#undef HAVEPARSEDRULE
- +#undef GETTEXT
- +#undef INDEX
- +#undef SEEK
- +#undef PUSHSTREAM
- +#undef POPSTREAM
- +#undef SETTEXT
- +#undef SETTEXT8
- +
- +#define LEXER ctx->pLexer
- +#define RECOGNIZER LEXER->rec
- +#define LEXSTATE RECOGNIZER->state
- +#define TOKSOURCE LEXSTATE->tokSource
- +#define GETCHARINDEX() LEXER->getCharIndex(LEXER)
- +#define GETLINE() LEXER->getLine(LEXER)
- +#define GETTEXT() LEXER->getText(LEXER)
- +#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
- +#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)
- +#define EMITNEW(t) LEXER->emitNew(LEXER, t)
- +#define MATCHC(c) LEXER->matchc(LEXER, c)
- +#define MATCHS(s) LEXER->matchs(LEXER, s)
- +#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)
- +#define MATCHANY() LEXER->matchAny(LEXER)
- +#define LTOKEN LEXSTATE->token
- +#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)
- +#define BACKTRACKING LEXSTATE->backtracking
- +#define FAILEDFLAG LEXSTATE->failed
- +#define INPUT LEXER->input
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)
- +#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION LEXSTATE->exception
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define LRECOVER() LEXER->recover(LEXER)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)
- +#define POPSTREAM() LEXER->popCharStream(LEXER)
- +#define SETTEXT(str) LEXSTATE->text = str
- +#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)
- +#define USER1 LEXSTATE->user1
- +#define USER2 LEXSTATE->user2
- +#define USER3 LEXSTATE->user3
- +#define CUSTOM LEXSTATE->custom
- +#define RULEMEMO LEXSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +/* If we have been told we can rely on the standard 8 bit or 16 bit input
- + * stream, then we can define our macros to use the direct pointers
- + * in the input object, which is much faster than indirect calls. This
- + * is really only significant to lexers with a lot of fragment rules (which
- + * do not place LA(1) in a temporary at the moment) and even then
- + * only if there is a lot of input (order of say 1M or so).
- + */
- +#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
- +
- +# ifdef ANTLR3_INLINE_INPUT_ASCII
- +
- +/* 8 bit "ASCII" (actually any 8 bit character set) */
- +
- +# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT8)(INPUT->data))
- +
- +# else
- +
- +# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT16)(INPUT->data))
- +
- +# endif
- +
- +# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
- +# define CONSUME() \
- +{ \
- + if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \
- + { \
- + INPUT->charPositionInLine++; \
- + if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \
- + { \
- + INPUT->line++; \
- + INPUT->charPositionInLine = 0; \
- + INPUT->currentLine = (void *)(NEXTCHAR + 1); \
- + } \
- + INPUT->nextChar = (void *)(NEXTCHAR + 1); \
- + } \
- +}
- +
- +#else
- +
- +// Pick up the input character by calling the input stream implementation.
- +//
- +#define CONSUME() INPUT->istream->consume(INPUT->istream)
- +#define LA(n) INPUT->istream->_LA(INPUT->istream, n)
- +
- +#endif
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +/* Forward declare the locally static matching functions we have generated and any predicate functions.
- + */
- +static ANTLR3_INLINE void mQUOTE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mLPAR (pRSPLexer ctx);
- +static ANTLR3_INLINE void mRPAR (pRSPLexer ctx);
- +static ANTLR3_INLINE void mAND (pRSPLexer ctx);
- +static ANTLR3_INLINE void mOR (pRSPLexer ctx);
- +static ANTLR3_INLINE void mNOT (pRSPLexer ctx);
- +static ANTLR3_INLINE void mEQUAL (pRSPLexer ctx);
- +static ANTLR3_INLINE void mINCLUDES (pRSPLexer ctx);
- +static ANTLR3_INLINE void mSTARTSW (pRSPLexer ctx);
- +static ANTLR3_INLINE void mENDSW (pRSPLexer ctx);
- +static ANTLR3_INLINE void mGREATER (pRSPLexer ctx);
- +static ANTLR3_INLINE void mLESS (pRSPLexer ctx);
- +static ANTLR3_INLINE void mGTE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mLTE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mBEFORE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mAFTER (pRSPLexer ctx);
- +static ANTLR3_INLINE void mDAY (pRSPLexer ctx);
- +static ANTLR3_INLINE void mWEEK (pRSPLexer ctx);
- +static ANTLR3_INLINE void mMONTH (pRSPLexer ctx);
- +static ANTLR3_INLINE void mYEAR (pRSPLexer ctx);
- +static ANTLR3_INLINE void mTODAY (pRSPLexer ctx);
- +static ANTLR3_INLINE void mNEWLINE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mWS (pRSPLexer ctx);
- +static ANTLR3_INLINE void mFIELD (pRSPLexer ctx);
- +static ANTLR3_INLINE void mINT (pRSPLexer ctx);
- +static ANTLR3_INLINE void mDATE (pRSPLexer ctx);
- +static ANTLR3_INLINE void mSTR (pRSPLexer ctx);
- +static ANTLR3_INLINE void mESCAPED (pRSPLexer ctx);
- +static ANTLR3_INLINE void mDIGIT09 (pRSPLexer ctx);
- +static ANTLR3_INLINE void mDIGIT19 (pRSPLexer ctx);
- +static ANTLR3_INLINE void mTokens (pRSPLexer ctx);
- +static void RSPLexerFree(pRSPLexer ctx);
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +
- +
- +
- +static void
- +RSPLexerFree (pRSPLexer ctx)
- +{
- + LEXER->free(LEXER);
- +
- + ANTLR3_FREE(ctx);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "RSP.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +
- +/** \brief Create a new lexer called RSPLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \return
- + * - Success pRSPLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pRSPLexer RSPLexerNew
- +(pANTLR3_INPUT_STREAM instream)
- +{
- + // See if we can create a new lexer with the standard constructor
- + //
- + return RSPLexerNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new lexer called RSPLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \param[state] state Previously created shared recognizer stat
- + * \return
- + * - Success pRSPLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pRSPLexer RSPLexerNewSSD
- +(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pRSPLexer ctx; // Context structure we will build and return
- +
- + ctx = (pRSPLexer) ANTLR3_CALLOC(1, sizeof(RSPLexer));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for lexer context
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * in base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 lexer function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in RSPLexer.h here so you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base lexer, using the supplied input stream
- + */
- + ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
- +
- + /* Check that we allocated the memory correctly
- + */
- + if (ctx->pLexer == NULL)
- + {
- + ANTLR3_FREE(ctx);
- + return NULL;
- + }
- + /* Install the implementation of our RSPLexer interface
- + */
- + ctx->mQUOTE = mQUOTE;
- + ctx->mLPAR = mLPAR;
- + ctx->mRPAR = mRPAR;
- + ctx->mAND = mAND;
- + ctx->mOR = mOR;
- + ctx->mNOT = mNOT;
- + ctx->mEQUAL = mEQUAL;
- + ctx->mINCLUDES = mINCLUDES;
- + ctx->mSTARTSW = mSTARTSW;
- + ctx->mENDSW = mENDSW;
- + ctx->mGREATER = mGREATER;
- + ctx->mLESS = mLESS;
- + ctx->mGTE = mGTE;
- + ctx->mLTE = mLTE;
- + ctx->mBEFORE = mBEFORE;
- + ctx->mAFTER = mAFTER;
- + ctx->mDAY = mDAY;
- + ctx->mWEEK = mWEEK;
- + ctx->mMONTH = mMONTH;
- + ctx->mYEAR = mYEAR;
- + ctx->mTODAY = mTODAY;
- + ctx->mNEWLINE = mNEWLINE;
- + ctx->mWS = mWS;
- + ctx->mFIELD = mFIELD;
- + ctx->mINT = mINT;
- + ctx->mDATE = mDATE;
- + ctx->mSTR = mSTR;
- + ctx->mESCAPED = mESCAPED;
- + ctx->mDIGIT09 = mDIGIT09;
- + ctx->mDIGIT19 = mDIGIT19;
- + ctx->mTokens = mTokens;
- +
- + /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
- + * it will call mTokens() in this generated code, and will pass it the ctx
- + * pointer of this lexer, not the context of the base lexer, so store that now.
- + */
- + ctx->pLexer->ctx = ctx;
- +
- + /**Install the token matching function
- + */
- + ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
- +
- + ctx->getGrammarFileName = getGrammarFileName;
- + ctx->free = RSPLexerFree;
- +
- +
- +
- +
- +
- + /* Return the newly built lexer to the caller
- + */
- + return ctx;
- +}
- +
- +
- +/* =========================================================================
- + * Functions to match the lexer grammar defined tokens from the input stream
- + */
- +
- +// Comes from: 85:7: ( '\"' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start QUOTE
- + *
- + * Looks to match the characters the constitute the token QUOTE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mQUOTE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = QUOTE;
- +
- +
- + // RSP.g:85:7: ( '\"' )
- + // RSP.g:85:9: '\"'
- + {
- + MATCHC('"');
- + if (HASEXCEPTION())
- + {
- + goto ruleQUOTEEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleQUOTEEx; /* Prevent compiler warnings */
- + ruleQUOTEEx: ;
- +
- +}
- +// $ANTLR end QUOTE
- +
- +// Comes from: 86:6: ( '(' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LPAR
- + *
- + * Looks to match the characters the constitute the token LPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLPAR(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = LPAR;
- +
- +
- + // RSP.g:86:6: ( '(' )
- + // RSP.g:86:8: '('
- + {
- + MATCHC('(');
- + if (HASEXCEPTION())
- + {
- + goto ruleLPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLPAREx; /* Prevent compiler warnings */
- + ruleLPAREx: ;
- +
- +}
- +// $ANTLR end LPAR
- +
- +// Comes from: 87:6: ( ')' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start RPAR
- + *
- + * Looks to match the characters the constitute the token RPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mRPAR(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = RPAR;
- +
- +
- + // RSP.g:87:6: ( ')' )
- + // RSP.g:87:8: ')'
- + {
- + MATCHC(')');
- + if (HASEXCEPTION())
- + {
- + goto ruleRPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleRPAREx; /* Prevent compiler warnings */
- + ruleRPAREx: ;
- +
- +}
- +// $ANTLR end RPAR
- +
- +// Comes from: 89:5: ( 'and' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start AND
- + *
- + * Looks to match the characters the constitute the token AND
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mAND(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = AND;
- +
- +
- + // RSP.g:89:5: ( 'and' )
- + // RSP.g:89:7: 'and'
- + {
- + MATCHS(lit_1);
- + if (HASEXCEPTION())
- + {
- + goto ruleANDEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleANDEx; /* Prevent compiler warnings */
- + ruleANDEx: ;
- +
- +}
- +// $ANTLR end AND
- +
- +// Comes from: 90:4: ( 'or' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start OR
- + *
- + * Looks to match the characters the constitute the token OR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mOR(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = OR;
- +
- +
- + // RSP.g:90:4: ( 'or' )
- + // RSP.g:90:6: 'or'
- + {
- + MATCHS(lit_2);
- + if (HASEXCEPTION())
- + {
- + goto ruleOREx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleOREx; /* Prevent compiler warnings */
- + ruleOREx: ;
- +
- +}
- +// $ANTLR end OR
- +
- +// Comes from: 91:5: ( '!' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start NOT
- + *
- + * Looks to match the characters the constitute the token NOT
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mNOT(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = NOT;
- +
- +
- + // RSP.g:91:5: ( '!' )
- + // RSP.g:91:7: '!'
- + {
- + MATCHC('!');
- + if (HASEXCEPTION())
- + {
- + goto ruleNOTEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleNOTEx; /* Prevent compiler warnings */
- + ruleNOTEx: ;
- +
- +}
- +// $ANTLR end NOT
- +
- +// Comes from: 94:7: ( '=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start EQUAL
- + *
- + * Looks to match the characters the constitute the token EQUAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mEQUAL(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = EQUAL;
- +
- +
- + // RSP.g:94:7: ( '=' )
- + // RSP.g:94:9: '='
- + {
- + MATCHC('=');
- + if (HASEXCEPTION())
- + {
- + goto ruleEQUALEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleEQUALEx; /* Prevent compiler warnings */
- + ruleEQUALEx: ;
- +
- +}
- +// $ANTLR end EQUAL
- +
- +// Comes from: 97:9: ( 'includes' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INCLUDES
- + *
- + * Looks to match the characters the constitute the token INCLUDES
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINCLUDES(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INCLUDES;
- +
- +
- + // RSP.g:97:9: ( 'includes' )
- + // RSP.g:97:11: 'includes'
- + {
- + MATCHS(lit_3);
- + if (HASEXCEPTION())
- + {
- + goto ruleINCLUDESEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINCLUDESEx; /* Prevent compiler warnings */
- + ruleINCLUDESEx: ;
- +
- +}
- +// $ANTLR end INCLUDES
- +
- +// Comes from: 98:9: ( 'startswith' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start STARTSW
- + *
- + * Looks to match the characters the constitute the token STARTSW
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mSTARTSW(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = STARTSW;
- +
- +
- + // RSP.g:98:9: ( 'startswith' )
- + // RSP.g:98:11: 'startswith'
- + {
- + MATCHS(lit_4);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTARTSWEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleSTARTSWEx; /* Prevent compiler warnings */
- + ruleSTARTSWEx: ;
- +
- +}
- +// $ANTLR end STARTSW
- +
- +// Comes from: 99:7: ( 'endswith' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start ENDSW
- + *
- + * Looks to match the characters the constitute the token ENDSW
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mENDSW(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = ENDSW;
- +
- +
- + // RSP.g:99:7: ( 'endswith' )
- + // RSP.g:99:9: 'endswith'
- + {
- + MATCHS(lit_5);
- + if (HASEXCEPTION())
- + {
- + goto ruleENDSWEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleENDSWEx; /* Prevent compiler warnings */
- + ruleENDSWEx: ;
- +
- +}
- +// $ANTLR end ENDSW
- +
- +// Comes from: 102:9: ( '>' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start GREATER
- + *
- + * Looks to match the characters the constitute the token GREATER
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mGREATER(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = GREATER;
- +
- +
- + // RSP.g:102:9: ( '>' )
- + // RSP.g:102:11: '>'
- + {
- + MATCHC('>');
- + if (HASEXCEPTION())
- + {
- + goto ruleGREATEREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleGREATEREx; /* Prevent compiler warnings */
- + ruleGREATEREx: ;
- +
- +}
- +// $ANTLR end GREATER
- +
- +// Comes from: 103:6: ( '<' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LESS
- + *
- + * Looks to match the characters the constitute the token LESS
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLESS(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = LESS;
- +
- +
- + // RSP.g:103:6: ( '<' )
- + // RSP.g:103:8: '<'
- + {
- + MATCHC('<');
- + if (HASEXCEPTION())
- + {
- + goto ruleLESSEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLESSEx; /* Prevent compiler warnings */
- + ruleLESSEx: ;
- +
- +}
- +// $ANTLR end LESS
- +
- +// Comes from: 104:5: ( '>=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start GTE
- + *
- + * Looks to match the characters the constitute the token GTE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mGTE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = GTE;
- +
- +
- + // RSP.g:104:5: ( '>=' )
- + // RSP.g:104:7: '>='
- + {
- + MATCHS(lit_6);
- + if (HASEXCEPTION())
- + {
- + goto ruleGTEEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleGTEEx; /* Prevent compiler warnings */
- + ruleGTEEx: ;
- +
- +}
- +// $ANTLR end GTE
- +
- +// Comes from: 105:5: ( '<=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LTE
- + *
- + * Looks to match the characters the constitute the token LTE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLTE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = LTE;
- +
- +
- + // RSP.g:105:5: ( '<=' )
- + // RSP.g:105:7: '<='
- + {
- + MATCHS(lit_7);
- + if (HASEXCEPTION())
- + {
- + goto ruleLTEEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLTEEx; /* Prevent compiler warnings */
- + ruleLTEEx: ;
- +
- +}
- +// $ANTLR end LTE
- +
- +// Comes from: 108:8: ( 'before' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start BEFORE
- + *
- + * Looks to match the characters the constitute the token BEFORE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mBEFORE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = BEFORE;
- +
- +
- + // RSP.g:108:8: ( 'before' )
- + // RSP.g:108:10: 'before'
- + {
- + MATCHS(lit_8);
- + if (HASEXCEPTION())
- + {
- + goto ruleBEFOREEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleBEFOREEx; /* Prevent compiler warnings */
- + ruleBEFOREEx: ;
- +
- +}
- +// $ANTLR end BEFORE
- +
- +// Comes from: 109:7: ( 'after' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start AFTER
- + *
- + * Looks to match the characters the constitute the token AFTER
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mAFTER(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = AFTER;
- +
- +
- + // RSP.g:109:7: ( 'after' )
- + // RSP.g:109:9: 'after'
- + {
- + MATCHS(lit_9);
- + if (HASEXCEPTION())
- + {
- + goto ruleAFTEREx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleAFTEREx; /* Prevent compiler warnings */
- + ruleAFTEREx: ;
- +
- +}
- +// $ANTLR end AFTER
- +
- +// Comes from: 110:5: ( 'day' | 'days' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DAY
- + *
- + * Looks to match the characters the constitute the token DAY
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDAY(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = DAY;
- +
- +
- + {
- + // RSP.g:110:5: ( 'day' | 'days' )
- +
- + ANTLR3_UINT32 alt1;
- +
- + alt1=2;
- +
- + switch ( LA(1) )
- + {
- + case 'd':
- + {
- + switch ( LA(2) )
- + {
- + case 'a':
- + {
- + switch ( LA(3) )
- + {
- + case 'y':
- + {
- + switch ( LA(4) )
- + {
- + case 's':
- + {
- + alt1=2;
- + }
- + break;
- +
- + default:
- + alt1=1;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleDAYEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleDAYEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDAYEx;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // RSP.g:110:7: 'day'
- + {
- + MATCHS(lit_10);
- + if (HASEXCEPTION())
- + {
- + goto ruleDAYEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:110:15: 'days'
- + {
- + MATCHS(lit_11);
- + if (HASEXCEPTION())
- + {
- + goto ruleDAYEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDAYEx; /* Prevent compiler warnings */
- + ruleDAYEx: ;
- +
- +}
- +// $ANTLR end DAY
- +
- +// Comes from: 111:6: ( 'week' | 'weeks' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start WEEK
- + *
- + * Looks to match the characters the constitute the token WEEK
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mWEEK(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = WEEK;
- +
- +
- + {
- + // RSP.g:111:6: ( 'week' | 'weeks' )
- +
- + ANTLR3_UINT32 alt2;
- +
- + alt2=2;
- +
- + switch ( LA(1) )
- + {
- + case 'w':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'e':
- + {
- + switch ( LA(4) )
- + {
- + case 'k':
- + {
- + switch ( LA(5) )
- + {
- + case 's':
- + {
- + alt2=2;
- + }
- + break;
- +
- + default:
- + alt2=1;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleWEEKEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleWEEKEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleWEEKEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleWEEKEx;
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // RSP.g:111:8: 'week'
- + {
- + MATCHS(lit_12);
- + if (HASEXCEPTION())
- + {
- + goto ruleWEEKEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:111:17: 'weeks'
- + {
- + MATCHS(lit_13);
- + if (HASEXCEPTION())
- + {
- + goto ruleWEEKEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleWEEKEx; /* Prevent compiler warnings */
- + ruleWEEKEx: ;
- +
- +}
- +// $ANTLR end WEEK
- +
- +// Comes from: 112:7: ( 'month' | 'months' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start MONTH
- + *
- + * Looks to match the characters the constitute the token MONTH
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mMONTH(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = MONTH;
- +
- +
- + {
- + // RSP.g:112:7: ( 'month' | 'months' )
- +
- + ANTLR3_UINT32 alt3;
- +
- + alt3=2;
- +
- + switch ( LA(1) )
- + {
- + case 'm':
- + {
- + switch ( LA(2) )
- + {
- + case 'o':
- + {
- + switch ( LA(3) )
- + {
- + case 'n':
- + {
- + switch ( LA(4) )
- + {
- + case 't':
- + {
- + switch ( LA(5) )
- + {
- + case 'h':
- + {
- + switch ( LA(6) )
- + {
- + case 's':
- + {
- + alt3=2;
- + }
- + break;
- +
- + default:
- + alt3=1;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleMONTHEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleMONTHEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleMONTHEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleMONTHEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleMONTHEx;
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // RSP.g:112:9: 'month'
- + {
- + MATCHS(lit_14);
- + if (HASEXCEPTION())
- + {
- + goto ruleMONTHEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:112:19: 'months'
- + {
- + MATCHS(lit_15);
- + if (HASEXCEPTION())
- + {
- + goto ruleMONTHEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleMONTHEx; /* Prevent compiler warnings */
- + ruleMONTHEx: ;
- +
- +}
- +// $ANTLR end MONTH
- +
- +// Comes from: 113:6: ( 'year' | 'years' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start YEAR
- + *
- + * Looks to match the characters the constitute the token YEAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mYEAR(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = YEAR;
- +
- +
- + {
- + // RSP.g:113:6: ( 'year' | 'years' )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=2;
- +
- + switch ( LA(1) )
- + {
- + case 'y':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'a':
- + {
- + switch ( LA(4) )
- + {
- + case 'r':
- + {
- + switch ( LA(5) )
- + {
- + case 's':
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + alt4=1;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleYEAREx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleYEAREx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleYEAREx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleYEAREx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // RSP.g:113:8: 'year'
- + {
- + MATCHS(lit_16);
- + if (HASEXCEPTION())
- + {
- + goto ruleYEAREx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:113:17: 'years'
- + {
- + MATCHS(lit_17);
- + if (HASEXCEPTION())
- + {
- + goto ruleYEAREx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleYEAREx; /* Prevent compiler warnings */
- + ruleYEAREx: ;
- +
- +}
- +// $ANTLR end YEAR
- +
- +// Comes from: 114:7: ( 'today' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start TODAY
- + *
- + * Looks to match the characters the constitute the token TODAY
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mTODAY(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = TODAY;
- +
- +
- + // RSP.g:114:7: ( 'today' )
- + // RSP.g:114:9: 'today'
- + {
- + MATCHS(lit_18);
- + if (HASEXCEPTION())
- + {
- + goto ruleTODAYEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleTODAYEx; /* Prevent compiler warnings */
- + ruleTODAYEx: ;
- +
- +}
- +// $ANTLR end TODAY
- +
- +// Comes from: 116:9: ( ( '\\r' )? '\\n' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start NEWLINE
- + *
- + * Looks to match the characters the constitute the token NEWLINE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mNEWLINE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = NEWLINE;
- +
- +
- + // RSP.g:116:9: ( ( '\\r' )? '\\n' )
- + // RSP.g:116:11: ( '\\r' )? '\\n'
- + {
- +
- + // RSP.g:116:11: ( '\\r' )?
- + {
- + int alt5=2;
- + switch ( LA(1) )
- + {
- + case '\r':
- + {
- + alt5=1;
- + }
- + break;
- + }
- +
- + switch (alt5)
- + {
- + case 1:
- + // RSP.g:116:11: '\\r'
- + {
- + MATCHC('\r');
- + if (HASEXCEPTION())
- + {
- + goto ruleNEWLINEEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- + MATCHC('\n');
- + if (HASEXCEPTION())
- + {
- + goto ruleNEWLINEEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleNEWLINEEx; /* Prevent compiler warnings */
- + ruleNEWLINEEx: ;
- +
- +}
- +// $ANTLR end NEWLINE
- +
- +// Comes from: 118:4: ( ( ' ' | '\\t' ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start WS
- + *
- + * Looks to match the characters the constitute the token WS
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mWS(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = WS;
- +
- +
- + // RSP.g:118:4: ( ( ' ' | '\\t' ) )
- + // RSP.g:118:6: ( ' ' | '\\t' )
- + {
- + if ( LA(1) == '\t' || LA(1) == ' ' )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleWSEx;
- + }
- +
- + {
- + LEXSTATE->channel = HIDDEN;
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleWSEx; /* Prevent compiler warnings */
- + ruleWSEx: ;
- +
- +}
- +// $ANTLR end WS
- +
- +// Comes from: 120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start FIELD
- + *
- + * Looks to match the characters the constitute the token FIELD
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mFIELD(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = FIELD;
- +
- +
- + // RSP.g:120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' )
- + // RSP.g:120:9: 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z'
- + {
- + MATCHRANGE('a', 'z');
- + if (HASEXCEPTION())
- + {
- + goto ruleFIELDEx;
- + }
- +
- +
- + // RSP.g:120:18: ( 'a' .. 'z' | '_' )*
- +
- + for (;;)
- + {
- + int alt6=2;
- + switch ( LA(1) )
- + {
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + switch ( LA(2) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt6=1;
- + }
- + break;
- +
- + }
- +
- + }
- + break;
- + case '_':
- + {
- + alt6=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt6)
- + {
- + case 1:
- + // RSP.g:
- + {
- + if ( LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleFIELDEx;
- + }
- +
- +
- + }
- + break;
- +
- + default:
- + goto loop6; /* break out of the loop */
- + break;
- + }
- + }
- + loop6: ; /* Jump out to here if this rule does not match */
- +
- + MATCHRANGE('a', 'z');
- + if (HASEXCEPTION())
- + {
- + goto ruleFIELDEx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleFIELDEx; /* Prevent compiler warnings */
- + ruleFIELDEx: ;
- +
- +}
- +// $ANTLR end FIELD
- +
- +// Comes from: 122:5: ( DIGIT19 ( DIGIT09 )* )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INT
- + *
- + * Looks to match the characters the constitute the token INT
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINT(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INT;
- +
- +
- + // RSP.g:122:5: ( DIGIT19 ( DIGIT09 )* )
- + // RSP.g:122:7: DIGIT19 ( DIGIT09 )*
- + {
- + /* 122:7: DIGIT19 ( DIGIT09 )* */
- + mDIGIT19(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTEx;
- + }
- +
- +
- + // RSP.g:122:15: ( DIGIT09 )*
- +
- + for (;;)
- + {
- + int alt7=2;
- + switch ( LA(1) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + alt7=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt7)
- + {
- + case 1:
- + // RSP.g:122:15: DIGIT09
- + {
- + /* 122:15: DIGIT09 */
- + mDIGIT09(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTEx;
- + }
- +
- +
- + }
- + break;
- +
- + default:
- + goto loop7; /* break out of the loop */
- + break;
- + }
- + }
- + loop7: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINTEx; /* Prevent compiler warnings */
- + ruleINTEx: ;
- +
- +}
- +// $ANTLR end INT
- +
- +// Comes from: 125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DATE
- + *
- + * Looks to match the characters the constitute the token DATE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDATE(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = DATE;
- +
- +
- + // RSP.g:125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) )
- + // RSP.g:125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' )
- + {
- + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
- + mDIGIT19(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
- + mDIGIT09(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
- + mDIGIT09(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
- + mDIGIT09(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + MATCHC('-');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + // RSP.g:125:44: ( '0' DIGIT19 | '1' '0' .. '2' )
- + {
- + int alt8=2;
- + switch ( LA(1) )
- + {
- + case '0':
- + {
- + alt8=1;
- + }
- + break;
- + case '1':
- + {
- + alt8=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 8;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + switch (alt8)
- + {
- + case 1:
- + // RSP.g:125:45: '0' DIGIT19
- + {
- + MATCHC('0');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:45: '0' DIGIT19 */
- + mDIGIT19(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:125:59: '1' '0' .. '2'
- + {
- + MATCHC('1');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + MATCHRANGE('0', '2');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- + MATCHC('-');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + // RSP.g:125:77: ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' )
- + {
- + int alt9=3;
- + switch ( LA(1) )
- + {
- + case '0':
- + {
- + alt9=1;
- + }
- + break;
- + case '1':
- + case '2':
- + {
- + alt9=2;
- + }
- + break;
- + case '3':
- + {
- + alt9=3;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + switch (alt9)
- + {
- + case 1:
- + // RSP.g:125:78: '0' DIGIT19
- + {
- + MATCHC('0');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:78: '0' DIGIT19 */
- + mDIGIT19(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:125:92: '1' .. '2' DIGIT09
- + {
- + MATCHRANGE('1', '2');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + /* 125:92: '1' .. '2' DIGIT09 */
- + mDIGIT09(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- + break;
- + case 3:
- + // RSP.g:125:111: '3' '0' .. '1'
- + {
- + MATCHC('3');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + MATCHRANGE('0', '1');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDATEEx; /* Prevent compiler warnings */
- + ruleDATEEx: ;
- +
- +}
- +// $ANTLR end DATE
- +
- +// Comes from: 133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start STR
- + *
- + * Looks to match the characters the constitute the token STR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mSTR(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- + pANTLR3_COMMON_TOKEN esc;
- + ANTLR3_UINT32 reg;
- +
- +
- + esc = NULL;
- +
- + _type = STR;
- +
- + pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory);
- +
- + // RSP.g:133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE )
- + // RSP.g:133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE
- + {
- + /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + // RSP.g:133:10: (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+
- + {
- + int cnt10=0;
- +
- + for (;;)
- + {
- + int alt10=3;
- + {
- + /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
- + */
- + int LA10_0 = LA(1);
- + if ( (((LA10_0 >= 0x0000) && (LA10_0 <= '!')) || ((LA10_0 >= '#') && (LA10_0 <= '[')) || ((LA10_0 >= ']') && (LA10_0 <= 0xFFFF))) )
- + {
- + alt10=1;
- + }
- + else if ( (LA10_0 == '\\') )
- + {
- + alt10=2;
- + }
- +
- + }
- + switch (alt10)
- + {
- + case 1:
- + // RSP.g:133:12: reg=~ ( '\\\\' | '\"' )
- + {
- + reg= LA(1);
- + if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleSTREx;
- + }
- +
- + {
- + unesc->addc(unesc, reg);
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP.g:134:6: esc= ESCAPED
- + {
- + /* 134:6: esc= ESCAPED */
- + {
- + ANTLR3_MARKER escStart381 = GETCHARINDEX();
- + mESCAPED(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory);
- + esc->setType(esc, ANTLR3_TOKEN_INVALID);
- + esc->setStartIndex(esc, escStart381);
- + esc->setStopIndex(esc, GETCHARINDEX()-1);
- + esc->input = INPUT;
- + }
- + {
- + unesc->appendS(unesc, GETTEXT());
- + }
- +
- + }
- + break;
- +
- + default:
- +
- + if ( cnt10 >= 1 )
- + {
- + goto loop10;
- + }
- + /* mismatchedSetEx()
- + */
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
- +
- +
- + goto ruleSTREx;
- + }
- + cnt10++;
- + }
- + loop10: ; /* Jump to here if this rule does not match */
- + }
- + /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + {
- + SETTEXT(unesc);
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleSTREx; /* Prevent compiler warnings */
- + ruleSTREx: ;
- +
- + esc = NULL;
- +
- +}
- +// $ANTLR end STR
- +
- +// Comes from: 138:9: ( '\\\\' ( '\\\\' | '\"' ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start ESCAPED
- + *
- + * Looks to match the characters the constitute the token ESCAPED
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mESCAPED(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // RSP.g:138:9: ( '\\\\' ( '\\\\' | '\"' ) )
- + // RSP.g:138:11: '\\\\' ( '\\\\' | '\"' )
- + {
- + MATCHC('\\');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- +
- + // RSP.g:139:3: ( '\\\\' | '\"' )
- + {
- + int alt11=2;
- + switch ( LA(1) )
- + {
- + case '\\':
- + {
- + alt11=1;
- + }
- + break;
- + case '"':
- + {
- + alt11=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 11;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleESCAPEDEx;
- + }
- +
- + switch (alt11)
- + {
- + case 1:
- + // RSP.g:139:5: '\\\\'
- + {
- + MATCHC('\\');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- + {
- + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\"));
- + }
- +
- + }
- + break;
- + case 2:
- + // RSP.g:140:5: '\"'
- + {
- + MATCHC('"');
- + if (HASEXCEPTION())
- + {
- + goto ruleESCAPEDEx;
- + }
- +
- + {
- + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\""));
- + }
- +
- + }
- + break;
- +
- + }
- + }
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleESCAPEDEx; /* Prevent compiler warnings */
- + ruleESCAPEDEx: ;
- +
- +}
- +// $ANTLR end ESCAPED
- +
- +// Comes from: 145:9: ( '0' .. '9' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DIGIT09
- + *
- + * Looks to match the characters the constitute the token DIGIT09
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDIGIT09(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // RSP.g:145:9: ( '0' .. '9' )
- + // RSP.g:145:11: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDIGIT09Ex;
- + }
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDIGIT09Ex; /* Prevent compiler warnings */
- + ruleDIGIT09Ex: ;
- +
- +}
- +// $ANTLR end DIGIT09
- +
- +// Comes from: 148:9: ( '1' .. '9' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DIGIT19
- + *
- + * Looks to match the characters the constitute the token DIGIT19
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDIGIT19(pRSPLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // RSP.g:148:9: ( '1' .. '9' )
- + // RSP.g:148:11: '1' .. '9'
- + {
- + MATCHRANGE('1', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDIGIT19Ex;
- + }
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDIGIT19Ex; /* Prevent compiler warnings */
- + ruleDIGIT19Ex: ;
- +
- +}
- +// $ANTLR end DIGIT19
- +
- +/** This is the entry point in to the lexer from an object that
- + * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
- + */
- +static void
- +mTokens(pRSPLexer ctx)
- +{
- + {
- + // RSP.g:1:8: ( QUOTE | LPAR | RPAR | AND | OR | NOT | EQUAL | INCLUDES | STARTSW | ENDSW | GREATER | LESS | GTE | LTE | BEFORE | AFTER | DAY | WEEK | MONTH | YEAR | TODAY | NEWLINE | WS | FIELD | INT | DATE | STR )
- +
- + ANTLR3_UINT32 alt12;
- +
- + alt12=27;
- +
- + switch ( LA(1) )
- + {
- + case '"':
- + {
- +
- + {
- + int LA12_1 = LA(2);
- + if ( (((LA12_1 >= 0x0000) && (LA12_1 <= '!')) || ((LA12_1 >= '#') && (LA12_1 <= 0xFFFF))) )
- + {
- + alt12=27;
- + }
- + else
- + {
- + alt12=1; }
- + }
- + }
- + break;
- + case '(':
- + {
- + alt12=2;
- + }
- + break;
- + case ')':
- + {
- + alt12=3;
- + }
- + break;
- + case 'a':
- + {
- + switch ( LA(2) )
- + {
- + case 'n':
- + {
- + switch ( LA(3) )
- + {
- + case 'd':
- + {
- + switch ( LA(4) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=4;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case 'f':
- + {
- + switch ( LA(3) )
- + {
- + case 't':
- + {
- + switch ( LA(4) )
- + {
- + case 'e':
- + {
- + switch ( LA(5) )
- + {
- + case 'r':
- + {
- + switch ( LA(6) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=16;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'o':
- + {
- + switch ( LA(2) )
- + {
- + case 'r':
- + {
- + switch ( LA(3) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=5;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 5;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case '!':
- + {
- + alt12=6;
- + }
- + break;
- + case '=':
- + {
- + alt12=7;
- + }
- + break;
- + case 'i':
- + {
- + switch ( LA(2) )
- + {
- + case 'n':
- + {
- + switch ( LA(3) )
- + {
- + case 'c':
- + {
- + switch ( LA(4) )
- + {
- + case 'l':
- + {
- + switch ( LA(5) )
- + {
- + case 'u':
- + {
- + switch ( LA(6) )
- + {
- + case 'd':
- + {
- + switch ( LA(7) )
- + {
- + case 'e':
- + {
- + switch ( LA(8) )
- + {
- + case 's':
- + {
- + switch ( LA(9) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=8;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 8;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 's':
- + {
- + switch ( LA(2) )
- + {
- + case 't':
- + {
- + switch ( LA(3) )
- + {
- + case 'a':
- + {
- + switch ( LA(4) )
- + {
- + case 'r':
- + {
- + switch ( LA(5) )
- + {
- + case 't':
- + {
- + switch ( LA(6) )
- + {
- + case 's':
- + {
- + switch ( LA(7) )
- + {
- + case 'w':
- + {
- + switch ( LA(8) )
- + {
- + case 'i':
- + {
- + switch ( LA(9) )
- + {
- + case 't':
- + {
- + switch ( LA(10) )
- + {
- + case 'h':
- + {
- + switch ( LA(11) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=9;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 9;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'e':
- + {
- + switch ( LA(2) )
- + {
- + case 'n':
- + {
- + switch ( LA(3) )
- + {
- + case 'd':
- + {
- + switch ( LA(4) )
- + {
- + case 's':
- + {
- + switch ( LA(5) )
- + {
- + case 'w':
- + {
- + switch ( LA(6) )
- + {
- + case 'i':
- + {
- + switch ( LA(7) )
- + {
- + case 't':
- + {
- + switch ( LA(8) )
- + {
- + case 'h':
- + {
- + switch ( LA(9) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=10;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 10;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case '>':
- + {
- + switch ( LA(2) )
- + {
- + case '=':
- + {
- + alt12=13;
- + }
- + break;
- +
- + default:
- + alt12=11;}
- +
- + }
- + break;
- + case '<':
- + {
- + switch ( LA(2) )
- + {
- + case '=':
- + {
- + alt12=14;
- + }
- + break;
- +
- + default:
- + alt12=12;}
- +
- + }
- + break;
- + case 'b':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'f':
- + {
- + switch ( LA(4) )
- + {
- + case 'o':
- + {
- + switch ( LA(5) )
- + {
- + case 'r':
- + {
- + switch ( LA(6) )
- + {
- + case 'e':
- + {
- + switch ( LA(7) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=15;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 13;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'd':
- + {
- + switch ( LA(2) )
- + {
- + case 'a':
- + {
- + switch ( LA(3) )
- + {
- + case 'y':
- + {
- + switch ( LA(4) )
- + {
- + case 's':
- + {
- + switch ( LA(5) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=17;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=17;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 14;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'w':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'e':
- + {
- + switch ( LA(4) )
- + {
- + case 'k':
- + {
- + switch ( LA(5) )
- + {
- + case 's':
- + {
- + switch ( LA(6) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=18;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=18;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 15;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'm':
- + {
- + switch ( LA(2) )
- + {
- + case 'o':
- + {
- + switch ( LA(3) )
- + {
- + case 'n':
- + {
- + switch ( LA(4) )
- + {
- + case 't':
- + {
- + switch ( LA(5) )
- + {
- + case 'h':
- + {
- + switch ( LA(6) )
- + {
- + case 's':
- + {
- + switch ( LA(7) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=19;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=19;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 16;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'y':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'a':
- + {
- + switch ( LA(4) )
- + {
- + case 'r':
- + {
- + switch ( LA(5) )
- + {
- + case 's':
- + {
- + switch ( LA(6) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=20;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=20;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 17;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 't':
- + {
- + switch ( LA(2) )
- + {
- + case 'o':
- + {
- + switch ( LA(3) )
- + {
- + case 'd':
- + {
- + switch ( LA(4) )
- + {
- + case 'a':
- + {
- + switch ( LA(5) )
- + {
- + case 'y':
- + {
- + switch ( LA(6) )
- + {
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'o':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + alt12=21;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- +
- + default:
- + alt12=24;}
- +
- + }
- + break;
- + case '_':
- + case 'a':
- + case 'b':
- + case 'c':
- + case 'd':
- + case 'e':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'i':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'm':
- + case 'n':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 's':
- + case 't':
- + case 'u':
- + case 'v':
- + case 'w':
- + case 'x':
- + case 'y':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 18;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case '\n':
- + case '\r':
- + {
- + alt12=22;
- + }
- + break;
- + case '\t':
- + case ' ':
- + {
- + alt12=23;
- + }
- + break;
- + case 'c':
- + case 'f':
- + case 'g':
- + case 'h':
- + case 'j':
- + case 'k':
- + case 'l':
- + case 'n':
- + case 'p':
- + case 'q':
- + case 'r':
- + case 'u':
- + case 'v':
- + case 'x':
- + case 'z':
- + {
- + alt12=24;
- + }
- + break;
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(2) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(3) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(4) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(5) )
- + {
- + case '-':
- + {
- + alt12=26;
- + }
- + break;
- +
- + default:
- + alt12=25;}
- +
- + }
- + break;
- +
- + default:
- + alt12=25;}
- +
- + }
- + break;
- +
- + default:
- + alt12=25;}
- +
- + }
- + break;
- +
- + default:
- + alt12=25;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + switch (alt12)
- + {
- + case 1:
- + // RSP.g:1:10: QUOTE
- + {
- + /* 1:10: QUOTE */
- + mQUOTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:1:16: LPAR
- + {
- + /* 1:16: LPAR */
- + mLPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 3:
- + // RSP.g:1:21: RPAR
- + {
- + /* 1:21: RPAR */
- + mRPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 4:
- + // RSP.g:1:26: AND
- + {
- + /* 1:26: AND */
- + mAND(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 5:
- + // RSP.g:1:30: OR
- + {
- + /* 1:30: OR */
- + mOR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 6:
- + // RSP.g:1:33: NOT
- + {
- + /* 1:33: NOT */
- + mNOT(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 7:
- + // RSP.g:1:37: EQUAL
- + {
- + /* 1:37: EQUAL */
- + mEQUAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 8:
- + // RSP.g:1:43: INCLUDES
- + {
- + /* 1:43: INCLUDES */
- + mINCLUDES(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 9:
- + // RSP.g:1:52: STARTSW
- + {
- + /* 1:52: STARTSW */
- + mSTARTSW(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 10:
- + // RSP.g:1:60: ENDSW
- + {
- + /* 1:60: ENDSW */
- + mENDSW(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 11:
- + // RSP.g:1:66: GREATER
- + {
- + /* 1:66: GREATER */
- + mGREATER(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 12:
- + // RSP.g:1:74: LESS
- + {
- + /* 1:74: LESS */
- + mLESS(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 13:
- + // RSP.g:1:79: GTE
- + {
- + /* 1:79: GTE */
- + mGTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 14:
- + // RSP.g:1:83: LTE
- + {
- + /* 1:83: LTE */
- + mLTE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 15:
- + // RSP.g:1:87: BEFORE
- + {
- + /* 1:87: BEFORE */
- + mBEFORE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 16:
- + // RSP.g:1:94: AFTER
- + {
- + /* 1:94: AFTER */
- + mAFTER(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 17:
- + // RSP.g:1:100: DAY
- + {
- + /* 1:100: DAY */
- + mDAY(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 18:
- + // RSP.g:1:104: WEEK
- + {
- + /* 1:104: WEEK */
- + mWEEK(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 19:
- + // RSP.g:1:109: MONTH
- + {
- + /* 1:109: MONTH */
- + mMONTH(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 20:
- + // RSP.g:1:115: YEAR
- + {
- + /* 1:115: YEAR */
- + mYEAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 21:
- + // RSP.g:1:120: TODAY
- + {
- + /* 1:120: TODAY */
- + mTODAY(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 22:
- + // RSP.g:1:126: NEWLINE
- + {
- + /* 1:126: NEWLINE */
- + mNEWLINE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 23:
- + // RSP.g:1:134: WS
- + {
- + /* 1:134: WS */
- + mWS(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 24:
- + // RSP.g:1:137: FIELD
- + {
- + /* 1:137: FIELD */
- + mFIELD(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 25:
- + // RSP.g:1:143: INT
- + {
- + /* 1:143: INT */
- + mINT(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 26:
- + // RSP.g:1:147: DATE
- + {
- + /* 1:147: DATE */
- + mDATE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 27:
- + // RSP.g:1:152: STR
- + {
- + /* 1:152: STR */
- + mSTR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- +
- +
- + goto ruleTokensEx; /* Prevent compiler warnings */
- +ruleTokensEx: ;
- +}
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +/* End of Lexer code
- + * ================================================
- + * ================================================
- + */
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/RSPLexer.h b/src/pregen/RSPLexer.h
- new file mode 100644
- index 0000000..27bc791
- --- /dev/null
- +++ b/src/pregen/RSPLexer.h
- @@ -0,0 +1,254 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP.g
- + * - On : 2016-01-01 12:23:42
- + * - for the lexer : RSPLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The lexer RSPLexer has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pRSPLexer, which is returned from a call to RSPLexerNew().
- + *
- + * As this is a generated lexer, it is unlikely you will call it 'manually'. However
- + * the methods are provided anyway.
- + * * The methods in pRSPLexer are as follows:
- + *
- + * - void pRSPLexer->QUOTE(pRSPLexer)
- + * - void pRSPLexer->LPAR(pRSPLexer)
- + * - void pRSPLexer->RPAR(pRSPLexer)
- + * - void pRSPLexer->AND(pRSPLexer)
- + * - void pRSPLexer->OR(pRSPLexer)
- + * - void pRSPLexer->NOT(pRSPLexer)
- + * - void pRSPLexer->EQUAL(pRSPLexer)
- + * - void pRSPLexer->INCLUDES(pRSPLexer)
- + * - void pRSPLexer->STARTSW(pRSPLexer)
- + * - void pRSPLexer->ENDSW(pRSPLexer)
- + * - void pRSPLexer->GREATER(pRSPLexer)
- + * - void pRSPLexer->LESS(pRSPLexer)
- + * - void pRSPLexer->GTE(pRSPLexer)
- + * - void pRSPLexer->LTE(pRSPLexer)
- + * - void pRSPLexer->BEFORE(pRSPLexer)
- + * - void pRSPLexer->AFTER(pRSPLexer)
- + * - void pRSPLexer->DAY(pRSPLexer)
- + * - void pRSPLexer->WEEK(pRSPLexer)
- + * - void pRSPLexer->MONTH(pRSPLexer)
- + * - void pRSPLexer->YEAR(pRSPLexer)
- + * - void pRSPLexer->TODAY(pRSPLexer)
- + * - void pRSPLexer->NEWLINE(pRSPLexer)
- + * - void pRSPLexer->WS(pRSPLexer)
- + * - void pRSPLexer->FIELD(pRSPLexer)
- + * - void pRSPLexer->INT(pRSPLexer)
- + * - void pRSPLexer->DATE(pRSPLexer)
- + * - void pRSPLexer->STR(pRSPLexer)
- + * - void pRSPLexer->ESCAPED(pRSPLexer)
- + * - void pRSPLexer->DIGIT09(pRSPLexer)
- + * - void pRSPLexer->DIGIT19(pRSPLexer)
- + * - void pRSPLexer->Tokens(pRSPLexer)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _RSPLexer_H
- +#define _RSPLexer_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct RSPLexer_Ctx_struct RSPLexer, * pRSPLexer;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +
- +/** Context tracking structure for RSPLexer
- + */
- +struct RSPLexer_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_LEXER pLexer;
- +
- +
- + void (*mQUOTE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mLPAR) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mRPAR) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mAND) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mOR) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mNOT) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mEQUAL) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mINCLUDES) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mSTARTSW) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mENDSW) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mGREATER) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mLESS) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mGTE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mLTE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mBEFORE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mAFTER) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mDAY) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mWEEK) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mMONTH) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mYEAR) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mTODAY) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mNEWLINE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mWS) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mFIELD) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mINT) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mDATE) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mSTR) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mESCAPED) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mDIGIT09) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mDIGIT19) (struct RSPLexer_Ctx_struct * ctx);
- + void (*mTokens) (struct RSPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)();
- + void (*free) (struct RSPLexer_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pRSPLexer RSPLexerNew (pANTLR3_INPUT_STREAM instream);
- +ANTLR3_API pRSPLexer RSPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the lexer will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STARTSW 14
- +#define WEEK 26
- +#define TODAY 24
- +#define YEAR 28
- +#define ENDSW 15
- +#define GTE 20
- +#define BEFORE 21
- +#define DAY 25
- +#define INT 16
- +#define NOT 11
- +#define AFTER 22
- +#define AND 6
- +#define EOF -1
- +#define LTE 19
- +#define MONTH 27
- +#define DIGIT19 31
- +#define INCLUDES 13
- +#define STR 10
- +#define QUOTE 29
- +#define GREATER 18
- +#define WS 30
- +#define LPAR 7
- +#define NEWLINE 4
- +#define EQUAL 12
- +#define OR 5
- +#define LESS 17
- +#define FIELD 9
- +#define RPAR 8
- +#define ESCAPED 33
- +#define DATE 23
- +#define DIGIT09 32
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for RSPLexer
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/RSPParser.c b/src/pregen/RSPParser.c
- new file mode 100644
- index 0000000..ba8a9d2
- --- /dev/null
- +++ b/src/pregen/RSPParser.c
- @@ -0,0 +1,3152 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP.g
- + * - On : 2016-01-01 12:23:42
- + * - for the parser : RSPParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "RSPParser.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pRSPParser_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pRSPParser_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pRSPParser_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pRSPParser_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef MEMOIZE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef INDEX
- +#undef ADAPTOR
- +#undef SEEK
- +#undef RULEMEMO
- +#undef DBG
- +
- +#define PARSER ctx->pParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define INPUT PARSER->tstream
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(INPUT->istream)
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) INPUT->istream->_LA(ISTREAM, n)
- +#define LT(n) INPUT->_LT(INPUT, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR ctx->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 RSPParserTokenNames[30+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "NEWLINE",
- + (pANTLR3_UINT8) "OR",
- + (pANTLR3_UINT8) "AND",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "FIELD",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "NOT",
- + (pANTLR3_UINT8) "EQUAL",
- + (pANTLR3_UINT8) "INCLUDES",
- + (pANTLR3_UINT8) "STARTSW",
- + (pANTLR3_UINT8) "ENDSW",
- + (pANTLR3_UINT8) "INT",
- + (pANTLR3_UINT8) "LESS",
- + (pANTLR3_UINT8) "GREATER",
- + (pANTLR3_UINT8) "LTE",
- + (pANTLR3_UINT8) "GTE",
- + (pANTLR3_UINT8) "BEFORE",
- + (pANTLR3_UINT8) "AFTER",
- + (pANTLR3_UINT8) "DATE",
- + (pANTLR3_UINT8) "TODAY",
- + (pANTLR3_UINT8) "DAY",
- + (pANTLR3_UINT8) "WEEK",
- + (pANTLR3_UINT8) "MONTH",
- + (pANTLR3_UINT8) "YEAR",
- + (pANTLR3_UINT8) "QUOTE",
- + (pANTLR3_UINT8) "WS",
- + (pANTLR3_UINT8) "DIGIT19",
- + (pANTLR3_UINT8) "DIGIT09",
- + (pANTLR3_UINT8) "ESCAPED"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static RSPParser_query_return query (pRSPParser ctx);
- +static RSPParser_expr_return expr (pRSPParser ctx);
- +static RSPParser_aexpr_return aexpr (pRSPParser ctx);
- +static RSPParser_crit_return crit (pRSPParser ctx);
- +static RSPParser_strcrit_return strcrit (pRSPParser ctx);
- +static RSPParser_strop_return strop (pRSPParser ctx);
- +static RSPParser_intcrit_return intcrit (pRSPParser ctx);
- +static RSPParser_intop_return intop (pRSPParser ctx);
- +static RSPParser_datecrit_return datecrit (pRSPParser ctx);
- +static RSPParser_dateop_return dateop (pRSPParser ctx);
- +static RSPParser_datespec_return datespec (pRSPParser ctx);
- +static RSPParser_dateref_return dateref (pRSPParser ctx);
- +static RSPParser_dateintval_return dateintval (pRSPParser ctx);
- +static void RSPParserFree(pRSPParser ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "RSP.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new RSPParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pRSPParser
- +RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return RSPParserNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new RSPParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pRSPParser
- +RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pRSPParser ctx; /* Context structure we will build and return */
- +
- + ctx = (pRSPParser) ANTLR3_CALLOC(1, sizeof(RSPParser));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in RSPParser.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base parser/recognizer, using the supplied token stream
- + */
- + ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
- + /* Install the implementation of our RSPParser interface
- + */
- + ctx->query = query;
- + ctx->expr = expr;
- + ctx->aexpr = aexpr;
- + ctx->crit = crit;
- + ctx->strcrit = strcrit;
- + ctx->strop = strop;
- + ctx->intcrit = intcrit;
- + ctx->intop = intop;
- + ctx->datecrit = datecrit;
- + ctx->dateop = dateop;
- + ctx->datespec = datespec;
- + ctx->dateref = dateref;
- + ctx->dateintval = dateintval;
- + ctx->free = RSPParserFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- + ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
- + ctx->vectors = antlr3VectorFactoryNew(0);
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = RSPParserTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + RSPParserFree(pRSPParser ctx)
- + {
- + /* Free any scope memory
- + */
- +
- + ctx->vectors->close(ctx->vectors);
- + /* We created the adaptor so we must free it
- + */
- + ADAPTOR->free(ADAPTOR);
- + // Free this parser
- + //
- + ctx->pParser->free(ctx->pParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return RSPParserTokenNames;
- +}
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */
- +static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */
- +static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr63 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr63_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr63 = { FOLLOW_aexpr_in_expr63_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr66 */
- +static ANTLR3_BITWORD FOLLOW_OR_in_expr66_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr66 = { FOLLOW_OR_in_expr66_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr69 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr69_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr69 = { FOLLOW_aexpr_in_expr69_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr81 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr81_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr81 = { FOLLOW_crit_in_aexpr81_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr84 */
- +static ANTLR3_BITWORD FOLLOW_AND_in_aexpr84_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr84 = { FOLLOW_AND_in_aexpr84_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr87 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr87_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr87 = { FOLLOW_crit_in_aexpr87_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit99 */
- +static ANTLR3_BITWORD FOLLOW_LPAR_in_crit99_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
- +static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit99 = { FOLLOW_LPAR_in_crit99_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit101 */
- +static ANTLR3_BITWORD FOLLOW_expr_in_crit101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) };
- +static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit101 = { FOLLOW_expr_in_crit101_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit103 */
- +static ANTLR3_BITWORD FOLLOW_RPAR_in_crit103_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit103 = { FOLLOW_RPAR_in_crit103_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_crit114 */
- +static ANTLR3_BITWORD FOLLOW_strcrit_in_crit114_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_crit114 = { FOLLOW_strcrit_in_crit114_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_crit119 */
- +static ANTLR3_BITWORD FOLLOW_intcrit_in_crit119_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_crit119 = { FOLLOW_intcrit_in_crit119_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_crit124 */
- +static ANTLR3_BITWORD FOLLOW_datecrit_in_crit124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_crit124 = { FOLLOW_datecrit_in_crit124_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit134 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit134_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit134 = { FOLLOW_FIELD_in_strcrit134_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit136 */
- +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit136_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
- +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit136 = { FOLLOW_strop_in_strcrit136_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit138 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit138_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit138 = { FOLLOW_STR_in_strcrit138_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit155 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit155_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit155 = { FOLLOW_FIELD_in_strcrit155_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_strcrit157 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_strcrit157_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_strcrit157 = { FOLLOW_NOT_in_strcrit157_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit159 */
- +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit159_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
- +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit159 = { FOLLOW_strop_in_strcrit159_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit161 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit161_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit161 = { FOLLOW_STR_in_strcrit161_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_strop188 */
- +static ANTLR3_BITWORD FOLLOW_EQUAL_in_strop188_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_strop188 = { FOLLOW_EQUAL_in_strop188_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_strop195 */
- +static ANTLR3_BITWORD FOLLOW_INCLUDES_in_strop195_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_strop195 = { FOLLOW_INCLUDES_in_strop195_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STARTSW_in_strop202 */
- +static ANTLR3_BITWORD FOLLOW_STARTSW_in_strop202_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STARTSW_in_strop202 = { FOLLOW_STARTSW_in_strop202_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENDSW_in_strop209 */
- +static ANTLR3_BITWORD FOLLOW_ENDSW_in_strop209_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENDSW_in_strop209 = { FOLLOW_ENDSW_in_strop209_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit219 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit219_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit219 = { FOLLOW_FIELD_in_intcrit219_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit221 */
- +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit221_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
- +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit221 = { FOLLOW_intop_in_intcrit221_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit223 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit223_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit223 = { FOLLOW_INT_in_intcrit223_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit240 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit240_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit240 = { FOLLOW_FIELD_in_intcrit240_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_intcrit242 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_intcrit242_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_intcrit242 = { FOLLOW_NOT_in_intcrit242_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit244 */
- +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit244_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
- +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit244 = { FOLLOW_intop_in_intcrit244_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit246 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit246_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit246 = { FOLLOW_INT_in_intcrit246_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_intop273 */
- +static ANTLR3_BITWORD FOLLOW_EQUAL_in_intop273_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_intop273 = { FOLLOW_EQUAL_in_intop273_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LESS_in_intop280 */
- +static ANTLR3_BITWORD FOLLOW_LESS_in_intop280_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_LESS_in_intop280 = { FOLLOW_LESS_in_intop280_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GREATER_in_intop287 */
- +static ANTLR3_BITWORD FOLLOW_GREATER_in_intop287_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_GREATER_in_intop287 = { FOLLOW_GREATER_in_intop287_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LTE_in_intop294 */
- +static ANTLR3_BITWORD FOLLOW_LTE_in_intop294_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_LTE_in_intop294 = { FOLLOW_LTE_in_intop294_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GTE_in_intop301 */
- +static ANTLR3_BITWORD FOLLOW_GTE_in_intop301_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_GTE_in_intop301 = { FOLLOW_GTE_in_intop301_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit310 */
- +static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit310_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) };
- +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit310 = { FOLLOW_FIELD_in_datecrit310_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit312 */
- +static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit312_bits[] = { ANTLR3_UINT64_LIT(0x0000000001810000) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit312 = { FOLLOW_dateop_in_datecrit312_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit314 */
- +static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit314_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit314 = { FOLLOW_datespec_in_datecrit314_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateop337 */
- +static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateop337_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateop337 = { FOLLOW_BEFORE_in_dateop337_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateop344 */
- +static ANTLR3_BITWORD FOLLOW_AFTER_in_dateop344_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateop344 = { FOLLOW_AFTER_in_dateop344_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec353 */
- +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec353_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec353 = { FOLLOW_dateref_in_datespec353_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec358 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_datespec358_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec358 = { FOLLOW_INT_in_datespec358_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec360 */
- +static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec360_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec360 = { FOLLOW_dateintval_in_datespec360_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec362 */
- +static ANTLR3_BITWORD FOLLOW_dateop_in_datespec362_bits[] = { ANTLR3_UINT64_LIT(0x0000000001800000) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec362 = { FOLLOW_dateop_in_datespec362_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec364 */
- +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec364_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec364 = { FOLLOW_dateref_in_datespec364_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateref388 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateref388_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateref388 = { FOLLOW_DATE_in_dateref388_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_TODAY_in_dateref395 */
- +static ANTLR3_BITWORD FOLLOW_TODAY_in_dateref395_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_TODAY_in_dateref395 = { FOLLOW_TODAY_in_dateref395_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DAY_in_dateintval408 */
- +static ANTLR3_BITWORD FOLLOW_DAY_in_dateintval408_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DAY_in_dateintval408 = { FOLLOW_DAY_in_dateintval408_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_WEEK_in_dateintval415 */
- +static ANTLR3_BITWORD FOLLOW_WEEK_in_dateintval415_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_WEEK_in_dateintval415 = { FOLLOW_WEEK_in_dateintval415_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_MONTH_in_dateintval422 */
- +static ANTLR3_BITWORD FOLLOW_MONTH_in_dateintval422_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_MONTH_in_dateintval422 = { FOLLOW_MONTH_in_dateintval422_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_YEAR_in_dateintval429 */
- +static ANTLR3_BITWORD FOLLOW_YEAR_in_dateintval429_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_YEAR_in_dateintval429 = { FOLLOW_YEAR_in_dateintval429_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start query
- + * RSP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
- + */
- +static RSPParser_query_return
- +query(pRSPParser ctx)
- +{
- + RSPParser_query_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN NEWLINE2;
- + pANTLR3_COMMON_TOKEN EOF3;
- + RSPParser_expr_return expr1;
- + #undef RETURN_TYPE_expr1
- + #define RETURN_TYPE_expr1 RSPParser_expr_return
- +
- + pANTLR3_BASE_TREE NEWLINE2_tree;
- + pANTLR3_BASE_TREE EOF3_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + NEWLINE2 = NULL;
- + EOF3 = NULL;
- + expr1.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + NEWLINE2_tree = NULL;
- + EOF3_tree = NULL;
- +
- + stream_NEWLINE = NULL;
- + #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); }
- + stream_EOF = NULL;
- + #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); }
- + stream_expr = NULL;
- + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
- +
- + retval.tree = NULL;
- + {
- + // RSP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
- + // RSP.g:27:9: expr ( NEWLINE )? EOF
- + {
- + FOLLOWPUSH(FOLLOW_expr_in_query42);
- + expr1=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);
- +
- + // RSP.g:27:14: ( NEWLINE )?
- + {
- + int alt1=2;
- + switch ( LA(1) )
- + {
- + case NEWLINE:
- + {
- + alt1=1;
- + }
- + break;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // RSP.g:27:14: NEWLINE
- + {
- + NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44);
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47);
- + if (HASEXCEPTION())
- + {
- + goto rulequeryEx;
- + }
- +
- + CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : expr
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 27:28: -> expr
- + {
- + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulequeryEx; /* Prevent compiler warnings */
- + rulequeryEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
- + if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
- + if (stream_expr != NULL) stream_expr->free(stream_expr);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end query */
- +
- +/**
- + * $ANTLR start expr
- + * RSP.g:30:1: expr : aexpr ( OR aexpr )* ;
- + */
- +static RSPParser_expr_return
- +expr(pRSPParser ctx)
- +{
- + RSPParser_expr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN OR5;
- + RSPParser_aexpr_return aexpr4;
- + #undef RETURN_TYPE_aexpr4
- + #define RETURN_TYPE_aexpr4 RSPParser_aexpr_return
- +
- + RSPParser_aexpr_return aexpr6;
- + #undef RETURN_TYPE_aexpr6
- + #define RETURN_TYPE_aexpr6 RSPParser_aexpr_return
- +
- + pANTLR3_BASE_TREE OR5_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + OR5 = NULL;
- + aexpr4.tree = NULL;
- +
- + aexpr6.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + OR5_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // RSP.g:30:6: ( aexpr ( OR aexpr )* )
- + // RSP.g:30:8: aexpr ( OR aexpr )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expr63);
- + aexpr4=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);
- +
- + // RSP.g:30:14: ( OR aexpr )*
- +
- + for (;;)
- + {
- + int alt2=2;
- + switch ( LA(1) )
- + {
- + case OR:
- + {
- + alt2=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // RSP.g:30:15: OR aexpr
- + {
- + OR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expr66);
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + OR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR5));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR5_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expr69);
- + aexpr6=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop2; /* break out of the loop */
- + break;
- + }
- + }
- + loop2: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexprEx; /* Prevent compiler warnings */
- + ruleexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end expr */
- +
- +/**
- + * $ANTLR start aexpr
- + * RSP.g:33:1: aexpr : crit ( AND crit )* ;
- + */
- +static RSPParser_aexpr_return
- +aexpr(pRSPParser ctx)
- +{
- + RSPParser_aexpr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN AND8;
- + RSPParser_crit_return crit7;
- + #undef RETURN_TYPE_crit7
- + #define RETURN_TYPE_crit7 RSPParser_crit_return
- +
- + RSPParser_crit_return crit9;
- + #undef RETURN_TYPE_crit9
- + #define RETURN_TYPE_crit9 RSPParser_crit_return
- +
- + pANTLR3_BASE_TREE AND8_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + AND8 = NULL;
- + crit7.tree = NULL;
- +
- + crit9.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + AND8_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // RSP.g:33:7: ( crit ( AND crit )* )
- + // RSP.g:33:9: crit ( AND crit )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_aexpr81);
- + crit7=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);
- +
- + // RSP.g:33:14: ( AND crit )*
- +
- + for (;;)
- + {
- + int alt3=2;
- + switch ( LA(1) )
- + {
- + case AND:
- + {
- + alt3=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // RSP.g:33:15: AND crit
- + {
- + AND8 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr84);
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + AND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND8));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND8_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_aexpr87);
- + crit9=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop3; /* break out of the loop */
- + break;
- + }
- + }
- + loop3: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleaexprEx; /* Prevent compiler warnings */
- + ruleaexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end aexpr */
- +
- +/**
- + * $ANTLR start crit
- + * RSP.g:36:1: crit : ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit );
- + */
- +static RSPParser_crit_return
- +crit(pRSPParser ctx)
- +{
- + RSPParser_crit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN LPAR10;
- + pANTLR3_COMMON_TOKEN RPAR12;
- + RSPParser_expr_return expr11;
- + #undef RETURN_TYPE_expr11
- + #define RETURN_TYPE_expr11 RSPParser_expr_return
- +
- + RSPParser_strcrit_return strcrit13;
- + #undef RETURN_TYPE_strcrit13
- + #define RETURN_TYPE_strcrit13 RSPParser_strcrit_return
- +
- + RSPParser_intcrit_return intcrit14;
- + #undef RETURN_TYPE_intcrit14
- + #define RETURN_TYPE_intcrit14 RSPParser_intcrit_return
- +
- + RSPParser_datecrit_return datecrit15;
- + #undef RETURN_TYPE_datecrit15
- + #define RETURN_TYPE_datecrit15 RSPParser_datecrit_return
- +
- + pANTLR3_BASE_TREE LPAR10_tree;
- + pANTLR3_BASE_TREE RPAR12_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + LPAR10 = NULL;
- + RPAR12 = NULL;
- + expr11.tree = NULL;
- +
- + strcrit13.tree = NULL;
- +
- + intcrit14.tree = NULL;
- +
- + datecrit15.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + LPAR10_tree = NULL;
- + RPAR12_tree = NULL;
- +
- + stream_RPAR = NULL;
- + #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
- + stream_LPAR = NULL;
- + #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
- + stream_expr = NULL;
- + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:36:6: ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=4;
- +
- + switch ( LA(1) )
- + {
- + case LPAR:
- + {
- + alt4=1;
- + }
- + break;
- + case FIELD:
- + {
- + switch ( LA(2) )
- + {
- + case NOT:
- + {
- + switch ( LA(3) )
- + {
- + case EQUAL:
- + {
- + switch ( LA(4) )
- + {
- + case STR:
- + {
- + alt4=2;
- + }
- + break;
- + case INT:
- + {
- + alt4=3;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 8;
- +
- +
- + goto rulecritEx;
- + }
- +
- + }
- + break;
- + case LESS:
- + case GREATER:
- + case LTE:
- + case GTE:
- + {
- + alt4=3;
- + }
- + break;
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 3;
- +
- +
- + goto rulecritEx;
- + }
- +
- + }
- + break;
- + case BEFORE:
- + case AFTER:
- + {
- + alt4=4;
- + }
- + break;
- + case EQUAL:
- + {
- + switch ( LA(3) )
- + {
- + case INT:
- + {
- + alt4=3;
- + }
- + break;
- + case STR:
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 5;
- +
- +
- + goto rulecritEx;
- + }
- +
- + }
- + break;
- + case LESS:
- + case GREATER:
- + case LTE:
- + case GTE:
- + {
- + alt4=3;
- + }
- + break;
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 2;
- +
- +
- + goto rulecritEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulecritEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // RSP.g:36:8: LPAR expr RPAR
- + {
- + LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit99);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);
- +
- + FOLLOWPUSH(FOLLOW_expr_in_crit101);
- + expr11=expr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
- + RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit103);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : expr
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 36:25: -> expr
- + {
- + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- + case 2:
- + // RSP.g:37:4: strcrit
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_strcrit_in_crit114);
- + strcrit13=strcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, strcrit13.tree);
- +
- + }
- + break;
- + case 3:
- + // RSP.g:38:4: intcrit
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_intcrit_in_crit119);
- + intcrit14=intcrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, intcrit14.tree);
- +
- + }
- + break;
- + case 4:
- + // RSP.g:39:4: datecrit
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_datecrit_in_crit124);
- + datecrit15=datecrit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, datecrit15.tree);
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulecritEx; /* Prevent compiler warnings */
- + rulecritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
- + if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
- + if (stream_expr != NULL) stream_expr->free(stream_expr);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end crit */
- +
- +/**
- + * $ANTLR start strcrit
- + * RSP.g:42:1: strcrit : ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) );
- + */
- +static RSPParser_strcrit_return
- +strcrit(pRSPParser ctx)
- +{
- + RSPParser_strcrit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN FIELD16;
- + pANTLR3_COMMON_TOKEN STR18;
- + pANTLR3_COMMON_TOKEN FIELD19;
- + pANTLR3_COMMON_TOKEN NOT20;
- + pANTLR3_COMMON_TOKEN STR22;
- + RSPParser_strop_return strop17;
- + #undef RETURN_TYPE_strop17
- + #define RETURN_TYPE_strop17 RSPParser_strop_return
- +
- + RSPParser_strop_return strop21;
- + #undef RETURN_TYPE_strop21
- + #define RETURN_TYPE_strop21 RSPParser_strop_return
- +
- + pANTLR3_BASE_TREE FIELD16_tree;
- + pANTLR3_BASE_TREE STR18_tree;
- + pANTLR3_BASE_TREE FIELD19_tree;
- + pANTLR3_BASE_TREE NOT20_tree;
- + pANTLR3_BASE_TREE STR22_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_STR;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_strop;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + FIELD16 = NULL;
- + STR18 = NULL;
- + FIELD19 = NULL;
- + NOT20 = NULL;
- + STR22 = NULL;
- + strop17.tree = NULL;
- +
- + strop21.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + FIELD16_tree = NULL;
- + STR18_tree = NULL;
- + FIELD19_tree = NULL;
- + NOT20_tree = NULL;
- + STR22_tree = NULL;
- +
- + stream_STR = NULL;
- + #define CREATE_stream_STR if (stream_STR == NULL) {stream_STR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token STR"); }
- + stream_FIELD = NULL;
- + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
- + stream_NOT = NULL;
- + #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); }
- + stream_strop = NULL;
- + #define CREATE_stream_strop if (stream_strop == NULL) {stream_strop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule strop"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:42:9: ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) )
- +
- + ANTLR3_UINT32 alt5;
- +
- + alt5=2;
- +
- + switch ( LA(1) )
- + {
- + case FIELD:
- + {
- + switch ( LA(2) )
- + {
- + case NOT:
- + {
- + alt5=2;
- + }
- + break;
- + case EQUAL:
- + case INCLUDES:
- + case STARTSW:
- + case ENDSW:
- + {
- + alt5=1;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 1;
- +
- +
- + goto rulestrcritEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulestrcritEx;
- + }
- +
- + switch (alt5)
- + {
- + case 1:
- + // RSP.g:42:11: FIELD strop STR
- + {
- + FIELD16 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit134);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD16, NULL);
- +
- + FOLLOWPUSH(FOLLOW_strop_in_strcrit136);
- + strop17=strop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_strop; stream_strop->add(stream_strop, strop17.tree, NULL);
- + STR18 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit138);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_STR; stream_STR->add(stream_STR, STR18, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : FIELD, STR, strop
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 42:29: -> ^( strop FIELD STR )
- + {
- + // RSP.g:42:32: ^( strop FIELD STR )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_1));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- + case 2:
- + // RSP.g:43:4: FIELD NOT strop STR
- + {
- + FIELD19 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit155);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD19, NULL);
- +
- + NOT20 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_strcrit157);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT20, NULL);
- +
- + FOLLOWPUSH(FOLLOW_strop_in_strcrit159);
- + strop21=strop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_strop; stream_strop->add(stream_strop, strop21.tree, NULL);
- + STR22 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit161);
- + if (HASEXCEPTION())
- + {
- + goto rulestrcritEx;
- + }
- +
- + CREATE_stream_STR; stream_STR->add(stream_STR, STR22, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : STR, FIELD, strop, NOT
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 43:25: -> ^( NOT ^( strop FIELD STR ) )
- + {
- + // RSP.g:43:28: ^( NOT ^( strop FIELD STR ) )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));
- +
- + // RSP.g:43:34: ^( strop FIELD STR )
- + {
- + pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_2));
- +
- + ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
- + ADAPTOR->addChild(ADAPTOR, root_2, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, root_2);
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulestrcritEx; /* Prevent compiler warnings */
- + rulestrcritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_STR != NULL) stream_STR->free(stream_STR);
- + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
- + if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
- + if (stream_strop != NULL) stream_strop->free(stream_strop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end strcrit */
- +
- +/**
- + * $ANTLR start strop
- + * RSP.g:46:1: strop : (equal= EQUAL | includes= INCLUDES | startsw= STARTSW | endsw= ENDSW );
- + */
- +static RSPParser_strop_return
- +strop(pRSPParser ctx)
- +{
- + RSPParser_strop_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN equal;
- + pANTLR3_COMMON_TOKEN includes;
- + pANTLR3_COMMON_TOKEN startsw;
- + pANTLR3_COMMON_TOKEN endsw;
- +
- + pANTLR3_BASE_TREE equal_tree;
- + pANTLR3_BASE_TREE includes_tree;
- + pANTLR3_BASE_TREE startsw_tree;
- + pANTLR3_BASE_TREE endsw_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + equal = NULL;
- + includes = NULL;
- + startsw = NULL;
- + endsw = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + equal_tree = NULL;
- + includes_tree = NULL;
- + startsw_tree = NULL;
- + endsw_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:46:7: (equal= EQUAL | includes= INCLUDES | startsw= STARTSW | endsw= ENDSW )
- +
- + ANTLR3_UINT32 alt6;
- +
- + alt6=4;
- +
- + switch ( LA(1) )
- + {
- + case EQUAL:
- + {
- + alt6=1;
- + }
- + break;
- + case INCLUDES:
- + {
- + alt6=2;
- + }
- + break;
- + case STARTSW:
- + {
- + alt6=3;
- + }
- + break;
- + case ENDSW:
- + {
- + alt6=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 6;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulestropEx;
- + }
- +
- + switch (alt6)
- + {
- + case 1:
- + // RSP.g:46:9: equal= EQUAL
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + equal = (pANTLR3_COMMON_TOKEN) MATCHT(EQUAL, &FOLLOW_EQUAL_in_strop188);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + equal_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, equal));
- + ADAPTOR->addChild(ADAPTOR, root_0, equal_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:47:4: includes= INCLUDES
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + includes = (pANTLR3_COMMON_TOKEN) MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_strop195);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + includes_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, includes));
- + ADAPTOR->addChild(ADAPTOR, root_0, includes_tree);
- +
- +
- + }
- + break;
- + case 3:
- + // RSP.g:48:4: startsw= STARTSW
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + startsw = (pANTLR3_COMMON_TOKEN) MATCHT(STARTSW, &FOLLOW_STARTSW_in_strop202);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + startsw_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, startsw));
- + ADAPTOR->addChild(ADAPTOR, root_0, startsw_tree);
- +
- +
- + }
- + break;
- + case 4:
- + // RSP.g:49:4: endsw= ENDSW
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + endsw = (pANTLR3_COMMON_TOKEN) MATCHT(ENDSW, &FOLLOW_ENDSW_in_strop209);
- + if (HASEXCEPTION())
- + {
- + goto rulestropEx;
- + }
- +
- + endsw_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, endsw));
- + ADAPTOR->addChild(ADAPTOR, root_0, endsw_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulestropEx; /* Prevent compiler warnings */
- + rulestropEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end strop */
- +
- +/**
- + * $ANTLR start intcrit
- + * RSP.g:52:1: intcrit : ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) );
- + */
- +static RSPParser_intcrit_return
- +intcrit(pRSPParser ctx)
- +{
- + RSPParser_intcrit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN FIELD23;
- + pANTLR3_COMMON_TOKEN INT25;
- + pANTLR3_COMMON_TOKEN FIELD26;
- + pANTLR3_COMMON_TOKEN NOT27;
- + pANTLR3_COMMON_TOKEN INT29;
- + RSPParser_intop_return intop24;
- + #undef RETURN_TYPE_intop24
- + #define RETURN_TYPE_intop24 RSPParser_intop_return
- +
- + RSPParser_intop_return intop28;
- + #undef RETURN_TYPE_intop28
- + #define RETURN_TYPE_intop28 RSPParser_intop_return
- +
- + pANTLR3_BASE_TREE FIELD23_tree;
- + pANTLR3_BASE_TREE INT25_tree;
- + pANTLR3_BASE_TREE FIELD26_tree;
- + pANTLR3_BASE_TREE NOT27_tree;
- + pANTLR3_BASE_TREE INT29_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_intop;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + FIELD23 = NULL;
- + INT25 = NULL;
- + FIELD26 = NULL;
- + NOT27 = NULL;
- + INT29 = NULL;
- + intop24.tree = NULL;
- +
- + intop28.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + FIELD23_tree = NULL;
- + INT25_tree = NULL;
- + FIELD26_tree = NULL;
- + NOT27_tree = NULL;
- + INT29_tree = NULL;
- +
- + stream_FIELD = NULL;
- + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
- + stream_INT = NULL;
- + #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); }
- + stream_NOT = NULL;
- + #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); }
- + stream_intop = NULL;
- + #define CREATE_stream_intop if (stream_intop == NULL) {stream_intop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule intop"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:52:9: ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) )
- +
- + ANTLR3_UINT32 alt7;
- +
- + alt7=2;
- +
- + switch ( LA(1) )
- + {
- + case FIELD:
- + {
- + switch ( LA(2) )
- + {
- + case NOT:
- + {
- + alt7=2;
- + }
- + break;
- + case EQUAL:
- + case LESS:
- + case GREATER:
- + case LTE:
- + case GTE:
- + {
- + alt7=1;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 7;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleintcritEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 7;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleintcritEx;
- + }
- +
- + switch (alt7)
- + {
- + case 1:
- + // RSP.g:52:11: FIELD intop INT
- + {
- + FIELD23 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit219);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD23, NULL);
- +
- + FOLLOWPUSH(FOLLOW_intop_in_intcrit221);
- + intop24=intop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_intop; stream_intop->add(stream_intop, intop24.tree, NULL);
- + INT25 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit223);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_INT; stream_INT->add(stream_INT, INT25, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : FIELD, INT, intop
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 52:29: -> ^( intop FIELD INT )
- + {
- + // RSP.g:52:32: ^( intop FIELD INT )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_1));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- + case 2:
- + // RSP.g:53:4: FIELD NOT intop INT
- + {
- + FIELD26 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit240);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD26, NULL);
- +
- + NOT27 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_intcrit242);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT27, NULL);
- +
- + FOLLOWPUSH(FOLLOW_intop_in_intcrit244);
- + intop28=intop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_intop; stream_intop->add(stream_intop, intop28.tree, NULL);
- + INT29 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit246);
- + if (HASEXCEPTION())
- + {
- + goto ruleintcritEx;
- + }
- +
- + CREATE_stream_INT; stream_INT->add(stream_INT, INT29, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : intop, NOT, INT, FIELD
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 53:25: -> ^( NOT ^( intop FIELD INT ) )
- + {
- + // RSP.g:53:28: ^( NOT ^( intop FIELD INT ) )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));
- +
- + // RSP.g:53:34: ^( intop FIELD INT )
- + {
- + pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_2));
- +
- + ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
- + ADAPTOR->addChild(ADAPTOR, root_2, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, root_2);
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintcritEx; /* Prevent compiler warnings */
- + ruleintcritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
- + if (stream_INT != NULL) stream_INT->free(stream_INT);
- + if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
- + if (stream_intop != NULL) stream_intop->free(stream_intop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end intcrit */
- +
- +/**
- + * $ANTLR start intop
- + * RSP.g:56:1: intop : (equal= EQUAL | less= LESS | greater= GREATER | lte= LTE | gte= GTE );
- + */
- +static RSPParser_intop_return
- +intop(pRSPParser ctx)
- +{
- + RSPParser_intop_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN equal;
- + pANTLR3_COMMON_TOKEN less;
- + pANTLR3_COMMON_TOKEN greater;
- + pANTLR3_COMMON_TOKEN lte;
- + pANTLR3_COMMON_TOKEN gte;
- +
- + pANTLR3_BASE_TREE equal_tree;
- + pANTLR3_BASE_TREE less_tree;
- + pANTLR3_BASE_TREE greater_tree;
- + pANTLR3_BASE_TREE lte_tree;
- + pANTLR3_BASE_TREE gte_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + equal = NULL;
- + less = NULL;
- + greater = NULL;
- + lte = NULL;
- + gte = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + equal_tree = NULL;
- + less_tree = NULL;
- + greater_tree = NULL;
- + lte_tree = NULL;
- + gte_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:56:7: (equal= EQUAL | less= LESS | greater= GREATER | lte= LTE | gte= GTE )
- +
- + ANTLR3_UINT32 alt8;
- +
- + alt8=5;
- +
- + switch ( LA(1) )
- + {
- + case EQUAL:
- + {
- + alt8=1;
- + }
- + break;
- + case LESS:
- + {
- + alt8=2;
- + }
- + break;
- + case GREATER:
- + {
- + alt8=3;
- + }
- + break;
- + case LTE:
- + {
- + alt8=4;
- + }
- + break;
- + case GTE:
- + {
- + alt8=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 8;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleintopEx;
- + }
- +
- + switch (alt8)
- + {
- + case 1:
- + // RSP.g:56:9: equal= EQUAL
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + equal = (pANTLR3_COMMON_TOKEN) MATCHT(EQUAL, &FOLLOW_EQUAL_in_intop273);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + equal_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, equal));
- + ADAPTOR->addChild(ADAPTOR, root_0, equal_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:57:4: less= LESS
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + less = (pANTLR3_COMMON_TOKEN) MATCHT(LESS, &FOLLOW_LESS_in_intop280);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + less_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, less));
- + ADAPTOR->addChild(ADAPTOR, root_0, less_tree);
- +
- +
- + }
- + break;
- + case 3:
- + // RSP.g:58:4: greater= GREATER
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + greater = (pANTLR3_COMMON_TOKEN) MATCHT(GREATER, &FOLLOW_GREATER_in_intop287);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + greater_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, greater));
- + ADAPTOR->addChild(ADAPTOR, root_0, greater_tree);
- +
- +
- + }
- + break;
- + case 4:
- + // RSP.g:59:4: lte= LTE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + lte = (pANTLR3_COMMON_TOKEN) MATCHT(LTE, &FOLLOW_LTE_in_intop294);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + lte_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, lte));
- + ADAPTOR->addChild(ADAPTOR, root_0, lte_tree);
- +
- +
- + }
- + break;
- + case 5:
- + // RSP.g:60:4: gte= GTE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + gte = (pANTLR3_COMMON_TOKEN) MATCHT(GTE, &FOLLOW_GTE_in_intop301);
- + if (HASEXCEPTION())
- + {
- + goto ruleintopEx;
- + }
- +
- + gte_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, gte));
- + ADAPTOR->addChild(ADAPTOR, root_0, gte_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintopEx; /* Prevent compiler warnings */
- + ruleintopEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end intop */
- +
- +/**
- + * $ANTLR start datecrit
- + * RSP.g:63:1: datecrit : FIELD dateop datespec -> ^( dateop FIELD datespec ) ;
- + */
- +static RSPParser_datecrit_return
- +datecrit(pRSPParser ctx)
- +{
- + RSPParser_datecrit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN FIELD30;
- + RSPParser_dateop_return dateop31;
- + #undef RETURN_TYPE_dateop31
- + #define RETURN_TYPE_dateop31 RSPParser_dateop_return
- +
- + RSPParser_datespec_return datespec32;
- + #undef RETURN_TYPE_datespec32
- + #define RETURN_TYPE_datespec32 RSPParser_datespec_return
- +
- + pANTLR3_BASE_TREE FIELD30_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_datespec;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + FIELD30 = NULL;
- + dateop31.tree = NULL;
- +
- + datespec32.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + FIELD30_tree = NULL;
- +
- + stream_FIELD = NULL;
- + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
- + stream_datespec = NULL;
- + #define CREATE_stream_datespec if (stream_datespec == NULL) {stream_datespec = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule datespec"); }
- + stream_dateop = NULL;
- + #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }
- +
- + retval.tree = NULL;
- + {
- + // RSP.g:63:9: ( FIELD dateop datespec -> ^( dateop FIELD datespec ) )
- + // RSP.g:63:11: FIELD dateop datespec
- + {
- + FIELD30 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit310);
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD30, NULL);
- +
- + FOLLOWPUSH(FOLLOW_dateop_in_datecrit312);
- + dateop31=dateop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop31.tree, NULL);
- + FOLLOWPUSH(FOLLOW_datespec_in_datecrit314);
- + datespec32=datespec(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatecritEx;
- + }
- +
- + CREATE_stream_datespec; stream_datespec->add(stream_datespec, datespec32.tree, NULL);
- +
- +
- + /* AST REWRITE
- + * elements : FIELD, dateop, datespec
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 63:34: -> ^( dateop FIELD datespec )
- + {
- + // RSP.g:63:37: ^( dateop FIELD datespec )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_datespec == NULL ? NULL : stream_datespec->nextTree(stream_datespec));
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatecritEx; /* Prevent compiler warnings */
- + ruledatecritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
- + if (stream_datespec != NULL) stream_datespec->free(stream_datespec);
- + if (stream_dateop != NULL) stream_dateop->free(stream_dateop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end datecrit */
- +
- +/**
- + * $ANTLR start dateop
- + * RSP.g:66:1: dateop : (before= BEFORE | after= AFTER );
- + */
- +static RSPParser_dateop_return
- +dateop(pRSPParser ctx)
- +{
- + RSPParser_dateop_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN before;
- + pANTLR3_COMMON_TOKEN after;
- +
- + pANTLR3_BASE_TREE before_tree;
- + pANTLR3_BASE_TREE after_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + before = NULL;
- + after = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + before_tree = NULL;
- + after_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:66:8: (before= BEFORE | after= AFTER )
- +
- + ANTLR3_UINT32 alt9;
- +
- + alt9=2;
- +
- + switch ( LA(1) )
- + {
- + case BEFORE:
- + {
- + alt9=1;
- + }
- + break;
- + case AFTER:
- + {
- + alt9=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledateopEx;
- + }
- +
- + switch (alt9)
- + {
- + case 1:
- + // RSP.g:66:10: before= BEFORE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + before = (pANTLR3_COMMON_TOKEN) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateop337);
- + if (HASEXCEPTION())
- + {
- + goto ruledateopEx;
- + }
- +
- + before_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, before));
- + ADAPTOR->addChild(ADAPTOR, root_0, before_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:67:4: after= AFTER
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + after = (pANTLR3_COMMON_TOKEN) MATCHT(AFTER, &FOLLOW_AFTER_in_dateop344);
- + if (HASEXCEPTION())
- + {
- + goto ruledateopEx;
- + }
- +
- + after_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, after));
- + ADAPTOR->addChild(ADAPTOR, root_0, after_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledateopEx; /* Prevent compiler warnings */
- + ruledateopEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateop */
- +
- +/**
- + * $ANTLR start datespec
- + * RSP.g:70:1: datespec : ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) );
- + */
- +static RSPParser_datespec_return
- +datespec(pRSPParser ctx)
- +{
- + RSPParser_datespec_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN INT34;
- + RSPParser_dateref_return dateref33;
- + #undef RETURN_TYPE_dateref33
- + #define RETURN_TYPE_dateref33 RSPParser_dateref_return
- +
- + RSPParser_dateintval_return dateintval35;
- + #undef RETURN_TYPE_dateintval35
- + #define RETURN_TYPE_dateintval35 RSPParser_dateintval_return
- +
- + RSPParser_dateop_return dateop36;
- + #undef RETURN_TYPE_dateop36
- + #define RETURN_TYPE_dateop36 RSPParser_dateop_return
- +
- + RSPParser_dateref_return dateref37;
- + #undef RETURN_TYPE_dateref37
- + #define RETURN_TYPE_dateref37 RSPParser_dateref_return
- +
- + pANTLR3_BASE_TREE INT34_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateintval;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateref;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + INT34 = NULL;
- + dateref33.tree = NULL;
- +
- + dateintval35.tree = NULL;
- +
- + dateop36.tree = NULL;
- +
- + dateref37.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + INT34_tree = NULL;
- +
- + stream_INT = NULL;
- + #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); }
- + stream_dateintval = NULL;
- + #define CREATE_stream_dateintval if (stream_dateintval == NULL) {stream_dateintval = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateintval"); }
- + stream_dateref = NULL;
- + #define CREATE_stream_dateref if (stream_dateref == NULL) {stream_dateref = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateref"); }
- + stream_dateop = NULL;
- + #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:70:9: ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) )
- +
- + ANTLR3_UINT32 alt10;
- +
- + alt10=2;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + case TODAY:
- + {
- + alt10=1;
- + }
- + break;
- + case INT:
- + {
- + alt10=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 10;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledatespecEx;
- + }
- +
- + switch (alt10)
- + {
- + case 1:
- + // RSP.g:70:11: dateref
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_dateref_in_datespec353);
- + dateref33=dateref(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, dateref33.tree);
- +
- + }
- + break;
- + case 2:
- + // RSP.g:71:4: INT dateintval dateop dateref
- + {
- + INT34 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_datespec358);
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + CREATE_stream_INT; stream_INT->add(stream_INT, INT34, NULL);
- +
- + FOLLOWPUSH(FOLLOW_dateintval_in_datespec360);
- + dateintval35=dateintval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + CREATE_stream_dateintval; stream_dateintval->add(stream_dateintval, dateintval35.tree, NULL);
- + FOLLOWPUSH(FOLLOW_dateop_in_datespec362);
- + dateop36=dateop(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop36.tree, NULL);
- + FOLLOWPUSH(FOLLOW_dateref_in_datespec364);
- + dateref37=dateref(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatespecEx;
- + }
- +
- + CREATE_stream_dateref; stream_dateref->add(stream_dateref, dateref37.tree, NULL);
- +
- +
- + /* AST REWRITE
- + * elements : dateop, INT, dateintval, dateref
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 71:34: -> ^( dateop dateref INT dateintval )
- + {
- + // RSP.g:71:37: ^( dateop dateref INT dateintval )
- + {
- + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));
- +
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_dateref == NULL ? NULL : stream_dateref->nextTree(stream_dateref));
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
- + ADAPTOR->addChild(ADAPTOR, root_1, stream_dateintval == NULL ? NULL : stream_dateintval->nextTree(stream_dateintval));
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
- + }
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatespecEx; /* Prevent compiler warnings */
- + ruledatespecEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_INT != NULL) stream_INT->free(stream_INT);
- + if (stream_dateintval != NULL) stream_dateintval->free(stream_dateintval);
- + if (stream_dateref != NULL) stream_dateref->free(stream_dateref);
- + if (stream_dateop != NULL) stream_dateop->free(stream_dateop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end datespec */
- +
- +/**
- + * $ANTLR start dateref
- + * RSP.g:74:1: dateref : (date= DATE | today= TODAY );
- + */
- +static RSPParser_dateref_return
- +dateref(pRSPParser ctx)
- +{
- + RSPParser_dateref_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN date;
- + pANTLR3_COMMON_TOKEN today;
- +
- + pANTLR3_BASE_TREE date_tree;
- + pANTLR3_BASE_TREE today_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + date = NULL;
- + today = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + date_tree = NULL;
- + today_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:74:9: (date= DATE | today= TODAY )
- +
- + ANTLR3_UINT32 alt11;
- +
- + alt11=2;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + {
- + alt11=1;
- + }
- + break;
- + case TODAY:
- + {
- + alt11=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 11;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledaterefEx;
- + }
- +
- + switch (alt11)
- + {
- + case 1:
- + // RSP.g:74:11: date= DATE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + date = (pANTLR3_COMMON_TOKEN) MATCHT(DATE, &FOLLOW_DATE_in_dateref388);
- + if (HASEXCEPTION())
- + {
- + goto ruledaterefEx;
- + }
- +
- + date_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, date));
- + ADAPTOR->addChild(ADAPTOR, root_0, date_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:75:4: today= TODAY
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + today = (pANTLR3_COMMON_TOKEN) MATCHT(TODAY, &FOLLOW_TODAY_in_dateref395);
- + if (HASEXCEPTION())
- + {
- + goto ruledaterefEx;
- + }
- +
- + today_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, today));
- + ADAPTOR->addChild(ADAPTOR, root_0, today_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledaterefEx; /* Prevent compiler warnings */
- + ruledaterefEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateref */
- +
- +/**
- + * $ANTLR start dateintval
- + * RSP.g:78:1: dateintval : (day= DAY | week= WEEK | month= MONTH | year= YEAR );
- + */
- +static RSPParser_dateintval_return
- +dateintval(pRSPParser ctx)
- +{
- + RSPParser_dateintval_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN day;
- + pANTLR3_COMMON_TOKEN week;
- + pANTLR3_COMMON_TOKEN month;
- + pANTLR3_COMMON_TOKEN year;
- +
- + pANTLR3_BASE_TREE day_tree;
- + pANTLR3_BASE_TREE week_tree;
- + pANTLR3_BASE_TREE month_tree;
- + pANTLR3_BASE_TREE year_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + day = NULL;
- + week = NULL;
- + month = NULL;
- + year = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + day_tree = NULL;
- + week_tree = NULL;
- + month_tree = NULL;
- + year_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // RSP.g:79:2: (day= DAY | week= WEEK | month= MONTH | year= YEAR )
- +
- + ANTLR3_UINT32 alt12;
- +
- + alt12=4;
- +
- + switch ( LA(1) )
- + {
- + case DAY:
- + {
- + alt12=1;
- + }
- + break;
- + case WEEK:
- + {
- + alt12=2;
- + }
- + break;
- + case MONTH:
- + {
- + alt12=3;
- + }
- + break;
- + case YEAR:
- + {
- + alt12=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 12;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledateintvalEx;
- + }
- +
- + switch (alt12)
- + {
- + case 1:
- + // RSP.g:79:4: day= DAY
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + day = (pANTLR3_COMMON_TOKEN) MATCHT(DAY, &FOLLOW_DAY_in_dateintval408);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + day_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, day));
- + ADAPTOR->addChild(ADAPTOR, root_0, day_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // RSP.g:80:4: week= WEEK
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + week = (pANTLR3_COMMON_TOKEN) MATCHT(WEEK, &FOLLOW_WEEK_in_dateintval415);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + week_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, week));
- + ADAPTOR->addChild(ADAPTOR, root_0, week_tree);
- +
- +
- + }
- + break;
- + case 3:
- + // RSP.g:81:4: month= MONTH
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + month = (pANTLR3_COMMON_TOKEN) MATCHT(MONTH, &FOLLOW_MONTH_in_dateintval422);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + month_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, month));
- + ADAPTOR->addChild(ADAPTOR, root_0, month_tree);
- +
- +
- + }
- + break;
- + case 4:
- + // RSP.g:82:4: year= YEAR
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + year = (pANTLR3_COMMON_TOKEN) MATCHT(YEAR, &FOLLOW_YEAR_in_dateintval429);
- + if (HASEXCEPTION())
- + {
- + goto ruledateintvalEx;
- + }
- +
- + year_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, year));
- + ADAPTOR->addChild(ADAPTOR, root_0, year_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledateintvalEx; /* Prevent compiler warnings */
- + ruledateintvalEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateintval */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/RSPParser.h b/src/pregen/RSPParser.h
- new file mode 100644
- index 0000000..1796c0a
- --- /dev/null
- +++ b/src/pregen/RSPParser.h
- @@ -0,0 +1,365 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : RSP.g
- + * - On : 2016-01-01 12:23:42
- + * - for the parser : RSPParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The parser RSPParser has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pRSPParser, which is returned from a call to RSPParserNew().
- + *
- + * The methods in pRSPParser are as follows:
- + *
- + * - RSPParser_query_return pRSPParser->query(pRSPParser)
- + * - RSPParser_expr_return pRSPParser->expr(pRSPParser)
- + * - RSPParser_aexpr_return pRSPParser->aexpr(pRSPParser)
- + * - RSPParser_crit_return pRSPParser->crit(pRSPParser)
- + * - RSPParser_strcrit_return pRSPParser->strcrit(pRSPParser)
- + * - RSPParser_strop_return pRSPParser->strop(pRSPParser)
- + * - RSPParser_intcrit_return pRSPParser->intcrit(pRSPParser)
- + * - RSPParser_intop_return pRSPParser->intop(pRSPParser)
- + * - RSPParser_datecrit_return pRSPParser->datecrit(pRSPParser)
- + * - RSPParser_dateop_return pRSPParser->dateop(pRSPParser)
- + * - RSPParser_datespec_return pRSPParser->datespec(pRSPParser)
- + * - RSPParser_dateref_return pRSPParser->dateref(pRSPParser)
- + * - RSPParser_dateintval_return pRSPParser->dateintval(pRSPParser)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _RSPParser_H
- +#define _RSPParser_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct RSPParser_Ctx_struct RSPParser, * pRSPParser;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct RSPParser_query_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_query_return;
- +
- +typedef struct RSPParser_expr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_expr_return;
- +
- +typedef struct RSPParser_aexpr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_aexpr_return;
- +
- +typedef struct RSPParser_crit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_crit_return;
- +
- +typedef struct RSPParser_strcrit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_strcrit_return;
- +
- +typedef struct RSPParser_strop_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_strop_return;
- +
- +typedef struct RSPParser_intcrit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_intcrit_return;
- +
- +typedef struct RSPParser_intop_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_intop_return;
- +
- +typedef struct RSPParser_datecrit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_datecrit_return;
- +
- +typedef struct RSPParser_dateop_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_dateop_return;
- +
- +typedef struct RSPParser_datespec_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_datespec_return;
- +
- +typedef struct RSPParser_dateref_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_dateref_return;
- +
- +typedef struct RSPParser_dateintval_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + RSPParser_dateintval_return;
- +
- +
- +
- +/** Context tracking structure for RSPParser
- + */
- +struct RSPParser_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_PARSER pParser;
- +
- +
- + RSPParser_query_return (*query) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_expr_return (*expr) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_aexpr_return (*aexpr) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_crit_return (*crit) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_strcrit_return (*strcrit) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_strop_return (*strop) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_intcrit_return (*intcrit) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_intop_return (*intop) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_datecrit_return (*datecrit) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_dateop_return (*dateop) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_datespec_return (*datespec) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_dateref_return (*dateref) (struct RSPParser_Ctx_struct * ctx);
- + RSPParser_dateintval_return (*dateintval) (struct RSPParser_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct RSPParser_Ctx_struct * ctx);
- + /* @headerFile.members() */
- + pANTLR3_BASE_TREE_ADAPTOR adaptor;
- + pANTLR3_VECTOR_FACTORY vectors;
- + /* End @headerFile.members() */
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pRSPParser RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream);
- +ANTLR3_API pRSPParser RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define STARTSW 14
- +#define WEEK 26
- +#define TODAY 24
- +#define YEAR 28
- +#define ENDSW 15
- +#define GTE 20
- +#define BEFORE 21
- +#define DAY 25
- +#define INT 16
- +#define NOT 11
- +#define AFTER 22
- +#define AND 6
- +#define EOF -1
- +#define LTE 19
- +#define MONTH 27
- +#define DIGIT19 31
- +#define INCLUDES 13
- +#define STR 10
- +#define QUOTE 29
- +#define WS 30
- +#define GREATER 18
- +#define NEWLINE 4
- +#define LPAR 7
- +#define EQUAL 12
- +#define OR 5
- +#define LESS 17
- +#define RPAR 8
- +#define FIELD 9
- +#define ESCAPED 33
- +#define DATE 23
- +#define DIGIT09 32
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for RSPParser
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/SMARTPL.u b/src/pregen/SMARTPL.u
- new file mode 100644
- index 0000000..2a66bf3
- --- /dev/null
- +++ b/src/pregen/SMARTPL.u
- @@ -0,0 +1,6 @@
- +SMARTPLParser.c : SMARTPL.g
- +./SMARTPL.tokens : SMARTPL.g
- +SMARTPLParser.h : SMARTPL.g
- +SMARTPLLexer.c : SMARTPL.g
- +SMARTPLLexer.h : SMARTPL.g
- +ANTLR_PRODUCTS += SMARTPLParser.c ./SMARTPL.tokens SMARTPLParser.h SMARTPLLexer.c SMARTPLLexer.h
- \ No newline at end of file
- diff --git a/src/pregen/SMARTPL2SQL.c b/src/pregen/SMARTPL2SQL.c
- new file mode 100644
- index 0000000..bd93752
- --- /dev/null
- +++ b/src/pregen/SMARTPL2SQL.c
- @@ -0,0 +1,1649 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL2SQL.g
- + * - On : 2016-01-01 12:23:44
- + * - for the tree parser : SMARTPL2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +
- +/* =============================================================================
- + * This is what the grammar programmer asked us to put at the top of every file.
- + */
- +
- + #include <stdio.h>
- + #include <stdlib.h>
- + #include <string.h>
- + #include <limits.h>
- + #include <errno.h>
- + #include <time.h>
- + #include <sqlite3.h>
- +
- + #include "logger.h"
- + #include "db.h"
- +
- +/* End of Header action.
- + * =============================================================================
- + */
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "SMARTPL2SQL.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pSMARTPL2SQL_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pSMARTPL2SQL_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pSMARTPL2SQL_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pSMARTPL2SQL_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef BACKTRACKING
- +#undef ADAPTOR
- +#undef RULEMEMO
- +#undef SEEK
- +#undef INDEX
- +#undef DBG
- +
- +#define PARSER ctx->pTreeParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define INPUT PARSER->ctnstream
- +#define ISTREAM INPUT->tnstream->istream
- +#define STRSTREAM INPUT->tnstream
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) ISTREAM->_LA(ISTREAM, n)
- +#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR INPUT->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define DBG RECOGNIZER->debugger
- +
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 SMARTPL2SQLTokenNames[28+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "OR",
- + (pANTLR3_UINT8) "AND",
- + (pANTLR3_UINT8) "NOT",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "STRTAG",
- + (pANTLR3_UINT8) "INCLUDES",
- + (pANTLR3_UINT8) "IS",
- + (pANTLR3_UINT8) "INTTAG",
- + (pANTLR3_UINT8) "INTBOOL",
- + (pANTLR3_UINT8) "INT",
- + (pANTLR3_UINT8) "DATETAG",
- + (pANTLR3_UINT8) "AFTER",
- + (pANTLR3_UINT8) "BEFORE",
- + (pANTLR3_UINT8) "ENUMTAG",
- + (pANTLR3_UINT8) "ENUMVAL",
- + (pANTLR3_UINT8) "DATE",
- + (pANTLR3_UINT8) "AGO",
- + (pANTLR3_UINT8) "DATINTERVAL",
- + (pANTLR3_UINT8) "GREATER",
- + (pANTLR3_UINT8) "GREATEREQUAL",
- + (pANTLR3_UINT8) "LESS",
- + (pANTLR3_UINT8) "LESSEQUAL",
- + (pANTLR3_UINT8) "EQUAL",
- + (pANTLR3_UINT8) "WHITESPACE",
- + (pANTLR3_UINT8) "'{'",
- + (pANTLR3_UINT8) "'}'"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static SMARTPL2SQL_playlist_return playlist (pSMARTPL2SQL ctx);
- +static pANTLR3_STRING expression (pSMARTPL2SQL ctx);
- +static int dateval (pSMARTPL2SQL ctx);
- +static int interval (pSMARTPL2SQL ctx);
- +static void SMARTPL2SQLFree(pSMARTPL2SQL ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "SMARTPL2SQL.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new SMARTPL2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pSMARTPL2SQL
- +SMARTPL2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return SMARTPL2SQLNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new SMARTPL2SQL parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pSMARTPL2SQL
- +SMARTPL2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pSMARTPL2SQL ctx; /* Context structure we will build and return */
- +
- + ctx = (pSMARTPL2SQL) ANTLR3_CALLOC(1, sizeof(SMARTPL2SQL));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in SMARTPL2SQL.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base Tree parser/recognizer, using the supplied tree node stream
- + */
- + ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state);
- + /* Install the implementation of our SMARTPL2SQL interface
- + */
- + ctx->playlist = playlist;
- + ctx->expression = expression;
- + ctx->dateval = dateval;
- + ctx->interval = interval;
- + ctx->free = SMARTPL2SQLFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- +
- +
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = SMARTPL2SQLTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + SMARTPL2SQLFree(pSMARTPL2SQL ctx)
- + {
- + /* Free any scope memory
- + */
- +
- +
- + // Free this parser
- + //
- + ctx->pTreeParser->free(ctx->pTreeParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this tree parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return SMARTPL2SQLTokenNames;
- +}
- +
- +
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_playlist66 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_playlist66_bits[] = { ANTLR3_UINT64_LIT(0x0000000040000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_playlist66 = { FOLLOW_STR_in_playlist66_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_30_in_playlist68 */
- +static ANTLR3_BITWORD FOLLOW_30_in_playlist68_bits[] = { ANTLR3_UINT64_LIT(0x00000000000924E0) };
- +static ANTLR3_BITSET_LIST FOLLOW_30_in_playlist68 = { FOLLOW_30_in_playlist68_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_playlist74 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_playlist74_bits[] = { ANTLR3_UINT64_LIT(0x0000000080000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_playlist74 = { FOLLOW_expression_in_playlist74_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_31_in_playlist76 */
- +static ANTLR3_BITWORD FOLLOW_31_in_playlist76_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_31_in_playlist76 = { FOLLOW_31_in_playlist76_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expression101 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_expression101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expression101 = { FOLLOW_NOT_in_expression101_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_expression107 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_expression107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_expression107 = { FOLLOW_expression_in_expression107_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_expression118 */
- +static ANTLR3_BITWORD FOLLOW_AND_in_expression118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_AND_in_expression118 = { FOLLOW_AND_in_expression118_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_expression124 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_expression124_bits[] = { ANTLR3_UINT64_LIT(0x00000000000924E0) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_expression124 = { FOLLOW_expression_in_expression124_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_expression130 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_expression130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_expression130 = { FOLLOW_expression_in_expression130_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expression141 */
- +static ANTLR3_BITWORD FOLLOW_OR_in_expression141_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
- +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expression141 = { FOLLOW_OR_in_expression141_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_expression147 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_expression147_bits[] = { ANTLR3_UINT64_LIT(0x00000000000924E0) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_expression147 = { FOLLOW_expression_in_expression147_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_expression153 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_expression153_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_expression153 = { FOLLOW_expression_in_expression153_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRTAG_in_expression163 */
- +static ANTLR3_BITWORD FOLLOW_STRTAG_in_expression163_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) };
- +static ANTLR3_BITSET_LIST FOLLOW_STRTAG_in_expression163 = { FOLLOW_STRTAG_in_expression163_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_expression165 */
- +static ANTLR3_BITWORD FOLLOW_INCLUDES_in_expression165_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
- +static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_expression165 = { FOLLOW_INCLUDES_in_expression165_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expression167 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_expression167_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_expression167 = { FOLLOW_STR_in_expression167_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRTAG_in_expression176 */
- +static ANTLR3_BITWORD FOLLOW_STRTAG_in_expression176_bits[] = { ANTLR3_UINT64_LIT(0x0000000000001000) };
- +static ANTLR3_BITSET_LIST FOLLOW_STRTAG_in_expression176 = { FOLLOW_STRTAG_in_expression176_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_IS_in_expression178 */
- +static ANTLR3_BITWORD FOLLOW_IS_in_expression178_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
- +static ANTLR3_BITSET_LIST FOLLOW_IS_in_expression178 = { FOLLOW_IS_in_expression178_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expression180 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_expression180_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_expression180 = { FOLLOW_STR_in_expression180_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INTTAG_in_expression189 */
- +static ANTLR3_BITWORD FOLLOW_INTTAG_in_expression189_bits[] = { ANTLR3_UINT64_LIT(0x0000000000004000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INTTAG_in_expression189 = { FOLLOW_INTTAG_in_expression189_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INTBOOL_in_expression191 */
- +static ANTLR3_BITWORD FOLLOW_INTBOOL_in_expression191_bits[] = { ANTLR3_UINT64_LIT(0x0000000000008000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INTBOOL_in_expression191 = { FOLLOW_INTBOOL_in_expression191_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_expression193 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_expression193_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_expression193 = { FOLLOW_INT_in_expression193_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATETAG_in_expression202 */
- +static ANTLR3_BITWORD FOLLOW_DATETAG_in_expression202_bits[] = { ANTLR3_UINT64_LIT(0x0000000000020000) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATETAG_in_expression202 = { FOLLOW_DATETAG_in_expression202_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_expression204 */
- +static ANTLR3_BITWORD FOLLOW_AFTER_in_expression204_bits[] = { ANTLR3_UINT64_LIT(0x0000000000208000) };
- +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_expression204 = { FOLLOW_AFTER_in_expression204_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateval_in_expression206 */
- +static ANTLR3_BITWORD FOLLOW_dateval_in_expression206_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateval_in_expression206 = { FOLLOW_dateval_in_expression206_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATETAG_in_expression215 */
- +static ANTLR3_BITWORD FOLLOW_DATETAG_in_expression215_bits[] = { ANTLR3_UINT64_LIT(0x0000000000040000) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATETAG_in_expression215 = { FOLLOW_DATETAG_in_expression215_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_expression217 */
- +static ANTLR3_BITWORD FOLLOW_BEFORE_in_expression217_bits[] = { ANTLR3_UINT64_LIT(0x0000000000208000) };
- +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_expression217 = { FOLLOW_BEFORE_in_expression217_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateval_in_expression219 */
- +static ANTLR3_BITWORD FOLLOW_dateval_in_expression219_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateval_in_expression219 = { FOLLOW_dateval_in_expression219_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENUMTAG_in_expression228 */
- +static ANTLR3_BITWORD FOLLOW_ENUMTAG_in_expression228_bits[] = { ANTLR3_UINT64_LIT(0x0000000000001000) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENUMTAG_in_expression228 = { FOLLOW_ENUMTAG_in_expression228_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_IS_in_expression230 */
- +static ANTLR3_BITWORD FOLLOW_IS_in_expression230_bits[] = { ANTLR3_UINT64_LIT(0x0000000000100000) };
- +static ANTLR3_BITSET_LIST FOLLOW_IS_in_expression230 = { FOLLOW_IS_in_expression230_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENUMVAL_in_expression232 */
- +static ANTLR3_BITWORD FOLLOW_ENUMVAL_in_expression232_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENUMVAL_in_expression232 = { FOLLOW_ENUMVAL_in_expression232_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval257 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval257_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval257 = { FOLLOW_DATE_in_dateval257_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval266 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval266_bits[] = { ANTLR3_UINT64_LIT(0x0000000000040000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval266 = { FOLLOW_interval_in_dateval266_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateval268 */
- +static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateval268_bits[] = { ANTLR3_UINT64_LIT(0x0000000000200000) };
- +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateval268 = { FOLLOW_BEFORE_in_dateval268_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval270 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval270_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval270 = { FOLLOW_DATE_in_dateval270_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval279 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval279_bits[] = { ANTLR3_UINT64_LIT(0x0000000000020000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval279 = { FOLLOW_interval_in_dateval279_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateval281 */
- +static ANTLR3_BITWORD FOLLOW_AFTER_in_dateval281_bits[] = { ANTLR3_UINT64_LIT(0x0000000000200000) };
- +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateval281 = { FOLLOW_AFTER_in_dateval281_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval283 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval283_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval283 = { FOLLOW_DATE_in_dateval283_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval292 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval292_bits[] = { ANTLR3_UINT64_LIT(0x0000000000400000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval292 = { FOLLOW_interval_in_dateval292_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AGO_in_dateval294 */
- +static ANTLR3_BITWORD FOLLOW_AGO_in_dateval294_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_AGO_in_dateval294 = { FOLLOW_AGO_in_dateval294_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_interval318 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_interval318_bits[] = { ANTLR3_UINT64_LIT(0x0000000000800000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_interval318 = { FOLLOW_INT_in_interval318_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATINTERVAL_in_interval320 */
- +static ANTLR3_BITWORD FOLLOW_DATINTERVAL_in_interval320_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATINTERVAL_in_interval320 = { FOLLOW_DATINTERVAL_in_interval320_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start playlist
- + * SMARTPL2SQL.g:43:1: playlist returns [ pANTLR3_STRING title, pANTLR3_STRING query ] : STR '{' e= expression '}' ;
- + */
- +static SMARTPL2SQL_playlist_return
- +playlist(pSMARTPL2SQL ctx)
- +{
- + SMARTPL2SQL_playlist_return retval;
- +
- + pANTLR3_BASE_TREE STR1;
- + pANTLR3_STRING e;
- + #undef RETURN_TYPE_e
- + #define RETURN_TYPE_e pANTLR3_STRING
- +
- + /* Initialize rule variables
- + */
- +
- +
- + retval.title= NULL; retval.query= NULL;
- + STR1 = NULL;
- + e = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + {
- + // SMARTPL2SQL.g:45:2: ( STR '{' e= expression '}' )
- + // SMARTPL2SQL.g:45:4: STR '{' e= expression '}'
- + {
- + STR1 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_playlist66);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + MATCHT(30, &FOLLOW_30_in_playlist68);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_playlist74);
- + e=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + MATCHT(31, &FOLLOW_31_in_playlist76);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 val;
- + val = (STR1->getText(STR1))->toUTF8((STR1->getText(STR1)))->chars;
- + val++;
- + val[strlen((const char *)val) - 1] = '\0';
- +
- + retval.title= (STR1->getText(STR1))->factory->newRaw((STR1->getText(STR1))->factory);
- + retval.title->append8(retval.title, (const char *)val);
- +
- + retval.query= e->factory->newRaw(e->factory);
- + retval.query->append8(retval.query, "(");
- + retval.query->appendS(retval.query, e);
- + retval.query->append8(retval.query, ")");
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleplaylistEx; /* Prevent compiler warnings */
- + ruleplaylistEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end playlist */
- +
- +/**
- + * $ANTLR start expression
- + * SMARTPL2SQL.g:62:1: expression returns [ pANTLR3_STRING result ] : ( ^( NOT a= expression ) | ^( AND a= expression b= expression ) | ^( OR a= expression b= expression ) | STRTAG INCLUDES STR | STRTAG IS STR | INTTAG INTBOOL INT | DATETAG AFTER dateval | DATETAG BEFORE dateval | ENUMTAG IS ENUMVAL );
- + */
- +static pANTLR3_STRING
- +expression(pSMARTPL2SQL ctx)
- +{
- + pANTLR3_STRING result = NULL;
- +
- + pANTLR3_BASE_TREE STR2;
- + pANTLR3_BASE_TREE STRTAG3;
- + pANTLR3_BASE_TREE STR4;
- + pANTLR3_BASE_TREE STRTAG5;
- + pANTLR3_BASE_TREE INTTAG6;
- + pANTLR3_BASE_TREE INTBOOL7;
- + pANTLR3_BASE_TREE INT8;
- + pANTLR3_BASE_TREE DATETAG10;
- + pANTLR3_BASE_TREE DATETAG12;
- + pANTLR3_BASE_TREE ENUMTAG13;
- + pANTLR3_BASE_TREE ENUMVAL14;
- + pANTLR3_STRING a;
- + #undef RETURN_TYPE_a
- + #define RETURN_TYPE_a pANTLR3_STRING
- +
- + pANTLR3_STRING b;
- + #undef RETURN_TYPE_b
- + #define RETURN_TYPE_b pANTLR3_STRING
- +
- + int dateval9;
- + #undef RETURN_TYPE_dateval9
- + #define RETURN_TYPE_dateval9 int
- +
- + int dateval11;
- + #undef RETURN_TYPE_dateval11
- + #define RETURN_TYPE_dateval11 int
- +
- + /* Initialize rule variables
- + */
- +
- +
- + result= NULL;
- + STR2 = NULL;
- + STRTAG3 = NULL;
- + STR4 = NULL;
- + STRTAG5 = NULL;
- + INTTAG6 = NULL;
- + INTBOOL7 = NULL;
- + INT8 = NULL;
- + DATETAG10 = NULL;
- + DATETAG12 = NULL;
- + ENUMTAG13 = NULL;
- + ENUMVAL14 = NULL;
- + a = NULL;
- + b = NULL;
- + dateval9 = 0;
- + dateval11 = 0;
- +
- + {
- + {
- + // SMARTPL2SQL.g:64:2: ( ^( NOT a= expression ) | ^( AND a= expression b= expression ) | ^( OR a= expression b= expression ) | STRTAG INCLUDES STR | STRTAG IS STR | INTTAG INTBOOL INT | DATETAG AFTER dateval | DATETAG BEFORE dateval | ENUMTAG IS ENUMVAL )
- +
- + ANTLR3_UINT32 alt1;
- +
- + alt1=9;
- +
- + switch ( LA(1) )
- + {
- + case NOT:
- + {
- + alt1=1;
- + }
- + break;
- + case AND:
- + {
- + alt1=2;
- + }
- + break;
- + case OR:
- + {
- + alt1=3;
- + }
- + break;
- + case STRTAG:
- + {
- + switch ( LA(2) )
- + {
- + case INCLUDES:
- + {
- + alt1=4;
- + }
- + break;
- + case IS:
- + {
- + alt1=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleexpressionEx;
- + }
- +
- + }
- + break;
- + case INTTAG:
- + {
- + alt1=6;
- + }
- + break;
- + case DATETAG:
- + {
- + switch ( LA(2) )
- + {
- + case AFTER:
- + {
- + alt1=7;
- + }
- + break;
- + case BEFORE:
- + {
- + alt1=8;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 6;
- +
- +
- + goto ruleexpressionEx;
- + }
- +
- + }
- + break;
- + case ENUMTAG:
- + {
- + alt1=9;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleexpressionEx;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // SMARTPL2SQL.g:64:4: ^( NOT a= expression )
- + {
- + MATCHT(NOT, &FOLLOW_NOT_in_expression101);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_expression107);
- + a=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + result= a->factory->newRaw(a->factory);
- + result->append8(result, "NOT(");
- + result->appendS(result, a);
- + result->append8(result, ")");
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // SMARTPL2SQL.g:71:4: ^( AND a= expression b= expression )
- + {
- + MATCHT(AND, &FOLLOW_AND_in_expression118);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_expression124);
- + a=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_expression130);
- + b=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + result= a->factory->newRaw(a->factory);
- + result->append8(result, "(");
- + result->appendS(result, a);
- + result->append8(result, " AND ");
- + result->appendS(result, b);
- + result->append8(result, ")");
- +
- + }
- +
- + }
- + break;
- + case 3:
- + // SMARTPL2SQL.g:80:4: ^( OR a= expression b= expression )
- + {
- + MATCHT(OR, &FOLLOW_OR_in_expression141);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_expression147);
- + a=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_expression_in_expression153);
- + b=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- +
- + MATCHT(ANTLR3_TOKEN_UP, NULL);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + result= a->factory->newRaw(a->factory);
- + result->append8(result, "(");
- + result->appendS(result, a);
- + result->append8(result, " OR ");
- + result->appendS(result, b);
- + result->append8(result, ")");
- +
- + }
- +
- + }
- + break;
- + case 4:
- + // SMARTPL2SQL.g:89:4: STRTAG INCLUDES STR
- + {
- + STRTAG3 = (pANTLR3_BASE_TREE) MATCHT(STRTAG, &FOLLOW_STRTAG_in_expression163);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_expression165);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + STR2 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expression167);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 val;
- + val = (STR2->getText(STR2))->toUTF8((STR2->getText(STR2)))->chars;
- + val++;
- + val[strlen((const char *)val) - 1] = '\0';
- +
- + result= (STR2->getText(STR2))->factory->newRaw((STR2->getText(STR2))->factory);
- + result->append8(result, "f.");
- + result->appendS(result, (STRTAG3->getText(STRTAG3))->toUTF8((STRTAG3->getText(STRTAG3))));
- + result->append8(result, " LIKE '%");
- + result->append8(result, sqlite3_mprintf("%q", (const char *)val));
- + result->append8(result, "%'");
- +
- + }
- +
- + }
- + break;
- + case 5:
- + // SMARTPL2SQL.g:103:4: STRTAG IS STR
- + {
- + STRTAG5 = (pANTLR3_BASE_TREE) MATCHT(STRTAG, &FOLLOW_STRTAG_in_expression176);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + MATCHT(IS, &FOLLOW_IS_in_expression178);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + STR4 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expression180);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 val;
- + val = (STR4->getText(STR4))->toUTF8((STR4->getText(STR4)))->chars;
- + val++;
- + val[strlen((const char *)val) - 1] = '\0';
- +
- + result= (STR4->getText(STR4))->factory->newRaw((STR4->getText(STR4))->factory);
- + result->append8(result, "f.");
- + result->appendS(result, (STRTAG5->getText(STRTAG5))->toUTF8((STRTAG5->getText(STRTAG5))));
- + result->append8(result, " LIKE '");
- + result->append8(result, sqlite3_mprintf("%q", (const char *)val));
- + result->append8(result, "'");
- +
- + }
- +
- + }
- + break;
- + case 6:
- + // SMARTPL2SQL.g:117:4: INTTAG INTBOOL INT
- + {
- + INTTAG6 = (pANTLR3_BASE_TREE) MATCHT(INTTAG, &FOLLOW_INTTAG_in_expression189);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + INTBOOL7 = (pANTLR3_BASE_TREE) MATCHT(INTBOOL, &FOLLOW_INTBOOL_in_expression191);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + INT8 = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_expression193);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + result= (INTTAG6->getText(INTTAG6))->factory->newRaw((INTTAG6->getText(INTTAG6))->factory);
- + result->append8(result, "f.");
- + result->appendS(result, (INTTAG6->getText(INTTAG6))->toUTF8((INTTAG6->getText(INTTAG6))));
- + result->append8(result, " ");
- + result->appendS(result, (INTBOOL7->getText(INTBOOL7))->toUTF8((INTBOOL7->getText(INTBOOL7))));
- + result->append8(result, " ");
- + result->appendS(result, (INT8->getText(INT8))->toUTF8((INT8->getText(INT8))));
- +
- + }
- +
- + }
- + break;
- + case 7:
- + // SMARTPL2SQL.g:127:4: DATETAG AFTER dateval
- + {
- + DATETAG10 = (pANTLR3_BASE_TREE) MATCHT(DATETAG, &FOLLOW_DATETAG_in_expression202);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + MATCHT(AFTER, &FOLLOW_AFTER_in_expression204);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_dateval_in_expression206);
- + dateval9=dateval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + char str[15];
- + sprintf(str, "%d", dateval9);
- +
- + result= (DATETAG10->getText(DATETAG10))->factory->newRaw((DATETAG10->getText(DATETAG10))->factory);
- + result->append8(result, "f.");
- + result->appendS(result, (DATETAG10->getText(DATETAG10))->toUTF8((DATETAG10->getText(DATETAG10))));
- + result->append8(result, " > ");
- + result->append8(result, str);
- +
- + }
- +
- + }
- + break;
- + case 8:
- + // SMARTPL2SQL.g:138:4: DATETAG BEFORE dateval
- + {
- + DATETAG12 = (pANTLR3_BASE_TREE) MATCHT(DATETAG, &FOLLOW_DATETAG_in_expression215);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + MATCHT(BEFORE, &FOLLOW_BEFORE_in_expression217);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_dateval_in_expression219);
- + dateval11=dateval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + char str[15];
- + sprintf(str, "%d", dateval11);
- +
- + result= (DATETAG12->getText(DATETAG12))->factory->newRaw((DATETAG12->getText(DATETAG12))->factory);
- + result->append8(result, "f.");
- + result->appendS(result, (DATETAG12->getText(DATETAG12))->toUTF8((DATETAG12->getText(DATETAG12))));
- + result->append8(result, " > ");
- + result->append8(result, str);
- +
- + }
- +
- + }
- + break;
- + case 9:
- + // SMARTPL2SQL.g:149:4: ENUMTAG IS ENUMVAL
- + {
- + ENUMTAG13 = (pANTLR3_BASE_TREE) MATCHT(ENUMTAG, &FOLLOW_ENUMTAG_in_expression228);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + MATCHT(IS, &FOLLOW_IS_in_expression230);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + ENUMVAL14 = (pANTLR3_BASE_TREE) MATCHT(ENUMVAL, &FOLLOW_ENUMVAL_in_expression232);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 tag;
- + pANTLR3_UINT8 val;
- + char str[20];
- +
- + sprintf(str, "1=1");
- +
- + tag = (ENUMTAG13->getText(ENUMTAG13))->chars;
- + val = (ENUMVAL14->getText(ENUMVAL14))->chars;
- + if (strcmp((char *)tag, "media_kind") == 0)
- + {
- + if (strcmp((char *)val, "music") == 0)
- + {
- + sprintf(str, "f.media_kind = %d", MEDIA_KIND_MUSIC);
- + }
- + else if (strcmp((char *)val, "movie") == 0)
- + {
- + sprintf(str, "f.media_kind = %d", MEDIA_KIND_MOVIE);
- + }
- + else if (strcmp((char *)val, "podcast") == 0)
- + {
- + sprintf(str, "f.media_kind = %d", MEDIA_KIND_PODCAST);
- + }
- + else if (strcmp((char *)val, "audiobook") == 0)
- + {
- + sprintf(str, "f.media_kind = %d", MEDIA_KIND_AUDIOBOOK);
- + }
- + else if (strcmp((char *)val, "tvshow") == 0)
- + {
- + sprintf(str, "f.media_kind = %d", MEDIA_KIND_TVSHOW);
- + }
- + }
- + else if (strcmp((char *)tag, "data_kind") == 0)
- + {
- + if (strcmp((char *)val, "file") == 0)
- + {
- + sprintf(str, "f.data_kind = %d", DATA_KIND_FILE);
- + }
- + else if (strcmp((char *)val, "url") == 0)
- + {
- + sprintf(str, "f.data_kind = %d", DATA_KIND_HTTP);
- + }
- + else if (strcmp((char *)val, "spotify") == 0)
- + {
- + sprintf(str, "f.data_kind = %d", DATA_KIND_SPOTIFY);
- + }
- + else if (strcmp((char *)val, "pipe") == 0)
- + {
- + sprintf(str, "f.data_kind = %d", DATA_KIND_PIPE);
- + }
- + }
- +
- + result= (ENUMTAG13->getText(ENUMTAG13))->factory->newRaw((ENUMTAG13->getText(ENUMTAG13))->factory);
- + result->append8(result, str);
- +
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexpressionEx; /* Prevent compiler warnings */
- + ruleexpressionEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return result;
- +}
- +/* $ANTLR end expression */
- +
- +/**
- + * $ANTLR start dateval
- + * SMARTPL2SQL.g:207:1: dateval returns [ int result ] : ( DATE | interval BEFORE DATE | interval AFTER DATE | interval AGO );
- + */
- +static int
- +dateval(pSMARTPL2SQL ctx)
- +{
- + int result = 0;
- +
- + pANTLR3_BASE_TREE DATE15;
- + pANTLR3_BASE_TREE DATE16;
- + pANTLR3_BASE_TREE DATE18;
- + int interval17;
- + #undef RETURN_TYPE_interval17
- + #define RETURN_TYPE_interval17 int
- +
- + int interval19;
- + #undef RETURN_TYPE_interval19
- + #define RETURN_TYPE_interval19 int
- +
- + int interval20;
- + #undef RETURN_TYPE_interval20
- + #define RETURN_TYPE_interval20 int
- +
- + /* Initialize rule variables
- + */
- +
- +
- + result= 0;
- + DATE15 = NULL;
- + DATE16 = NULL;
- + DATE18 = NULL;
- + interval17 = 0;
- + interval19 = 0;
- + interval20 = 0;
- +
- + {
- + {
- + // SMARTPL2SQL.g:209:2: ( DATE | interval BEFORE DATE | interval AFTER DATE | interval AGO )
- +
- + ANTLR3_UINT32 alt2;
- +
- + alt2=4;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + {
- + alt2=1;
- + }
- + break;
- + case INT:
- + {
- + switch ( LA(2) )
- + {
- + case DATINTERVAL:
- + {
- + switch ( LA(3) )
- + {
- + case AGO:
- + {
- + alt2=4;
- + }
- + break;
- + case BEFORE:
- + {
- + alt2=2;
- + }
- + break;
- + case AFTER:
- + {
- + alt2=3;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // SMARTPL2SQL.g:209:4: DATE
- + {
- + DATE15 = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateval257);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 datval;
- +
- + datval = (DATE15->getText(DATE15))->chars;
- +
- + if (strcmp((char *)datval, "today") == 0)
- + {
- + result= time(NULL);
- + }
- + else if (strcmp((char *)datval, "yesterday") == 0)
- + {
- + result= time(NULL) - 24 * 3600;
- + }
- + else if (strcmp((char *)datval, "last week") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 7;
- + }
- + else if (strcmp((char *)datval, "last month") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 30;
- + }
- + else if (strcmp((char *)datval, "last year") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 365;
- + }
- + else
- + {
- + struct tm tm;
- + char year[5];
- + char month[3];
- + char day[3];
- +
- + memset((void*)&tm,0,sizeof(tm));
- + memset(year, 0, sizeof(year));
- + memset(month, 0, sizeof(month));
- + memset(day, 0, sizeof(day));
- +
- + strncpy(year, (const char *)datval, 4);
- + strncpy(month, (const char *)datval + 5, 2);
- + strncpy(day, (const char *)datval + 8, 2);
- +
- + tm.tm_year = atoi(year) - 1900;
- + tm.tm_mon = atoi(month) - 1;
- + tm.tm_mday = atoi(day);
- +
- + result= mktime(&tm);
- + }
- +
- + }
- +
- + }
- + break;
- + case 2:
- + // SMARTPL2SQL.g:258:4: interval BEFORE DATE
- + {
- + FOLLOWPUSH(FOLLOW_interval_in_dateval266);
- + interval17=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateval268);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + DATE16 = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateval270);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 datval;
- +
- + datval = (DATE16->getText(DATE16))->chars;
- +
- + if (strcmp((char *)datval, "yesterday") == 0)
- + {
- + result= time(NULL) - 24 * 3600;
- + }
- + else if (strcmp((char *)datval, "last week") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 7;
- + }
- + else if (strcmp((char *)datval, "last month") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 30;
- + }
- + else if (strcmp((char *)datval, "last year") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 365;
- + }
- + else
- + {
- + result= time(NULL);
- + }
- +
- + result= result - interval17;
- +
- + }
- +
- + }
- + break;
- + case 3:
- + // SMARTPL2SQL.g:287:4: interval AFTER DATE
- + {
- + FOLLOWPUSH(FOLLOW_interval_in_dateval279);
- + interval19=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + MATCHT(AFTER, &FOLLOW_AFTER_in_dateval281);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + DATE18 = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateval283);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 datval;
- +
- + datval = (DATE18->getText(DATE18))->chars;
- +
- + if (strcmp((char *)datval, "yesterday") == 0)
- + {
- + result= time(NULL) - 24 * 3600;
- + }
- + else if (strcmp((char *)datval, "last week") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 7;
- + }
- + else if (strcmp((char *)datval, "last month") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 30;
- + }
- + else if (strcmp((char *)datval, "last year") == 0)
- + {
- + result= time(NULL) - 24 * 3600 * 365;
- + }
- + else
- + {
- + result= time(NULL);
- + }
- +
- + result= result + interval19;
- +
- + }
- +
- + }
- + break;
- + case 4:
- + // SMARTPL2SQL.g:316:4: interval AGO
- + {
- + FOLLOWPUSH(FOLLOW_interval_in_dateval292);
- + interval20=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + MATCHT(AGO, &FOLLOW_AGO_in_dateval294);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + {
- +
- + result= time(NULL) - interval20;
- +
- + }
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatevalEx; /* Prevent compiler warnings */
- + ruledatevalEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return result;
- +}
- +/* $ANTLR end dateval */
- +
- +/**
- + * $ANTLR start interval
- + * SMARTPL2SQL.g:322:1: interval returns [ int result ] : INT DATINTERVAL ;
- + */
- +static int
- +interval(pSMARTPL2SQL ctx)
- +{
- + int result = 0;
- +
- + pANTLR3_BASE_TREE INT21;
- + pANTLR3_BASE_TREE DATINTERVAL22;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + result= 0;
- + INT21 = NULL;
- + DATINTERVAL22 = NULL;
- +
- + {
- + // SMARTPL2SQL.g:324:2: ( INT DATINTERVAL )
- + // SMARTPL2SQL.g:324:4: INT DATINTERVAL
- + {
- + INT21 = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_interval318);
- + if (HASEXCEPTION())
- + {
- + goto ruleintervalEx;
- + }
- +
- + DATINTERVAL22 = (pANTLR3_BASE_TREE) MATCHT(DATINTERVAL, &FOLLOW_DATINTERVAL_in_interval320);
- + if (HASEXCEPTION())
- + {
- + goto ruleintervalEx;
- + }
- +
- + {
- +
- + pANTLR3_UINT8 interval;
- +
- + result= atoi((const char *)(INT21->getText(INT21))->chars);
- + interval = (DATINTERVAL22->getText(DATINTERVAL22))->chars;
- +
- + if (strcmp((char *)interval, "days") == 0)
- + {
- + result= result * 24 * 3600;
- + }
- + else if (strcmp((char *)interval, "weeks") == 0)
- + {
- + result= result * 24 * 3600 * 7;
- + }
- + else if (strcmp((char *)interval, "months") == 0)
- + {
- + result= result * 24 * 3600 * 30;
- + }
- + else if (strcmp((char *)interval, "weeks") == 0)
- + {
- + result= result * 24 * 3600 * 365;
- + }
- + else
- + {
- + result= 0;
- + }
- +
- + }
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintervalEx; /* Prevent compiler warnings */
- + ruleintervalEx: ;
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + }
- +
- +
- + return result;
- +}
- +/* $ANTLR end interval */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/SMARTPL2SQL.h b/src/pregen/SMARTPL2SQL.h
- new file mode 100644
- index 0000000..8e06de7
- --- /dev/null
- +++ b/src/pregen/SMARTPL2SQL.h
- @@ -0,0 +1,220 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL2SQL.g
- + * - On : 2016-01-01 12:23:44
- + * - for the tree parser : SMARTPL2SQLTreeParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The tree parser SMARTPL2SQL has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pSMARTPL2SQL, which is returned from a call to SMARTPL2SQLNew().
- + *
- + * The methods in pSMARTPL2SQL are as follows:
- + *
- + * - SMARTPL2SQL_playlist_return pSMARTPL2SQL->playlist(pSMARTPL2SQL)
- + * - pANTLR3_STRING pSMARTPL2SQL->expression(pSMARTPL2SQL)
- + * - int pSMARTPL2SQL->dateval(pSMARTPL2SQL)
- + * - int pSMARTPL2SQL->interval(pSMARTPL2SQL)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _SMARTPL2SQL_H
- +#define _SMARTPL2SQL_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct SMARTPL2SQL_Ctx_struct SMARTPL2SQL, * pSMARTPL2SQL;
- +
- +
- +
- + #include <stdio.h>
- + #include <stdlib.h>
- + #include <string.h>
- + #include <limits.h>
- + #include <errno.h>
- + #include <time.h>
- + #include <sqlite3.h>
- +
- + #include "logger.h"
- + #include "db.h"
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct SMARTPL2SQL_playlist_return_struct
- +{
- + pANTLR3_BASE_TREE start;
- + pANTLR3_BASE_TREE stop;
- + pANTLR3_STRING title;
- + pANTLR3_STRING query;
- +}
- + SMARTPL2SQL_playlist_return;
- +
- +
- +
- +/** Context tracking structure for SMARTPL2SQL
- + */
- +struct SMARTPL2SQL_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_TREE_PARSER pTreeParser;
- +
- +
- + SMARTPL2SQL_playlist_return (*playlist) (struct SMARTPL2SQL_Ctx_struct * ctx);
- + pANTLR3_STRING (*expression) (struct SMARTPL2SQL_Ctx_struct * ctx);
- + int (*dateval) (struct SMARTPL2SQL_Ctx_struct * ctx);
- + int (*interval) (struct SMARTPL2SQL_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct SMARTPL2SQL_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pSMARTPL2SQL SMARTPL2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
- +ANTLR3_API pSMARTPL2SQL SMARTPL2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the tree parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define INTBOOL 14
- +#define STRTAG 10
- +#define AGO 22
- +#define WHITESPACE 29
- +#define GREATEREQUAL 25
- +#define BEFORE 18
- +#define DATETAG 16
- +#define INT 15
- +#define NOT 7
- +#define AFTER 17
- +#define AND 6
- +#define EOF -1
- +#define INCLUDES 11
- +#define STR 4
- +#define T__30 30
- +#define T__31 31
- +#define GREATER 24
- +#define LPAR 8
- +#define ENUMTAG 19
- +#define IS 12
- +#define ENUMVAL 20
- +#define EQUAL 28
- +#define OR 5
- +#define LESS 26
- +#define RPAR 9
- +#define DATE 21
- +#define LESSEQUAL 27
- +#define INTTAG 13
- +#define DATINTERVAL 23
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for SMARTPL2SQL
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/SMARTPL2SQL.u b/src/pregen/SMARTPL2SQL.u
- new file mode 100644
- index 0000000..85567d1
- --- /dev/null
- +++ b/src/pregen/SMARTPL2SQL.u
- @@ -0,0 +1,5 @@
- +SMARTPL2SQL.g: SMARTPL.tokens
- +SMARTPL2SQL.c : SMARTPL2SQL.g
- +./SMARTPL2SQL.tokens : SMARTPL2SQL.g
- +SMARTPL2SQL.h : SMARTPL2SQL.g
- +ANTLR_PRODUCTS += SMARTPL2SQL.c ./SMARTPL2SQL.tokens SMARTPL2SQL.h
- \ No newline at end of file
- diff --git a/src/pregen/SMARTPLLexer.c b/src/pregen/SMARTPLLexer.c
- new file mode 100644
- index 0000000..91d6e99
- --- /dev/null
- +++ b/src/pregen/SMARTPLLexer.c
- @@ -0,0 +1,4168 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL.g
- + * - On : 2016-01-01 12:23:40
- + * - for the lexer : SMARTPLLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "SMARTPLLexer.h"
- +/* ----------------------------------------- */
- +
- +
- +/** String literals used by SMARTPLLexer that we must do things like MATCHS() with.
- + * C will normally just lay down 8 bit characters, and you can use L"xxx" to
- + * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so
- + * we perform this little trick of defining the literals as arrays of UINT32
- + * and passing in the address of these.
- + */
- +static ANTLR3_UCHAR lit_1[] = { 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_2[] = { 0x61, 0x6C, 0x62, 0x75, 0x6D, 0x5F, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_3[] = { 0x61, 0x6C, 0x62, 0x75, 0x6D, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_4[] = { 0x74, 0x69, 0x74, 0x6C, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_5[] = { 0x67, 0x65, 0x6E, 0x72, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_6[] = { 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x73, 0x65, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_7[] = { 0x70, 0x61, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_8[] = { 0x74, 0x79, 0x70, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_9[] = { 0x67, 0x72, 0x6F, 0x75, 0x70, 0x69, 0x6E, 0x67, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_10[] = { 0x70, 0x6C, 0x61, 0x79, 0x5F, 0x63, 0x6F, 0x75, 0x6E, 0x74, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_11[] = { 0x72, 0x61, 0x74, 0x69, 0x6E, 0x67, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_12[] = { 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_13[] = { 0x63, 0x6F, 0x6D, 0x70, 0x69, 0x6C, 0x61, 0x74, 0x69, 0x6F, 0x6E, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_14[] = { 0x74, 0x69, 0x6D, 0x65, 0x5F, 0x61, 0x64, 0x64, 0x65, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_15[] = { 0x74, 0x69, 0x6D, 0x65, 0x5F, 0x70, 0x6C, 0x61, 0x79, 0x65, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_16[] = { 0x64, 0x61, 0x74, 0x61, 0x5F, 0x6B, 0x69, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_17[] = { 0x6D, 0x65, 0x64, 0x69, 0x61, 0x5F, 0x6B, 0x69, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_18[] = { 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_19[] = { 0x69, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_20[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_21[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_22[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_23[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_24[] = { 0x61, 0x67, 0x6F, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_25[] = { 0x41, 0x4E, 0x44, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_26[] = { 0x61, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_27[] = { 0x4F, 0x52, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_28[] = { 0x6F, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_29[] = { 0x4E, 0x4F, 0x54, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_30[] = { 0x6E, 0x6F, 0x74, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_31[] = { 0x74, 0x6F, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_32[] = { 0x79, 0x65, 0x73, 0x74, 0x65, 0x72, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_33[] = { 0x6C, 0x61, 0x73, 0x74, 0x20, 0x77, 0x65, 0x65, 0x6B, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_34[] = { 0x6C, 0x61, 0x73, 0x74, 0x20, 0x6D, 0x6F, 0x6E, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_35[] = { 0x6C, 0x61, 0x73, 0x74, 0x20, 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_36[] = { 0x64, 0x61, 0x79, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_37[] = { 0x77, 0x65, 0x65, 0x6B, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_38[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_39[] = { 0x79, 0x65, 0x61, 0x72, 0x73, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_40[] = { 0x6D, 0x75, 0x73, 0x69, 0x63, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_41[] = { 0x6D, 0x6F, 0x76, 0x69, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_42[] = { 0x70, 0x6F, 0x64, 0x63, 0x61, 0x73, 0x74, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_43[] = { 0x61, 0x75, 0x64, 0x69, 0x6F, 0x62, 0x6F, 0x6F, 0x6B, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_44[] = { 0x74, 0x76, 0x73, 0x68, 0x6F, 0x77, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_45[] = { 0x66, 0x69, 0x6C, 0x65, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_46[] = { 0x75, 0x72, 0x6C, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_47[] = { 0x73, 0x70, 0x6F, 0x74, 0x69, 0x66, 0x79, ANTLR3_STRING_TERMINATOR};
- +static ANTLR3_UCHAR lit_48[] = { 0x70, 0x69, 0x70, 0x65, ANTLR3_STRING_TERMINATOR};
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pSMARTPLLexer_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pSMARTPLLexer_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pSMARTPLLexer_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pSMARTPLLexer_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +
- +/* Macros for accessing things in a lexer
- + */
- +#undef LEXER
- +#undef RECOGNIZER
- +#undef RULEMEMO
- +#undef GETCHARINDEX
- +#undef GETLINE
- +#undef GETCHARPOSITIONINLINE
- +#undef EMIT
- +#undef EMITNEW
- +#undef MATCHC
- +#undef MATCHS
- +#undef MATCHRANGE
- +#undef LTOKEN
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef INPUT
- +#undef STRSTREAM
- +#undef LA
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef LRECOVER
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef BACKTRACKING
- +#undef MATCHANY
- +#undef MEMOIZE
- +#undef HAVEPARSEDRULE
- +#undef GETTEXT
- +#undef INDEX
- +#undef SEEK
- +#undef PUSHSTREAM
- +#undef POPSTREAM
- +#undef SETTEXT
- +#undef SETTEXT8
- +
- +#define LEXER ctx->pLexer
- +#define RECOGNIZER LEXER->rec
- +#define LEXSTATE RECOGNIZER->state
- +#define TOKSOURCE LEXSTATE->tokSource
- +#define GETCHARINDEX() LEXER->getCharIndex(LEXER)
- +#define GETLINE() LEXER->getLine(LEXER)
- +#define GETTEXT() LEXER->getText(LEXER)
- +#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
- +#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)
- +#define EMITNEW(t) LEXER->emitNew(LEXER, t)
- +#define MATCHC(c) LEXER->matchc(LEXER, c)
- +#define MATCHS(s) LEXER->matchs(LEXER, s)
- +#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)
- +#define MATCHANY() LEXER->matchAny(LEXER)
- +#define LTOKEN LEXSTATE->token
- +#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)
- +#define BACKTRACKING LEXSTATE->backtracking
- +#define FAILEDFLAG LEXSTATE->failed
- +#define INPUT LEXER->input
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)
- +#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION LEXSTATE->exception
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define LRECOVER() LEXER->recover(LEXER)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)
- +#define POPSTREAM() LEXER->popCharStream(LEXER)
- +#define SETTEXT(str) LEXSTATE->text = str
- +#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)
- +#define USER1 LEXSTATE->user1
- +#define USER2 LEXSTATE->user2
- +#define USER3 LEXSTATE->user3
- +#define CUSTOM LEXSTATE->custom
- +#define RULEMEMO LEXSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +/* If we have been told we can rely on the standard 8 bit or 16 bit input
- + * stream, then we can define our macros to use the direct pointers
- + * in the input object, which is much faster than indirect calls. This
- + * is really only significant to lexers with a lot of fragment rules (which
- + * do not place LA(1) in a temporary at the moment) and even then
- + * only if there is a lot of input (order of say 1M or so).
- + */
- +#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
- +
- +# ifdef ANTLR3_INLINE_INPUT_ASCII
- +
- +/* 8 bit "ASCII" (actually any 8 bit character set) */
- +
- +# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT8)(INPUT->data))
- +
- +# else
- +
- +# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar))
- +# define DATAP ((pANTLR3_UINT16)(INPUT->data))
- +
- +# endif
- +
- +# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
- +# define CONSUME() \
- +{ \
- + if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \
- + { \
- + INPUT->charPositionInLine++; \
- + if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \
- + { \
- + INPUT->line++; \
- + INPUT->charPositionInLine = 0; \
- + INPUT->currentLine = (void *)(NEXTCHAR + 1); \
- + } \
- + INPUT->nextChar = (void *)(NEXTCHAR + 1); \
- + } \
- +}
- +
- +#else
- +
- +// Pick up the input character by calling the input stream implementation.
- +//
- +#define CONSUME() INPUT->istream->consume(INPUT->istream)
- +#define LA(n) INPUT->istream->_LA(INPUT->istream, n)
- +
- +#endif
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +/* Forward declare the locally static matching functions we have generated and any predicate functions.
- + */
- +static ANTLR3_INLINE void mT__30 (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mT__31 (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mSTRTAG (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mINTTAG (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mDATETAG (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mENUMTAG (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mINCLUDES (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mIS (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mINTBOOL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mGREATER (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mGREATEREQUAL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mLESS (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mLESSEQUAL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mEQUAL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mAFTER (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mBEFORE (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mAGO (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mAND (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mOR (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mNOT (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mLPAR (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mRPAR (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mDATE (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mDATINTERVAL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mENUMVAL (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mSTR (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mINT (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mWHITESPACE (pSMARTPLLexer ctx);
- +static ANTLR3_INLINE void mTokens (pSMARTPLLexer ctx);
- +static void SMARTPLLexerFree(pSMARTPLLexer ctx);
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +
- +
- +
- +static void
- +SMARTPLLexerFree (pSMARTPLLexer ctx)
- +{
- + LEXER->free(LEXER);
- +
- + ANTLR3_FREE(ctx);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "SMARTPL.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +
- +/** \brief Create a new lexer called SMARTPLLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \return
- + * - Success pSMARTPLLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pSMARTPLLexer SMARTPLLexerNew
- +(pANTLR3_INPUT_STREAM instream)
- +{
- + // See if we can create a new lexer with the standard constructor
- + //
- + return SMARTPLLexerNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new lexer called SMARTPLLexer
- + *
- + * \param[in] instream Pointer to an initialized input stream
- + * \param[state] state Previously created shared recognizer stat
- + * \return
- + * - Success pSMARTPLLexer initialized for the lex start
- + * - Fail NULL
- + */
- +ANTLR3_API pSMARTPLLexer SMARTPLLexerNewSSD
- +(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pSMARTPLLexer ctx; // Context structure we will build and return
- +
- + ctx = (pSMARTPLLexer) ANTLR3_CALLOC(1, sizeof(SMARTPLLexer));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for lexer context
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * in base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 lexer function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in SMARTPLLexer.h here so you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base lexer, using the supplied input stream
- + */
- + ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
- +
- + /* Check that we allocated the memory correctly
- + */
- + if (ctx->pLexer == NULL)
- + {
- + ANTLR3_FREE(ctx);
- + return NULL;
- + }
- + /* Install the implementation of our SMARTPLLexer interface
- + */
- + ctx->mT__30 = mT__30;
- + ctx->mT__31 = mT__31;
- + ctx->mSTRTAG = mSTRTAG;
- + ctx->mINTTAG = mINTTAG;
- + ctx->mDATETAG = mDATETAG;
- + ctx->mENUMTAG = mENUMTAG;
- + ctx->mINCLUDES = mINCLUDES;
- + ctx->mIS = mIS;
- + ctx->mINTBOOL = mINTBOOL;
- + ctx->mGREATER = mGREATER;
- + ctx->mGREATEREQUAL = mGREATEREQUAL;
- + ctx->mLESS = mLESS;
- + ctx->mLESSEQUAL = mLESSEQUAL;
- + ctx->mEQUAL = mEQUAL;
- + ctx->mAFTER = mAFTER;
- + ctx->mBEFORE = mBEFORE;
- + ctx->mAGO = mAGO;
- + ctx->mAND = mAND;
- + ctx->mOR = mOR;
- + ctx->mNOT = mNOT;
- + ctx->mLPAR = mLPAR;
- + ctx->mRPAR = mRPAR;
- + ctx->mDATE = mDATE;
- + ctx->mDATINTERVAL = mDATINTERVAL;
- + ctx->mENUMVAL = mENUMVAL;
- + ctx->mSTR = mSTR;
- + ctx->mINT = mINT;
- + ctx->mWHITESPACE = mWHITESPACE;
- + ctx->mTokens = mTokens;
- +
- + /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
- + * it will call mTokens() in this generated code, and will pass it the ctx
- + * pointer of this lexer, not the context of the base lexer, so store that now.
- + */
- + ctx->pLexer->ctx = ctx;
- +
- + /**Install the token matching function
- + */
- + ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
- +
- + ctx->getGrammarFileName = getGrammarFileName;
- + ctx->free = SMARTPLLexerFree;
- +
- +
- +
- +
- +
- + /* Return the newly built lexer to the caller
- + */
- + return ctx;
- +}
- +
- +
- +/* =========================================================================
- + * Functions to match the lexer grammar defined tokens from the input stream
- + */
- +
- +// Comes from: 7:7: ( '{' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start T__30
- + *
- + * Looks to match the characters the constitute the token T__30
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mT__30(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = T__30;
- +
- +
- + // SMARTPL.g:7:7: ( '{' )
- + // SMARTPL.g:7:9: '{'
- + {
- + MATCHC('{');
- + if (HASEXCEPTION())
- + {
- + goto ruleT__30Ex;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleT__30Ex; /* Prevent compiler warnings */
- + ruleT__30Ex: ;
- +
- +}
- +// $ANTLR end T__30
- +
- +// Comes from: 8:7: ( '}' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start T__31
- + *
- + * Looks to match the characters the constitute the token T__31
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mT__31(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = T__31;
- +
- +
- + // SMARTPL.g:8:7: ( '}' )
- + // SMARTPL.g:8:9: '}'
- + {
- + MATCHC('}');
- + if (HASEXCEPTION())
- + {
- + goto ruleT__31Ex;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleT__31Ex; /* Prevent compiler warnings */
- + ruleT__31Ex: ;
- +
- +}
- +// $ANTLR end T__31
- +
- +// Comes from: 56:9: ( 'artist' | 'album_artist' | 'album' | 'title' | 'genre' | 'composer' | 'path' | 'type' | 'grouping' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start STRTAG
- + *
- + * Looks to match the characters the constitute the token STRTAG
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mSTRTAG(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = STRTAG;
- +
- +
- + {
- + // SMARTPL.g:56:9: ( 'artist' | 'album_artist' | 'album' | 'title' | 'genre' | 'composer' | 'path' | 'type' | 'grouping' )
- +
- + ANTLR3_UINT32 alt1;
- +
- + alt1=9;
- +
- + switch ( LA(1) )
- + {
- + case 'a':
- + {
- + switch ( LA(2) )
- + {
- + case 'r':
- + {
- + alt1=1;
- + }
- + break;
- + case 'l':
- + {
- + switch ( LA(3) )
- + {
- + case 'b':
- + {
- + switch ( LA(4) )
- + {
- + case 'u':
- + {
- + switch ( LA(5) )
- + {
- + case 'm':
- + {
- + switch ( LA(6) )
- + {
- + case '_':
- + {
- + alt1=2;
- + }
- + break;
- +
- + default:
- + alt1=3;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 13;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 12;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 7;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- + case 't':
- + {
- + switch ( LA(2) )
- + {
- + case 'i':
- + {
- + alt1=4;
- + }
- + break;
- + case 'y':
- + {
- + alt1=8;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- + case 'g':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + alt1=5;
- + }
- + break;
- + case 'r':
- + {
- + alt1=9;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + }
- + break;
- + case 'c':
- + {
- + alt1=6;
- + }
- + break;
- + case 'p':
- + {
- + alt1=7;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 1;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleSTRTAGEx;
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // SMARTPL.g:56:11: 'artist'
- + {
- + MATCHS(lit_1);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:57:6: 'album_artist'
- + {
- + MATCHS(lit_2);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:58:6: 'album'
- + {
- + MATCHS(lit_3);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:59:6: 'title'
- + {
- + MATCHS(lit_4);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:60:6: 'genre'
- + {
- + MATCHS(lit_5);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 6:
- + // SMARTPL.g:61:6: 'composer'
- + {
- + MATCHS(lit_6);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 7:
- + // SMARTPL.g:62:6: 'path'
- + {
- + MATCHS(lit_7);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 8:
- + // SMARTPL.g:63:6: 'type'
- + {
- + MATCHS(lit_8);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 9:
- + // SMARTPL.g:64:6: 'grouping'
- + {
- + MATCHS(lit_9);
- + if (HASEXCEPTION())
- + {
- + goto ruleSTRTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleSTRTAGEx; /* Prevent compiler warnings */
- + ruleSTRTAGEx: ;
- +
- +}
- +// $ANTLR end STRTAG
- +
- +// Comes from: 67:9: ( 'play_count' | 'rating' | 'year' | 'compilation' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INTTAG
- + *
- + * Looks to match the characters the constitute the token INTTAG
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINTTAG(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INTTAG;
- +
- +
- + {
- + // SMARTPL.g:67:9: ( 'play_count' | 'rating' | 'year' | 'compilation' )
- +
- + ANTLR3_UINT32 alt2;
- +
- + alt2=4;
- +
- + switch ( LA(1) )
- + {
- + case 'p':
- + {
- + alt2=1;
- + }
- + break;
- + case 'r':
- + {
- + alt2=2;
- + }
- + break;
- + case 'y':
- + {
- + alt2=3;
- + }
- + break;
- + case 'c':
- + {
- + alt2=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 2;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleINTTAGEx;
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // SMARTPL.g:67:11: 'play_count'
- + {
- + MATCHS(lit_10);
- + if (HASEXCEPTION())
- + {
- + goto ruleINTTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:68:6: 'rating'
- + {
- + MATCHS(lit_11);
- + if (HASEXCEPTION())
- + {
- + goto ruleINTTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:69:6: 'year'
- + {
- + MATCHS(lit_12);
- + if (HASEXCEPTION())
- + {
- + goto ruleINTTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:70:6: 'compilation'
- + {
- + MATCHS(lit_13);
- + if (HASEXCEPTION())
- + {
- + goto ruleINTTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINTTAGEx; /* Prevent compiler warnings */
- + ruleINTTAGEx: ;
- +
- +}
- +// $ANTLR end INTTAG
- +
- +// Comes from: 73:10: ( 'time_added' | 'time_played' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DATETAG
- + *
- + * Looks to match the characters the constitute the token DATETAG
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDATETAG(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = DATETAG;
- +
- +
- + {
- + // SMARTPL.g:73:10: ( 'time_added' | 'time_played' )
- +
- + ANTLR3_UINT32 alt3;
- +
- + alt3=2;
- +
- + switch ( LA(1) )
- + {
- + case 't':
- + {
- + switch ( LA(2) )
- + {
- + case 'i':
- + {
- + switch ( LA(3) )
- + {
- + case 'm':
- + {
- + switch ( LA(4) )
- + {
- + case 'e':
- + {
- + switch ( LA(5) )
- + {
- + case '_':
- + {
- + switch ( LA(6) )
- + {
- + case 'a':
- + {
- + alt3=1;
- + }
- + break;
- + case 'p':
- + {
- + alt3=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 5;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDATETAGEx;
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // SMARTPL.g:73:12: 'time_added'
- + {
- + MATCHS(lit_14);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATETAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:74:6: 'time_played'
- + {
- + MATCHS(lit_15);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATETAGEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDATETAGEx; /* Prevent compiler warnings */
- + ruleDATETAGEx: ;
- +
- +}
- +// $ANTLR end DATETAG
- +
- +// Comes from: 77:10: ( 'data_kind' | 'media_kind' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start ENUMTAG
- + *
- + * Looks to match the characters the constitute the token ENUMTAG
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mENUMTAG(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = ENUMTAG;
- +
- +
- + {
- + // SMARTPL.g:77:10: ( 'data_kind' | 'media_kind' )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=2;
- +
- + switch ( LA(1) )
- + {
- + case 'd':
- + {
- + alt4=1;
- + }
- + break;
- + case 'm':
- + {
- + alt4=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleENUMTAGEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // SMARTPL.g:77:12: 'data_kind'
- + {
- + MATCHS(lit_16);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:78:6: 'media_kind'
- + {
- + MATCHS(lit_17);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMTAGEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleENUMTAGEx; /* Prevent compiler warnings */
- + ruleENUMTAGEx: ;
- +
- +}
- +// $ANTLR end ENUMTAG
- +
- +// Comes from: 81:10: ( 'includes' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INCLUDES
- + *
- + * Looks to match the characters the constitute the token INCLUDES
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINCLUDES(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INCLUDES;
- +
- +
- + // SMARTPL.g:81:10: ( 'includes' )
- + // SMARTPL.g:81:12: 'includes'
- + {
- + MATCHS(lit_18);
- + if (HASEXCEPTION())
- + {
- + goto ruleINCLUDESEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINCLUDESEx; /* Prevent compiler warnings */
- + ruleINCLUDESEx: ;
- +
- +}
- +// $ANTLR end INCLUDES
- +
- +// Comes from: 84:6: ( 'is' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start IS
- + *
- + * Looks to match the characters the constitute the token IS
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mIS(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = IS;
- +
- +
- + // SMARTPL.g:84:6: ( 'is' )
- + // SMARTPL.g:84:8: 'is'
- + {
- + MATCHS(lit_19);
- + if (HASEXCEPTION())
- + {
- + goto ruleISEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleISEx; /* Prevent compiler warnings */
- + ruleISEx: ;
- +
- +}
- +// $ANTLR end IS
- +
- +// Comes from: 87:10: ( ( GREATER | GREATEREQUAL | LESS | LESSEQUAL | EQUAL ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INTBOOL
- + *
- + * Looks to match the characters the constitute the token INTBOOL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINTBOOL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INTBOOL;
- +
- +
- + // SMARTPL.g:87:10: ( ( GREATER | GREATEREQUAL | LESS | LESSEQUAL | EQUAL ) )
- + // SMARTPL.g:87:12: ( GREATER | GREATEREQUAL | LESS | LESSEQUAL | EQUAL )
- + {
- +
- + // SMARTPL.g:87:12: ( GREATER | GREATEREQUAL | LESS | LESSEQUAL | EQUAL )
- + {
- + int alt5=5;
- + switch ( LA(1) )
- + {
- + case '>':
- + {
- + switch ( LA(2) )
- + {
- + case '=':
- + {
- + alt5=2;
- + }
- + break;
- +
- + default:
- + alt5=1;}
- +
- + }
- + break;
- + case '<':
- + {
- + switch ( LA(2) )
- + {
- + case '=':
- + {
- + alt5=4;
- + }
- + break;
- +
- + default:
- + alt5=3;}
- +
- + }
- + break;
- + case '=':
- + {
- + alt5=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleINTBOOLEx;
- + }
- +
- + switch (alt5)
- + {
- + case 1:
- + // SMARTPL.g:87:13: GREATER
- + {
- + /* 87:13: GREATER */
- + mGREATER(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTBOOLEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:87:21: GREATEREQUAL
- + {
- + /* 87:21: GREATEREQUAL */
- + mGREATEREQUAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTBOOLEx;
- + }
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:87:34: LESS
- + {
- + /* 87:34: LESS */
- + mLESS(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTBOOLEx;
- + }
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:87:39: LESSEQUAL
- + {
- + /* 87:39: LESSEQUAL */
- + mLESSEQUAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTBOOLEx;
- + }
- +
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:87:49: EQUAL
- + {
- + /* 87:49: EQUAL */
- + mEQUAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleINTBOOLEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINTBOOLEx; /* Prevent compiler warnings */
- + ruleINTBOOLEx: ;
- +
- +}
- +// $ANTLR end INTBOOL
- +
- +// Comes from: 91:10: ( '>' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start GREATER
- + *
- + * Looks to match the characters the constitute the token GREATER
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mGREATER(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // SMARTPL.g:91:10: ( '>' )
- + // SMARTPL.g:91:12: '>'
- + {
- + MATCHC('>');
- + if (HASEXCEPTION())
- + {
- + goto ruleGREATEREx;
- + }
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleGREATEREx; /* Prevent compiler warnings */
- + ruleGREATEREx: ;
- +
- +}
- +// $ANTLR end GREATER
- +
- +// Comes from: 95:13: ( '>=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start GREATEREQUAL
- + *
- + * Looks to match the characters the constitute the token GREATEREQUAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mGREATEREQUAL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // SMARTPL.g:95:13: ( '>=' )
- + // SMARTPL.g:95:15: '>='
- + {
- + MATCHS(lit_20);
- + if (HASEXCEPTION())
- + {
- + goto ruleGREATEREQUALEx;
- + }
- +
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleGREATEREQUALEx; /* Prevent compiler warnings */
- + ruleGREATEREQUALEx: ;
- +
- +}
- +// $ANTLR end GREATEREQUAL
- +
- +// Comes from: 99:7: ( '<' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LESS
- + *
- + * Looks to match the characters the constitute the token LESS
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLESS(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // SMARTPL.g:99:7: ( '<' )
- + // SMARTPL.g:99:9: '<'
- + {
- + MATCHC('<');
- + if (HASEXCEPTION())
- + {
- + goto ruleLESSEx;
- + }
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLESSEx; /* Prevent compiler warnings */
- + ruleLESSEx: ;
- +
- +}
- +// $ANTLR end LESS
- +
- +// Comes from: 103:11: ( '<=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LESSEQUAL
- + *
- + * Looks to match the characters the constitute the token LESSEQUAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLESSEQUAL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // SMARTPL.g:103:11: ( '<=' )
- + // SMARTPL.g:103:13: '<='
- + {
- + MATCHS(lit_21);
- + if (HASEXCEPTION())
- + {
- + goto ruleLESSEQUALEx;
- + }
- +
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLESSEQUALEx; /* Prevent compiler warnings */
- + ruleLESSEQUALEx: ;
- +
- +}
- +// $ANTLR end LESSEQUAL
- +
- +// Comes from: 107:8: ( '=' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start EQUAL
- + *
- + * Looks to match the characters the constitute the token EQUAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mEQUAL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- +
- + // SMARTPL.g:107:8: ( '=' )
- + // SMARTPL.g:107:10: '='
- + {
- + MATCHC('=');
- + if (HASEXCEPTION())
- + {
- + goto ruleEQUALEx;
- + }
- +
- +
- + }
- +
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleEQUALEx; /* Prevent compiler warnings */
- + ruleEQUALEx: ;
- +
- +}
- +// $ANTLR end EQUAL
- +
- +// Comes from: 110:8: ( 'after' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start AFTER
- + *
- + * Looks to match the characters the constitute the token AFTER
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mAFTER(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = AFTER;
- +
- +
- + // SMARTPL.g:110:8: ( 'after' )
- + // SMARTPL.g:110:10: 'after'
- + {
- + MATCHS(lit_22);
- + if (HASEXCEPTION())
- + {
- + goto ruleAFTEREx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleAFTEREx; /* Prevent compiler warnings */
- + ruleAFTEREx: ;
- +
- +}
- +// $ANTLR end AFTER
- +
- +// Comes from: 113:9: ( 'before' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start BEFORE
- + *
- + * Looks to match the characters the constitute the token BEFORE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mBEFORE(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = BEFORE;
- +
- +
- + // SMARTPL.g:113:9: ( 'before' )
- + // SMARTPL.g:113:11: 'before'
- + {
- + MATCHS(lit_23);
- + if (HASEXCEPTION())
- + {
- + goto ruleBEFOREEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleBEFOREEx; /* Prevent compiler warnings */
- + ruleBEFOREEx: ;
- +
- +}
- +// $ANTLR end BEFORE
- +
- +// Comes from: 116:7: ( 'ago' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start AGO
- + *
- + * Looks to match the characters the constitute the token AGO
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mAGO(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = AGO;
- +
- +
- + // SMARTPL.g:116:7: ( 'ago' )
- + // SMARTPL.g:116:9: 'ago'
- + {
- + MATCHS(lit_24);
- + if (HASEXCEPTION())
- + {
- + goto ruleAGOEx;
- + }
- +
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleAGOEx; /* Prevent compiler warnings */
- + ruleAGOEx: ;
- +
- +}
- +// $ANTLR end AGO
- +
- +// Comes from: 119:7: ( 'AND' | 'and' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start AND
- + *
- + * Looks to match the characters the constitute the token AND
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mAND(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = AND;
- +
- +
- + {
- + // SMARTPL.g:119:7: ( 'AND' | 'and' )
- +
- + ANTLR3_UINT32 alt6;
- +
- + alt6=2;
- +
- + switch ( LA(1) )
- + {
- + case 'A':
- + {
- + alt6=1;
- + }
- + break;
- + case 'a':
- + {
- + alt6=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 6;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleANDEx;
- + }
- +
- + switch (alt6)
- + {
- + case 1:
- + // SMARTPL.g:119:9: 'AND'
- + {
- + MATCHS(lit_25);
- + if (HASEXCEPTION())
- + {
- + goto ruleANDEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:120:6: 'and'
- + {
- + MATCHS(lit_26);
- + if (HASEXCEPTION())
- + {
- + goto ruleANDEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleANDEx; /* Prevent compiler warnings */
- + ruleANDEx: ;
- +
- +}
- +// $ANTLR end AND
- +
- +// Comes from: 123:6: ( 'OR' | 'or' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start OR
- + *
- + * Looks to match the characters the constitute the token OR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mOR(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = OR;
- +
- +
- + {
- + // SMARTPL.g:123:6: ( 'OR' | 'or' )
- +
- + ANTLR3_UINT32 alt7;
- +
- + alt7=2;
- +
- + switch ( LA(1) )
- + {
- + case 'O':
- + {
- + alt7=1;
- + }
- + break;
- + case 'o':
- + {
- + alt7=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 7;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleOREx;
- + }
- +
- + switch (alt7)
- + {
- + case 1:
- + // SMARTPL.g:123:8: 'OR'
- + {
- + MATCHS(lit_27);
- + if (HASEXCEPTION())
- + {
- + goto ruleOREx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:124:6: 'or'
- + {
- + MATCHS(lit_28);
- + if (HASEXCEPTION())
- + {
- + goto ruleOREx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleOREx; /* Prevent compiler warnings */
- + ruleOREx: ;
- +
- +}
- +// $ANTLR end OR
- +
- +// Comes from: 127:7: ( 'NOT' | 'not' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start NOT
- + *
- + * Looks to match the characters the constitute the token NOT
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mNOT(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = NOT;
- +
- +
- + {
- + // SMARTPL.g:127:7: ( 'NOT' | 'not' )
- +
- + ANTLR3_UINT32 alt8;
- +
- + alt8=2;
- +
- + switch ( LA(1) )
- + {
- + case 'N':
- + {
- + alt8=1;
- + }
- + break;
- + case 'n':
- + {
- + alt8=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 8;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleNOTEx;
- + }
- +
- + switch (alt8)
- + {
- + case 1:
- + // SMARTPL.g:127:9: 'NOT'
- + {
- + MATCHS(lit_29);
- + if (HASEXCEPTION())
- + {
- + goto ruleNOTEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:128:6: 'not'
- + {
- + MATCHS(lit_30);
- + if (HASEXCEPTION())
- + {
- + goto ruleNOTEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleNOTEx; /* Prevent compiler warnings */
- + ruleNOTEx: ;
- +
- +}
- +// $ANTLR end NOT
- +
- +// Comes from: 131:7: ( '(' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start LPAR
- + *
- + * Looks to match the characters the constitute the token LPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mLPAR(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = LPAR;
- +
- +
- + // SMARTPL.g:131:7: ( '(' )
- + // SMARTPL.g:131:9: '('
- + {
- + MATCHC('(');
- + if (HASEXCEPTION())
- + {
- + goto ruleLPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleLPAREx; /* Prevent compiler warnings */
- + ruleLPAREx: ;
- +
- +}
- +// $ANTLR end LPAR
- +
- +// Comes from: 134:7: ( ')' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start RPAR
- + *
- + * Looks to match the characters the constitute the token RPAR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mRPAR(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = RPAR;
- +
- +
- + // SMARTPL.g:134:7: ( ')' )
- + // SMARTPL.g:134:9: ')'
- + {
- + MATCHC(')');
- + if (HASEXCEPTION())
- + {
- + goto ruleRPAREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleRPAREx; /* Prevent compiler warnings */
- + ruleRPAREx: ;
- +
- +}
- +// $ANTLR end RPAR
- +
- +// Comes from: 137:7: ( ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) '-' ( '0' .. '1' ) ( '0' .. '9' ) '-' ( '0' .. '3' ) ( '0' .. '9' ) | 'today' | 'yesterday' | 'last week' | 'last month' | 'last year' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DATE
- + *
- + * Looks to match the characters the constitute the token DATE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDATE(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = DATE;
- +
- +
- + {
- + // SMARTPL.g:137:7: ( ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) '-' ( '0' .. '1' ) ( '0' .. '9' ) '-' ( '0' .. '3' ) ( '0' .. '9' ) | 'today' | 'yesterday' | 'last week' | 'last month' | 'last year' )
- +
- + ANTLR3_UINT32 alt9;
- +
- + alt9=6;
- +
- + switch ( LA(1) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + alt9=1;
- + }
- + break;
- + case 't':
- + {
- + alt9=2;
- + }
- + break;
- + case 'y':
- + {
- + alt9=3;
- + }
- + break;
- + case 'l':
- + {
- + switch ( LA(2) )
- + {
- + case 'a':
- + {
- + switch ( LA(3) )
- + {
- + case 's':
- + {
- + switch ( LA(4) )
- + {
- + case 't':
- + {
- + switch ( LA(5) )
- + {
- + case ' ':
- + {
- + switch ( LA(6) )
- + {
- + case 'w':
- + {
- + alt9=4;
- + }
- + break;
- + case 'm':
- + {
- + alt9=5;
- + }
- + break;
- + case 'y':
- + {
- + alt9=6;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 8;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 7;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 6;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 5;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 9;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDATEEx;
- + }
- +
- + switch (alt9)
- + {
- + case 1:
- + // SMARTPL.g:137:9: ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) ( '0' .. '9' ) '-' ( '0' .. '1' ) ( '0' .. '9' ) '-' ( '0' .. '3' ) ( '0' .. '9' )
- + {
- + // SMARTPL.g:137:9: ( '0' .. '9' )
- + // SMARTPL.g:137:10: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + // SMARTPL.g:137:19: ( '0' .. '9' )
- + // SMARTPL.g:137:20: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + // SMARTPL.g:137:29: ( '0' .. '9' )
- + // SMARTPL.g:137:30: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + // SMARTPL.g:137:39: ( '0' .. '9' )
- + // SMARTPL.g:137:40: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + MATCHC('-');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + // SMARTPL.g:137:52: ( '0' .. '1' )
- + // SMARTPL.g:137:53: '0' .. '1'
- + {
- + MATCHRANGE('0', '1');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + // SMARTPL.g:137:62: ( '0' .. '9' )
- + // SMARTPL.g:137:63: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + MATCHC('-');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- + // SMARTPL.g:137:75: ( '0' .. '3' )
- + // SMARTPL.g:137:76: '0' .. '3'
- + {
- + MATCHRANGE('0', '3');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- + // SMARTPL.g:137:85: ( '0' .. '9' )
- + // SMARTPL.g:137:86: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:138:6: 'today'
- + {
- + MATCHS(lit_31);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:139:6: 'yesterday'
- + {
- + MATCHS(lit_32);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:140:6: 'last week'
- + {
- + MATCHS(lit_33);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:141:6: 'last month'
- + {
- + MATCHS(lit_34);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 6:
- + // SMARTPL.g:142:6: 'last year'
- + {
- + MATCHS(lit_35);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATEEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDATEEx; /* Prevent compiler warnings */
- + ruleDATEEx: ;
- +
- +}
- +// $ANTLR end DATE
- +
- +// Comes from: 145:13: ( 'days' | 'weeks' | 'months' | 'years' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start DATINTERVAL
- + *
- + * Looks to match the characters the constitute the token DATINTERVAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mDATINTERVAL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = DATINTERVAL;
- +
- +
- + {
- + // SMARTPL.g:145:13: ( 'days' | 'weeks' | 'months' | 'years' )
- +
- + ANTLR3_UINT32 alt10;
- +
- + alt10=4;
- +
- + switch ( LA(1) )
- + {
- + case 'd':
- + {
- + alt10=1;
- + }
- + break;
- + case 'w':
- + {
- + alt10=2;
- + }
- + break;
- + case 'm':
- + {
- + alt10=3;
- + }
- + break;
- + case 'y':
- + {
- + alt10=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 10;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleDATINTERVALEx;
- + }
- +
- + switch (alt10)
- + {
- + case 1:
- + // SMARTPL.g:145:15: 'days'
- + {
- + MATCHS(lit_36);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATINTERVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:146:6: 'weeks'
- + {
- + MATCHS(lit_37);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATINTERVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:147:6: 'months'
- + {
- + MATCHS(lit_38);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATINTERVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:148:6: 'years'
- + {
- + MATCHS(lit_39);
- + if (HASEXCEPTION())
- + {
- + goto ruleDATINTERVALEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleDATINTERVALEx; /* Prevent compiler warnings */
- + ruleDATINTERVALEx: ;
- +
- +}
- +// $ANTLR end DATINTERVAL
- +
- +// Comes from: 151:10: ( 'music' | 'movie' | 'podcast' | 'audiobook' | 'tvshow' | 'file' | 'url' | 'spotify' | 'pipe' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start ENUMVAL
- + *
- + * Looks to match the characters the constitute the token ENUMVAL
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mENUMVAL(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = ENUMVAL;
- +
- +
- + {
- + // SMARTPL.g:151:10: ( 'music' | 'movie' | 'podcast' | 'audiobook' | 'tvshow' | 'file' | 'url' | 'spotify' | 'pipe' )
- +
- + ANTLR3_UINT32 alt11;
- +
- + alt11=9;
- +
- + switch ( LA(1) )
- + {
- + case 'm':
- + {
- + switch ( LA(2) )
- + {
- + case 'u':
- + {
- + alt11=1;
- + }
- + break;
- + case 'o':
- + {
- + alt11=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 11;
- + EXCEPTION->state = 1;
- +
- +
- + goto ruleENUMVALEx;
- + }
- +
- + }
- + break;
- + case 'p':
- + {
- + switch ( LA(2) )
- + {
- + case 'o':
- + {
- + alt11=3;
- + }
- + break;
- + case 'i':
- + {
- + alt11=9;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 11;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruleENUMVALEx;
- + }
- +
- + }
- + break;
- + case 'a':
- + {
- + alt11=4;
- + }
- + break;
- + case 't':
- + {
- + alt11=5;
- + }
- + break;
- + case 'f':
- + {
- + alt11=6;
- + }
- + break;
- + case 'u':
- + {
- + alt11=7;
- + }
- + break;
- + case 's':
- + {
- + alt11=8;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 11;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleENUMVALEx;
- + }
- +
- + switch (alt11)
- + {
- + case 1:
- + // SMARTPL.g:151:12: 'music'
- + {
- + MATCHS(lit_40);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:152:6: 'movie'
- + {
- + MATCHS(lit_41);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:153:6: 'podcast'
- + {
- + MATCHS(lit_42);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:154:6: 'audiobook'
- + {
- + MATCHS(lit_43);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:155:6: 'tvshow'
- + {
- + MATCHS(lit_44);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 6:
- + // SMARTPL.g:156:6: 'file'
- + {
- + MATCHS(lit_45);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 7:
- + // SMARTPL.g:157:6: 'url'
- + {
- + MATCHS(lit_46);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 8:
- + // SMARTPL.g:158:6: 'spotify'
- + {
- + MATCHS(lit_47);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- + case 9:
- + // SMARTPL.g:159:6: 'pipe'
- + {
- + MATCHS(lit_48);
- + if (HASEXCEPTION())
- + {
- + goto ruleENUMVALEx;
- + }
- +
- +
- +
- + }
- + break;
- +
- + }
- + }
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleENUMVALEx; /* Prevent compiler warnings */
- + ruleENUMVALEx: ;
- +
- +}
- +// $ANTLR end ENUMVAL
- +
- +// Comes from: 162:7: ( '\"' (~ ( '\"' ) )+ '\"' )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start STR
- + *
- + * Looks to match the characters the constitute the token STR
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mSTR(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = STR;
- +
- +
- + // SMARTPL.g:162:7: ( '\"' (~ ( '\"' ) )+ '\"' )
- + // SMARTPL.g:162:9: '\"' (~ ( '\"' ) )+ '\"'
- + {
- + MATCHC('"');
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- + // SMARTPL.g:162:13: (~ ( '\"' ) )+
- + {
- + int cnt12=0;
- +
- + for (;;)
- + {
- + int alt12=2;
- + {
- + /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
- + */
- + int LA12_0 = LA(1);
- + if ( (((LA12_0 >= 0x0000) && (LA12_0 <= '!')) || ((LA12_0 >= '#') && (LA12_0 <= 0xFFFF))) )
- + {
- + alt12=1;
- + }
- +
- + }
- + switch (alt12)
- + {
- + case 1:
- + // SMARTPL.g:162:13: ~ ( '\"' )
- + {
- + if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= 0xFFFF)) )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleSTREx;
- + }
- +
- +
- + }
- + break;
- +
- + default:
- +
- + if ( cnt12 >= 1 )
- + {
- + goto loop12;
- + }
- + /* mismatchedSetEx()
- + */
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
- +
- +
- + goto ruleSTREx;
- + }
- + cnt12++;
- + }
- + loop12: ; /* Jump to here if this rule does not match */
- + }
- + MATCHC('"');
- + if (HASEXCEPTION())
- + {
- + goto ruleSTREx;
- + }
- +
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleSTREx; /* Prevent compiler warnings */
- + ruleSTREx: ;
- +
- +}
- +// $ANTLR end STR
- +
- +// Comes from: 165:7: ( ( '0' .. '9' )+ )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start INT
- + *
- + * Looks to match the characters the constitute the token INT
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mINT(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = INT;
- +
- +
- + // SMARTPL.g:165:7: ( ( '0' .. '9' )+ )
- + // SMARTPL.g:165:9: ( '0' .. '9' )+
- + {
- + // SMARTPL.g:165:9: ( '0' .. '9' )+
- + {
- + int cnt13=0;
- +
- + for (;;)
- + {
- + int alt13=2;
- + switch ( LA(1) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + alt13=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt13)
- + {
- + case 1:
- + // SMARTPL.g:165:10: '0' .. '9'
- + {
- + MATCHRANGE('0', '9');
- + if (HASEXCEPTION())
- + {
- + goto ruleINTEx;
- + }
- +
- +
- + }
- + break;
- +
- + default:
- +
- + if ( cnt13 >= 1 )
- + {
- + goto loop13;
- + }
- + /* mismatchedSetEx()
- + */
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
- +
- +
- + goto ruleINTEx;
- + }
- + cnt13++;
- + }
- + loop13: ; /* Jump to here if this rule does not match */
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleINTEx; /* Prevent compiler warnings */
- + ruleINTEx: ;
- +
- +}
- +// $ANTLR end INT
- +
- +// Comes from: 168:12: ( ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' ) )
- +/** \brief Lexer rule generated by ANTLR3
- + *
- + * $ANTLR start WHITESPACE
- + *
- + * Looks to match the characters the constitute the token WHITESPACE
- + * from the attached input stream.
- + *
- + *
- + * \remark
- + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
- + */
- +static ANTLR3_INLINE
- +void mWHITESPACE(pSMARTPLLexer ctx)
- +{
- + ANTLR3_UINT32 _type;
- +
- + _type = WHITESPACE;
- +
- +
- + // SMARTPL.g:168:12: ( ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' ) )
- + // SMARTPL.g:168:14: ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' )
- + {
- + if ( ((LA(1) >= '\t') && (LA(1) <= '\n')) || ((LA(1) >= '\f') && (LA(1) <= '\r')) || LA(1) == ' ' )
- + {
- + CONSUME();
- +
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- +
- + LRECOVER(); goto ruleWHITESPACEEx;
- + }
- +
- + {
- + LEXSTATE->channel = HIDDEN;
- + }
- +
- + }
- +
- + LEXSTATE->type = _type;
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleWHITESPACEEx; /* Prevent compiler warnings */
- + ruleWHITESPACEEx: ;
- +
- +}
- +// $ANTLR end WHITESPACE
- +
- +/** This is the entry point in to the lexer from an object that
- + * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
- + */
- +static void
- +mTokens(pSMARTPLLexer ctx)
- +{
- + {
- + // SMARTPL.g:1:8: ( T__30 | T__31 | STRTAG | INTTAG | DATETAG | ENUMTAG | INCLUDES | IS | INTBOOL | AFTER | BEFORE | AGO | AND | OR | NOT | LPAR | RPAR | DATE | DATINTERVAL | ENUMVAL | STR | INT | WHITESPACE )
- +
- + ANTLR3_UINT32 alt14;
- +
- + alt14=23;
- +
- + switch ( LA(1) )
- + {
- + case '{':
- + {
- + alt14=1;
- + }
- + break;
- + case '}':
- + {
- + alt14=2;
- + }
- + break;
- + case 'a':
- + {
- + switch ( LA(2) )
- + {
- + case 'l':
- + case 'r':
- + {
- + alt14=3;
- + }
- + break;
- + case 'f':
- + {
- + alt14=10;
- + }
- + break;
- + case 'g':
- + {
- + alt14=12;
- + }
- + break;
- + case 'n':
- + {
- + alt14=13;
- + }
- + break;
- + case 'u':
- + {
- + alt14=20;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 't':
- + {
- + switch ( LA(2) )
- + {
- + case 'i':
- + {
- + switch ( LA(3) )
- + {
- + case 't':
- + {
- + alt14=3;
- + }
- + break;
- + case 'm':
- + {
- + alt14=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 28;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'y':
- + {
- + alt14=3;
- + }
- + break;
- + case 'o':
- + {
- + alt14=18;
- + }
- + break;
- + case 'v':
- + {
- + alt14=20;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 4;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'g':
- + {
- + alt14=3;
- + }
- + break;
- + case 'c':
- + {
- + switch ( LA(2) )
- + {
- + case 'o':
- + {
- + switch ( LA(3) )
- + {
- + case 'm':
- + {
- + switch ( LA(4) )
- + {
- + case 'p':
- + {
- + switch ( LA(5) )
- + {
- + case 'o':
- + {
- + alt14=3;
- + }
- + break;
- + case 'i':
- + {
- + alt14=4;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 42;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 39;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 29;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 6;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'p':
- + {
- + switch ( LA(2) )
- + {
- + case 'a':
- + {
- + alt14=3;
- + }
- + break;
- + case 'l':
- + {
- + alt14=4;
- + }
- + break;
- + case 'i':
- + case 'o':
- + {
- + alt14=20;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 7;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'r':
- + {
- + alt14=4;
- + }
- + break;
- + case 'y':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + switch ( LA(3) )
- + {
- + case 'a':
- + {
- + switch ( LA(4) )
- + {
- + case 'r':
- + {
- + switch ( LA(5) )
- + {
- + case 's':
- + {
- + alt14=19;
- + }
- + break;
- +
- + default:
- + alt14=4;}
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 40;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 's':
- + {
- + alt14=18;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 30;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 9;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'd':
- + {
- + switch ( LA(2) )
- + {
- + case 'a':
- + {
- + switch ( LA(3) )
- + {
- + case 't':
- + {
- + alt14=6;
- + }
- + break;
- + case 'y':
- + {
- + alt14=19;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 31;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 10;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'm':
- + {
- + switch ( LA(2) )
- + {
- + case 'e':
- + {
- + alt14=6;
- + }
- + break;
- + case 'o':
- + {
- + switch ( LA(3) )
- + {
- + case 'n':
- + {
- + alt14=19;
- + }
- + break;
- + case 'v':
- + {
- + alt14=20;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 33;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'u':
- + {
- + alt14=20;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 11;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case 'i':
- + {
- + switch ( LA(2) )
- + {
- + case 'n':
- + {
- + alt14=7;
- + }
- + break;
- + case 's':
- + {
- + alt14=8;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 12;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + }
- + break;
- + case '<':
- + case '=':
- + case '>':
- + {
- + alt14=9;
- + }
- + break;
- + case 'b':
- + {
- + alt14=11;
- + }
- + break;
- + case 'A':
- + {
- + alt14=13;
- + }
- + break;
- + case 'O':
- + case 'o':
- + {
- + alt14=14;
- + }
- + break;
- + case 'N':
- + case 'n':
- + {
- + alt14=15;
- + }
- + break;
- + case '(':
- + {
- + alt14=16;
- + }
- + break;
- + case ')':
- + {
- + alt14=17;
- + }
- + break;
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(2) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(3) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(4) )
- + {
- + case '0':
- + case '1':
- + case '2':
- + case '3':
- + case '4':
- + case '5':
- + case '6':
- + case '7':
- + case '8':
- + case '9':
- + {
- + switch ( LA(5) )
- + {
- + case '-':
- + {
- + alt14=18;
- + }
- + break;
- +
- + default:
- + alt14=22;}
- +
- + }
- + break;
- +
- + default:
- + alt14=22;}
- +
- + }
- + break;
- +
- + default:
- + alt14=22;}
- +
- + }
- + break;
- +
- + default:
- + alt14=22;}
- +
- + }
- + break;
- + case 'l':
- + {
- + alt14=18;
- + }
- + break;
- + case 'w':
- + {
- + alt14=19;
- + }
- + break;
- + case 'f':
- + case 's':
- + case 'u':
- + {
- + alt14=20;
- + }
- + break;
- + case '"':
- + {
- + alt14=21;
- + }
- + break;
- + case '\t':
- + case '\n':
- + case '\f':
- + case '\r':
- + case ' ':
- + {
- + alt14=23;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 14;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruleTokensEx;
- + }
- +
- + switch (alt14)
- + {
- + case 1:
- + // SMARTPL.g:1:10: T__30
- + {
- + /* 1:10: T__30 */
- + mT__30(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:1:16: T__31
- + {
- + /* 1:16: T__31 */
- + mT__31(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:1:22: STRTAG
- + {
- + /* 1:22: STRTAG */
- + mSTRTAG(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:1:29: INTTAG
- + {
- + /* 1:29: INTTAG */
- + mINTTAG(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:1:36: DATETAG
- + {
- + /* 1:36: DATETAG */
- + mDATETAG(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 6:
- + // SMARTPL.g:1:44: ENUMTAG
- + {
- + /* 1:44: ENUMTAG */
- + mENUMTAG(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 7:
- + // SMARTPL.g:1:52: INCLUDES
- + {
- + /* 1:52: INCLUDES */
- + mINCLUDES(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 8:
- + // SMARTPL.g:1:61: IS
- + {
- + /* 1:61: IS */
- + mIS(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 9:
- + // SMARTPL.g:1:64: INTBOOL
- + {
- + /* 1:64: INTBOOL */
- + mINTBOOL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 10:
- + // SMARTPL.g:1:72: AFTER
- + {
- + /* 1:72: AFTER */
- + mAFTER(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 11:
- + // SMARTPL.g:1:78: BEFORE
- + {
- + /* 1:78: BEFORE */
- + mBEFORE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 12:
- + // SMARTPL.g:1:85: AGO
- + {
- + /* 1:85: AGO */
- + mAGO(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 13:
- + // SMARTPL.g:1:89: AND
- + {
- + /* 1:89: AND */
- + mAND(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 14:
- + // SMARTPL.g:1:93: OR
- + {
- + /* 1:93: OR */
- + mOR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 15:
- + // SMARTPL.g:1:96: NOT
- + {
- + /* 1:96: NOT */
- + mNOT(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 16:
- + // SMARTPL.g:1:100: LPAR
- + {
- + /* 1:100: LPAR */
- + mLPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 17:
- + // SMARTPL.g:1:105: RPAR
- + {
- + /* 1:105: RPAR */
- + mRPAR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 18:
- + // SMARTPL.g:1:110: DATE
- + {
- + /* 1:110: DATE */
- + mDATE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 19:
- + // SMARTPL.g:1:115: DATINTERVAL
- + {
- + /* 1:115: DATINTERVAL */
- + mDATINTERVAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 20:
- + // SMARTPL.g:1:127: ENUMVAL
- + {
- + /* 1:127: ENUMVAL */
- + mENUMVAL(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 21:
- + // SMARTPL.g:1:135: STR
- + {
- + /* 1:135: STR */
- + mSTR(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 22:
- + // SMARTPL.g:1:139: INT
- + {
- + /* 1:139: INT */
- + mINT(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- + case 23:
- + // SMARTPL.g:1:143: WHITESPACE
- + {
- + /* 1:143: WHITESPACE */
- + mWHITESPACE(ctx );
- + if (HASEXCEPTION())
- + {
- + goto ruleTokensEx;
- + }
- +
- +
- + }
- + break;
- +
- + }
- + }
- +
- +
- + goto ruleTokensEx; /* Prevent compiler warnings */
- +ruleTokensEx: ;
- +}
- +
- +/* =========================================================================
- + * Lexer matching rules end.
- + * =========================================================================
- + */
- +/* End of Lexer code
- + * ================================================
- + * ================================================
- + */
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/SMARTPLLexer.h b/src/pregen/SMARTPLLexer.h
- new file mode 100644
- index 0000000..87e8c7e
- --- /dev/null
- +++ b/src/pregen/SMARTPLLexer.h
- @@ -0,0 +1,248 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL.g
- + * - On : 2016-01-01 12:23:40
- + * - for the lexer : SMARTPLLexerLexer *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The lexer SMARTPLLexer has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pSMARTPLLexer, which is returned from a call to SMARTPLLexerNew().
- + *
- + * As this is a generated lexer, it is unlikely you will call it 'manually'. However
- + * the methods are provided anyway.
- + * * The methods in pSMARTPLLexer are as follows:
- + *
- + * - void pSMARTPLLexer->T__30(pSMARTPLLexer)
- + * - void pSMARTPLLexer->T__31(pSMARTPLLexer)
- + * - void pSMARTPLLexer->STRTAG(pSMARTPLLexer)
- + * - void pSMARTPLLexer->INTTAG(pSMARTPLLexer)
- + * - void pSMARTPLLexer->DATETAG(pSMARTPLLexer)
- + * - void pSMARTPLLexer->ENUMTAG(pSMARTPLLexer)
- + * - void pSMARTPLLexer->INCLUDES(pSMARTPLLexer)
- + * - void pSMARTPLLexer->IS(pSMARTPLLexer)
- + * - void pSMARTPLLexer->INTBOOL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->GREATER(pSMARTPLLexer)
- + * - void pSMARTPLLexer->GREATEREQUAL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->LESS(pSMARTPLLexer)
- + * - void pSMARTPLLexer->LESSEQUAL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->EQUAL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->AFTER(pSMARTPLLexer)
- + * - void pSMARTPLLexer->BEFORE(pSMARTPLLexer)
- + * - void pSMARTPLLexer->AGO(pSMARTPLLexer)
- + * - void pSMARTPLLexer->AND(pSMARTPLLexer)
- + * - void pSMARTPLLexer->OR(pSMARTPLLexer)
- + * - void pSMARTPLLexer->NOT(pSMARTPLLexer)
- + * - void pSMARTPLLexer->LPAR(pSMARTPLLexer)
- + * - void pSMARTPLLexer->RPAR(pSMARTPLLexer)
- + * - void pSMARTPLLexer->DATE(pSMARTPLLexer)
- + * - void pSMARTPLLexer->DATINTERVAL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->ENUMVAL(pSMARTPLLexer)
- + * - void pSMARTPLLexer->STR(pSMARTPLLexer)
- + * - void pSMARTPLLexer->INT(pSMARTPLLexer)
- + * - void pSMARTPLLexer->WHITESPACE(pSMARTPLLexer)
- + * - void pSMARTPLLexer->Tokens(pSMARTPLLexer)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _SMARTPLLexer_H
- +#define _SMARTPLLexer_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct SMARTPLLexer_Ctx_struct SMARTPLLexer, * pSMARTPLLexer;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +
- +/** Context tracking structure for SMARTPLLexer
- + */
- +struct SMARTPLLexer_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_LEXER pLexer;
- +
- +
- + void (*mT__30) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mT__31) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mSTRTAG) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mINTTAG) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mDATETAG) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mENUMTAG) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mINCLUDES) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mIS) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mINTBOOL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mGREATER) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mGREATEREQUAL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mLESS) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mLESSEQUAL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mEQUAL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mAFTER) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mBEFORE) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mAGO) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mAND) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mOR) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mNOT) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mLPAR) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mRPAR) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mDATE) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mDATINTERVAL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mENUMVAL) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mSTR) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mINT) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mWHITESPACE) (struct SMARTPLLexer_Ctx_struct * ctx);
- + void (*mTokens) (struct SMARTPLLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)();
- + void (*free) (struct SMARTPLLexer_Ctx_struct * ctx);
- +
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pSMARTPLLexer SMARTPLLexerNew (pANTLR3_INPUT_STREAM instream);
- +ANTLR3_API pSMARTPLLexer SMARTPLLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the lexer will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define INTBOOL 14
- +#define STRTAG 10
- +#define AGO 22
- +#define WHITESPACE 29
- +#define GREATEREQUAL 25
- +#define BEFORE 18
- +#define DATETAG 16
- +#define INT 15
- +#define NOT 7
- +#define AFTER 17
- +#define AND 6
- +#define EOF -1
- +#define INCLUDES 11
- +#define STR 4
- +#define T__30 30
- +#define T__31 31
- +#define GREATER 24
- +#define LPAR 8
- +#define ENUMTAG 19
- +#define IS 12
- +#define ENUMVAL 20
- +#define EQUAL 28
- +#define OR 5
- +#define LESS 26
- +#define RPAR 9
- +#define DATE 21
- +#define LESSEQUAL 27
- +#define INTTAG 13
- +#define DATINTERVAL 23
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for SMARTPLLexer
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
- diff --git a/src/pregen/SMARTPLParser.c b/src/pregen/SMARTPLParser.c
- new file mode 100644
- index 0000000..f39e5ae
- --- /dev/null
- +++ b/src/pregen/SMARTPLParser.c
- @@ -0,0 +1,1812 @@
- +/** \file
- + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL.g
- + * - On : 2016-01-01 12:23:40
- + * - for the parser : SMARTPLParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- +*/
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +/* -----------------------------------------
- + * Include the ANTLR3 generated header file.
- + */
- +#include "SMARTPLParser.h"
- +/* ----------------------------------------- */
- +
- +
- +
- +
- +
- +/* MACROS that hide the C interface implementations from the
- + * generated code, which makes it a little more understandable to the human eye.
- + * I am very much against using C pre-processor macros for function calls and bits
- + * of code as you cannot see what is happening when single stepping in debuggers
- + * and so on. The exception (in my book at least) is for generated code, where you are
- + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
- + * hides some indirect calls, but is always referring to the input stream. This is
- + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
- + * the runtime interfaces without changing the generated code too often, without
- + * confusing the reader of the generated output, who may not wish to know the gory
- + * details of the interface inheritance.
- + */
- +
- +#define CTX ctx
- +
- +/* Aids in accessing scopes for grammar programmers
- + */
- +#undef SCOPE_TYPE
- +#undef SCOPE_STACK
- +#undef SCOPE_TOP
- +#define SCOPE_TYPE(scope) pSMARTPLParser_##scope##_SCOPE
- +#define SCOPE_STACK(scope) pSMARTPLParser_##scope##Stack
- +#define SCOPE_TOP(scope) ctx->pSMARTPLParser_##scope##Top
- +#define SCOPE_SIZE(scope) ctx->pSMARTPLParser_##scope##Stack_limit
- +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
- +
- +/* Macros for accessing things in the parser
- + */
- +
- +#undef PARSER
- +#undef RECOGNIZER
- +#undef HAVEPARSEDRULE
- +#undef MEMOIZE
- +#undef INPUT
- +#undef STRSTREAM
- +#undef HASEXCEPTION
- +#undef EXCEPTION
- +#undef MATCHT
- +#undef MATCHANYT
- +#undef FOLLOWSTACK
- +#undef FOLLOWPUSH
- +#undef FOLLOWPOP
- +#undef PRECOVER
- +#undef PREPORTERROR
- +#undef LA
- +#undef LT
- +#undef CONSTRUCTEX
- +#undef CONSUME
- +#undef MARK
- +#undef REWIND
- +#undef REWINDLAST
- +#undef PERRORRECOVERY
- +#undef HASFAILED
- +#undef FAILEDFLAG
- +#undef RECOVERFROMMISMATCHEDSET
- +#undef RECOVERFROMMISMATCHEDELEMENT
- +#undef INDEX
- +#undef ADAPTOR
- +#undef SEEK
- +#undef RULEMEMO
- +#undef DBG
- +
- +#define PARSER ctx->pParser
- +#define RECOGNIZER PARSER->rec
- +#define PSRSTATE RECOGNIZER->state
- +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
- +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
- +#define INPUT PARSER->tstream
- +#define STRSTREAM INPUT
- +#define ISTREAM INPUT->istream
- +#define INDEX() ISTREAM->index(INPUT->istream)
- +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
- +#define EXCEPTION PSRSTATE->exception
- +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
- +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
- +#define FOLLOWSTACK PSRSTATE->following
- +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
- +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
- +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
- +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
- +#define LA(n) INPUT->istream->_LA(ISTREAM, n)
- +#define LT(n) INPUT->_LT(INPUT, n)
- +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
- +#define CONSUME() ISTREAM->consume(ISTREAM)
- +#define MARK() ISTREAM->mark(ISTREAM)
- +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
- +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
- +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
- +#define PERRORRECOVERY PSRSTATE->errorRecovery
- +#define FAILEDFLAG PSRSTATE->failed
- +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
- +#define BACKTRACKING PSRSTATE->backtracking
- +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
- +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
- +#define ADAPTOR ctx->adaptor
- +#define RULEMEMO PSRSTATE->ruleMemo
- +#define DBG RECOGNIZER->debugger
- +
- +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
- +
- +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
- + * then for the present you must use different names for your defines as these are hard coded
- + * in the code generator. It would be better not to use such names internally, and maybe
- + * we can change this in a forthcoming release. I deliberately do not #undef these
- + * here as this will at least give you a redefined error somewhere if they clash.
- + */
- +#define UP ANTLR3_TOKEN_UP
- +#define DOWN ANTLR3_TOKEN_DOWN
- +#define EOR ANTLR3_TOKEN_EOR
- +#define INVALID ANTLR3_TOKEN_INVALID
- +
- +
- +/* =============================================================================
- + * Functions to create and destroy scopes. First come the rule scopes, followed
- + * by the global declared scopes.
- + */
- +
- +
- +
- +/* ============================================================================= */
- +
- +/* =============================================================================
- + * Start of recognizer
- + */
- +
- +
- +
- +/** \brief Table of all token names in symbolic order, mainly used for
- + * error reporting.
- + */
- +pANTLR3_UINT8 SMARTPLParserTokenNames[28+4]
- + = {
- + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
- + (pANTLR3_UINT8) "<EOR>",
- + (pANTLR3_UINT8) "<DOWN>",
- + (pANTLR3_UINT8) "<UP>",
- + (pANTLR3_UINT8) "STR",
- + (pANTLR3_UINT8) "OR",
- + (pANTLR3_UINT8) "AND",
- + (pANTLR3_UINT8) "NOT",
- + (pANTLR3_UINT8) "LPAR",
- + (pANTLR3_UINT8) "RPAR",
- + (pANTLR3_UINT8) "STRTAG",
- + (pANTLR3_UINT8) "INCLUDES",
- + (pANTLR3_UINT8) "IS",
- + (pANTLR3_UINT8) "INTTAG",
- + (pANTLR3_UINT8) "INTBOOL",
- + (pANTLR3_UINT8) "INT",
- + (pANTLR3_UINT8) "DATETAG",
- + (pANTLR3_UINT8) "AFTER",
- + (pANTLR3_UINT8) "BEFORE",
- + (pANTLR3_UINT8) "ENUMTAG",
- + (pANTLR3_UINT8) "ENUMVAL",
- + (pANTLR3_UINT8) "DATE",
- + (pANTLR3_UINT8) "AGO",
- + (pANTLR3_UINT8) "DATINTERVAL",
- + (pANTLR3_UINT8) "GREATER",
- + (pANTLR3_UINT8) "GREATEREQUAL",
- + (pANTLR3_UINT8) "LESS",
- + (pANTLR3_UINT8) "LESSEQUAL",
- + (pANTLR3_UINT8) "EQUAL",
- + (pANTLR3_UINT8) "WHITESPACE",
- + (pANTLR3_UINT8) "'{'",
- + (pANTLR3_UINT8) "'}'"
- + };
- +
- +
- +
- +// Forward declare the locally static matching functions we have generated.
- +//
- +static SMARTPLParser_playlist_return playlist (pSMARTPLParser ctx);
- +static SMARTPLParser_expression_return expression (pSMARTPLParser ctx);
- +static SMARTPLParser_aexpr_return aexpr (pSMARTPLParser ctx);
- +static SMARTPLParser_nexpr_return nexpr (pSMARTPLParser ctx);
- +static SMARTPLParser_crit_return crit (pSMARTPLParser ctx);
- +static SMARTPLParser_dateval_return dateval (pSMARTPLParser ctx);
- +static SMARTPLParser_interval_return interval (pSMARTPLParser ctx);
- +static void SMARTPLParserFree(pSMARTPLParser ctx);
- +/* For use in tree output where we are accumulating rule labels via label += ruleRef
- + * we need a function that knows how to free a return scope when the list is destroyed.
- + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
- + */
- +static void ANTLR3_CDECL freeScope(void * scope)
- +{
- + ANTLR3_FREE(scope);
- +}
- +
- +/** \brief Name of the grammar file that generated this code
- + */
- +static const char fileName[] = "SMARTPL.g";
- +
- +/** \brief Return the name of the grammar file that generated this code.
- + */
- +static const char * getGrammarFileName()
- +{
- + return fileName;
- +}
- +/** \brief Create a new SMARTPLParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pSMARTPLParser
- +SMARTPLParserNew (pANTLR3_COMMON_TOKEN_STREAM instream)
- +{
- + // See if we can create a new parser with the standard constructor
- + //
- + return SMARTPLParserNewSSD(instream, NULL);
- +}
- +
- +/** \brief Create a new SMARTPLParser parser and return a context for it.
- + *
- + * \param[in] instream Pointer to an input stream interface.
- + *
- + * \return Pointer to new parser context upon success.
- + */
- +ANTLR3_API pSMARTPLParser
- +SMARTPLParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
- +{
- + pSMARTPLParser ctx; /* Context structure we will build and return */
- +
- + ctx = (pSMARTPLParser) ANTLR3_CALLOC(1, sizeof(SMARTPLParser));
- +
- + if (ctx == NULL)
- + {
- + // Failed to allocate memory for parser context
- + //
- + return NULL;
- + }
- +
- + /* -------------------------------------------------------------------
- + * Memory for basic structure is allocated, now to fill in
- + * the base ANTLR3 structures. We initialize the function pointers
- + * for the standard ANTLR3 parser function set, but upon return
- + * from here, the programmer may set the pointers to provide custom
- + * implementations of each function.
- + *
- + * We don't use the macros defined in SMARTPLParser.h here, in order that you can get a sense
- + * of what goes where.
- + */
- +
- + /* Create a base parser/recognizer, using the supplied token stream
- + */
- + ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
- + /* Install the implementation of our SMARTPLParser interface
- + */
- + ctx->playlist = playlist;
- + ctx->expression = expression;
- + ctx->aexpr = aexpr;
- + ctx->nexpr = nexpr;
- + ctx->crit = crit;
- + ctx->dateval = dateval;
- + ctx->interval = interval;
- + ctx->free = SMARTPLParserFree;
- + ctx->getGrammarFileName = getGrammarFileName;
- +
- + /* Install the scope pushing methods.
- + */
- + ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
- + ctx->vectors = antlr3VectorFactoryNew(0);
- +
- +
- +
- + /* Install the token table
- + */
- + PSRSTATE->tokenNames = SMARTPLParserTokenNames;
- +
- +
- + /* Return the newly built parser to the caller
- + */
- + return ctx;
- +}
- +
- +/** Free the parser resources
- + */
- + static void
- + SMARTPLParserFree(pSMARTPLParser ctx)
- + {
- + /* Free any scope memory
- + */
- +
- + ctx->vectors->close(ctx->vectors);
- + /* We created the adaptor so we must free it
- + */
- + ADAPTOR->free(ADAPTOR);
- + // Free this parser
- + //
- + ctx->pParser->free(ctx->pParser);
- + ANTLR3_FREE(ctx);
- +
- + /* Everything is released, so we can return
- + */
- + return;
- + }
- +
- +/** Return token names used by this parser
- + *
- + * The returned pointer is used as an index into the token names table (using the token
- + * number as the index).
- + *
- + * \return Pointer to first char * in the table.
- + */
- +static pANTLR3_UINT8 *getTokenNames()
- +{
- + return SMARTPLParserTokenNames;
- +}
- +
- +
- +/* Declare the bitsets
- + */
- +
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_playlist42 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_playlist42_bits[] = { ANTLR3_UINT64_LIT(0x0000000040000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_playlist42 = { FOLLOW_STR_in_playlist42_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_30_in_playlist44 */
- +static ANTLR3_BITWORD FOLLOW_30_in_playlist44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000092580) };
- +static ANTLR3_BITSET_LIST FOLLOW_30_in_playlist44 = { FOLLOW_30_in_playlist44_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_playlist46 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_playlist46_bits[] = { ANTLR3_UINT64_LIT(0x0000000080000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_playlist46 = { FOLLOW_expression_in_playlist46_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_31_in_playlist48 */
- +static ANTLR3_BITWORD FOLLOW_31_in_playlist48_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) };
- +static ANTLR3_BITSET_LIST FOLLOW_31_in_playlist48 = { FOLLOW_31_in_playlist48_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_playlist50 */
- +static ANTLR3_BITWORD FOLLOW_EOF_in_playlist50_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_EOF_in_playlist50 = { FOLLOW_EOF_in_playlist50_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expression62 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expression62_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expression62 = { FOLLOW_aexpr_in_expression62_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expression65 */
- +static ANTLR3_BITWORD FOLLOW_OR_in_expression65_bits[] = { ANTLR3_UINT64_LIT(0x0000000000092580) };
- +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expression65 = { FOLLOW_OR_in_expression65_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expression68 */
- +static ANTLR3_BITWORD FOLLOW_aexpr_in_expression68_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
- +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expression68 = { FOLLOW_aexpr_in_expression68_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_nexpr_in_aexpr83 */
- +static ANTLR3_BITWORD FOLLOW_nexpr_in_aexpr83_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_nexpr_in_aexpr83 = { FOLLOW_nexpr_in_aexpr83_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr86 */
- +static ANTLR3_BITWORD FOLLOW_AND_in_aexpr86_bits[] = { ANTLR3_UINT64_LIT(0x0000000000092580) };
- +static ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr86 = { FOLLOW_AND_in_aexpr86_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_nexpr_in_aexpr89 */
- +static ANTLR3_BITWORD FOLLOW_nexpr_in_aexpr89_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
- +static ANTLR3_BITSET_LIST FOLLOW_nexpr_in_aexpr89 = { FOLLOW_nexpr_in_aexpr89_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_nexpr104 */
- +static ANTLR3_BITWORD FOLLOW_NOT_in_nexpr104_bits[] = { ANTLR3_UINT64_LIT(0x0000000000092580) };
- +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_nexpr104 = { FOLLOW_NOT_in_nexpr104_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_nexpr107 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_nexpr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_nexpr107 = { FOLLOW_crit_in_nexpr107_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_nexpr114 */
- +static ANTLR3_BITWORD FOLLOW_crit_in_nexpr114_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_crit_in_nexpr114 = { FOLLOW_crit_in_nexpr114_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit127 */
- +static ANTLR3_BITWORD FOLLOW_LPAR_in_crit127_bits[] = { ANTLR3_UINT64_LIT(0x0000000000092580) };
- +static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit127 = { FOLLOW_LPAR_in_crit127_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expression_in_crit129 */
- +static ANTLR3_BITWORD FOLLOW_expression_in_crit129_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000200) };
- +static ANTLR3_BITSET_LIST FOLLOW_expression_in_crit129 = { FOLLOW_expression_in_crit129_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit131 */
- +static ANTLR3_BITWORD FOLLOW_RPAR_in_crit131_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit131 = { FOLLOW_RPAR_in_crit131_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRTAG_in_crit142 */
- +static ANTLR3_BITWORD FOLLOW_STRTAG_in_crit142_bits[] = { ANTLR3_UINT64_LIT(0x0000000000001800) };
- +static ANTLR3_BITSET_LIST FOLLOW_STRTAG_in_crit142 = { FOLLOW_STRTAG_in_crit142_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_crit144 */
- +static ANTLR3_BITWORD FOLLOW_set_in_crit144_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
- +static ANTLR3_BITSET_LIST FOLLOW_set_in_crit144 = { FOLLOW_set_in_crit144_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit150 */
- +static ANTLR3_BITWORD FOLLOW_STR_in_crit150_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_STR_in_crit150 = { FOLLOW_STR_in_crit150_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INTTAG_in_crit157 */
- +static ANTLR3_BITWORD FOLLOW_INTTAG_in_crit157_bits[] = { ANTLR3_UINT64_LIT(0x0000000000004000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INTTAG_in_crit157 = { FOLLOW_INTTAG_in_crit157_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INTBOOL_in_crit159 */
- +static ANTLR3_BITWORD FOLLOW_INTBOOL_in_crit159_bits[] = { ANTLR3_UINT64_LIT(0x0000000000008000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INTBOOL_in_crit159 = { FOLLOW_INTBOOL_in_crit159_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_crit161 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_crit161_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_crit161 = { FOLLOW_INT_in_crit161_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATETAG_in_crit168 */
- +static ANTLR3_BITWORD FOLLOW_DATETAG_in_crit168_bits[] = { ANTLR3_UINT64_LIT(0x0000000000060000) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATETAG_in_crit168 = { FOLLOW_DATETAG_in_crit168_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_crit170 */
- +static ANTLR3_BITWORD FOLLOW_set_in_crit170_bits[] = { ANTLR3_UINT64_LIT(0x0000000000208000) };
- +static ANTLR3_BITSET_LIST FOLLOW_set_in_crit170 = { FOLLOW_set_in_crit170_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateval_in_crit176 */
- +static ANTLR3_BITWORD FOLLOW_dateval_in_crit176_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_dateval_in_crit176 = { FOLLOW_dateval_in_crit176_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENUMTAG_in_crit183 */
- +static ANTLR3_BITWORD FOLLOW_ENUMTAG_in_crit183_bits[] = { ANTLR3_UINT64_LIT(0x0000000000001000) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENUMTAG_in_crit183 = { FOLLOW_ENUMTAG_in_crit183_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_IS_in_crit185 */
- +static ANTLR3_BITWORD FOLLOW_IS_in_crit185_bits[] = { ANTLR3_UINT64_LIT(0x0000000000100000) };
- +static ANTLR3_BITSET_LIST FOLLOW_IS_in_crit185 = { FOLLOW_IS_in_crit185_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENUMVAL_in_crit187 */
- +static ANTLR3_BITWORD FOLLOW_ENUMVAL_in_crit187_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_ENUMVAL_in_crit187 = { FOLLOW_ENUMVAL_in_crit187_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval200 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval200_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval200 = { FOLLOW_DATE_in_dateval200_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval207 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval207_bits[] = { ANTLR3_UINT64_LIT(0x0000000000040000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval207 = { FOLLOW_interval_in_dateval207_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateval209 */
- +static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateval209_bits[] = { ANTLR3_UINT64_LIT(0x0000000000200000) };
- +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateval209 = { FOLLOW_BEFORE_in_dateval209_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval211 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval211_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval211 = { FOLLOW_DATE_in_dateval211_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval218 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval218_bits[] = { ANTLR3_UINT64_LIT(0x0000000000020000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval218 = { FOLLOW_interval_in_dateval218_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateval220 */
- +static ANTLR3_BITWORD FOLLOW_AFTER_in_dateval220_bits[] = { ANTLR3_UINT64_LIT(0x0000000000200000) };
- +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateval220 = { FOLLOW_AFTER_in_dateval220_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateval222 */
- +static ANTLR3_BITWORD FOLLOW_DATE_in_dateval222_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateval222 = { FOLLOW_DATE_in_dateval222_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_interval_in_dateval229 */
- +static ANTLR3_BITWORD FOLLOW_interval_in_dateval229_bits[] = { ANTLR3_UINT64_LIT(0x0000000000400000) };
- +static ANTLR3_BITSET_LIST FOLLOW_interval_in_dateval229 = { FOLLOW_interval_in_dateval229_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AGO_in_dateval231 */
- +static ANTLR3_BITWORD FOLLOW_AGO_in_dateval231_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_AGO_in_dateval231 = { FOLLOW_AGO_in_dateval231_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_interval243 */
- +static ANTLR3_BITWORD FOLLOW_INT_in_interval243_bits[] = { ANTLR3_UINT64_LIT(0x0000000000800000) };
- +static ANTLR3_BITSET_LIST FOLLOW_INT_in_interval243 = { FOLLOW_INT_in_interval243_bits, 1 };
- +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATINTERVAL_in_interval245 */
- +static ANTLR3_BITWORD FOLLOW_DATINTERVAL_in_interval245_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
- +static ANTLR3_BITSET_LIST FOLLOW_DATINTERVAL_in_interval245 = { FOLLOW_DATINTERVAL_in_interval245_bits, 1 };
- +
- +
- +
- +
- +/* ==============================================
- + * Parsing rules
- + */
- +/**
- + * $ANTLR start playlist
- + * SMARTPL.g:27:1: playlist : STR '{' expression '}' EOF ;
- + */
- +static SMARTPLParser_playlist_return
- +playlist(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_playlist_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN STR1;
- + pANTLR3_COMMON_TOKEN char_literal2;
- + pANTLR3_COMMON_TOKEN char_literal4;
- + pANTLR3_COMMON_TOKEN EOF5;
- + SMARTPLParser_expression_return expression3;
- + #undef RETURN_TYPE_expression3
- + #define RETURN_TYPE_expression3 SMARTPLParser_expression_return
- +
- + pANTLR3_BASE_TREE STR1_tree;
- + pANTLR3_BASE_TREE char_literal2_tree;
- + pANTLR3_BASE_TREE char_literal4_tree;
- + pANTLR3_BASE_TREE EOF5_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + STR1 = NULL;
- + char_literal2 = NULL;
- + char_literal4 = NULL;
- + EOF5 = NULL;
- + expression3.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + STR1_tree = NULL;
- + char_literal2_tree = NULL;
- + char_literal4_tree = NULL;
- + EOF5_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // SMARTPL.g:27:10: ( STR '{' expression '}' EOF )
- + // SMARTPL.g:27:12: STR '{' expression '}' EOF
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + STR1 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_playlist42);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + STR1_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR1));
- + ADAPTOR->addChild(ADAPTOR, root_0, STR1_tree);
- +
- + char_literal2 = (pANTLR3_COMMON_TOKEN) MATCHT(30, &FOLLOW_30_in_playlist44);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + char_literal2_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal2));
- + ADAPTOR->addChild(ADAPTOR, root_0, char_literal2_tree);
- +
- + FOLLOWPUSH(FOLLOW_expression_in_playlist46);
- + expression3=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, expression3.tree);
- + char_literal4 = (pANTLR3_COMMON_TOKEN) MATCHT(31, &FOLLOW_31_in_playlist48);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + char_literal4_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal4));
- + ADAPTOR->addChild(ADAPTOR, root_0, char_literal4_tree);
- +
- + EOF5 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_playlist50);
- + if (HASEXCEPTION())
- + {
- + goto ruleplaylistEx;
- + }
- +
- + EOF5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, EOF5));
- + ADAPTOR->addChild(ADAPTOR, root_0, EOF5_tree);
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleplaylistEx; /* Prevent compiler warnings */
- + ruleplaylistEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end playlist */
- +
- +/**
- + * $ANTLR start expression
- + * SMARTPL.g:30:1: expression : aexpr ( OR aexpr )* ;
- + */
- +static SMARTPLParser_expression_return
- +expression(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_expression_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN OR7;
- + SMARTPLParser_aexpr_return aexpr6;
- + #undef RETURN_TYPE_aexpr6
- + #define RETURN_TYPE_aexpr6 SMARTPLParser_aexpr_return
- +
- + SMARTPLParser_aexpr_return aexpr8;
- + #undef RETURN_TYPE_aexpr8
- + #define RETURN_TYPE_aexpr8 SMARTPLParser_aexpr_return
- +
- + pANTLR3_BASE_TREE OR7_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + OR7 = NULL;
- + aexpr6.tree = NULL;
- +
- + aexpr8.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + OR7_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // SMARTPL.g:30:12: ( aexpr ( OR aexpr )* )
- + // SMARTPL.g:30:14: aexpr ( OR aexpr )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expression62);
- + aexpr6=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
- +
- + // SMARTPL.g:30:20: ( OR aexpr )*
- +
- + for (;;)
- + {
- + int alt1=2;
- + switch ( LA(1) )
- + {
- + case OR:
- + {
- + alt1=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt1)
- + {
- + case 1:
- + // SMARTPL.g:30:21: OR aexpr
- + {
- + OR7 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expression65);
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + OR7_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR7));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR7_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_aexpr_in_expression68);
- + aexpr8=aexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleexpressionEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, aexpr8.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop1; /* break out of the loop */
- + break;
- + }
- + }
- + loop1: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleexpressionEx; /* Prevent compiler warnings */
- + ruleexpressionEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end expression */
- +
- +/**
- + * $ANTLR start aexpr
- + * SMARTPL.g:33:1: aexpr : nexpr ( AND nexpr )* ;
- + */
- +static SMARTPLParser_aexpr_return
- +aexpr(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_aexpr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN AND10;
- + SMARTPLParser_nexpr_return nexpr9;
- + #undef RETURN_TYPE_nexpr9
- + #define RETURN_TYPE_nexpr9 SMARTPLParser_nexpr_return
- +
- + SMARTPLParser_nexpr_return nexpr11;
- + #undef RETURN_TYPE_nexpr11
- + #define RETURN_TYPE_nexpr11 SMARTPLParser_nexpr_return
- +
- + pANTLR3_BASE_TREE AND10_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + AND10 = NULL;
- + nexpr9.tree = NULL;
- +
- + nexpr11.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + AND10_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // SMARTPL.g:33:8: ( nexpr ( AND nexpr )* )
- + // SMARTPL.g:33:10: nexpr ( AND nexpr )*
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_nexpr_in_aexpr83);
- + nexpr9=nexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, nexpr9.tree);
- +
- + // SMARTPL.g:33:16: ( AND nexpr )*
- +
- + for (;;)
- + {
- + int alt2=2;
- + switch ( LA(1) )
- + {
- + case AND:
- + {
- + alt2=1;
- + }
- + break;
- +
- + }
- +
- + switch (alt2)
- + {
- + case 1:
- + // SMARTPL.g:33:17: AND nexpr
- + {
- + AND10 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr86);
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + AND10_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND10));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND10_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_nexpr_in_aexpr89);
- + nexpr11=nexpr(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruleaexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, nexpr11.tree);
- +
- + }
- + break;
- +
- + default:
- + goto loop2; /* break out of the loop */
- + break;
- + }
- + }
- + loop2: ; /* Jump out to here if this rule does not match */
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleaexprEx; /* Prevent compiler warnings */
- + ruleaexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end aexpr */
- +
- +/**
- + * $ANTLR start nexpr
- + * SMARTPL.g:36:1: nexpr : ( NOT crit | crit );
- + */
- +static SMARTPLParser_nexpr_return
- +nexpr(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_nexpr_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN NOT12;
- + SMARTPLParser_crit_return crit13;
- + #undef RETURN_TYPE_crit13
- + #define RETURN_TYPE_crit13 SMARTPLParser_crit_return
- +
- + SMARTPLParser_crit_return crit14;
- + #undef RETURN_TYPE_crit14
- + #define RETURN_TYPE_crit14 SMARTPLParser_crit_return
- +
- + pANTLR3_BASE_TREE NOT12_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + NOT12 = NULL;
- + crit13.tree = NULL;
- +
- + crit14.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + NOT12_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // SMARTPL.g:36:8: ( NOT crit | crit )
- +
- + ANTLR3_UINT32 alt3;
- +
- + alt3=2;
- +
- + switch ( LA(1) )
- + {
- + case NOT:
- + {
- + alt3=1;
- + }
- + break;
- + case LPAR:
- + case STRTAG:
- + case INTTAG:
- + case DATETAG:
- + case ENUMTAG:
- + {
- + alt3=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 3;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulenexprEx;
- + }
- +
- + switch (alt3)
- + {
- + case 1:
- + // SMARTPL.g:36:10: NOT crit
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + NOT12 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_nexpr104);
- + if (HASEXCEPTION())
- + {
- + goto rulenexprEx;
- + }
- +
- + NOT12_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, NOT12));
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, NOT12_tree, root_0));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_nexpr107);
- + crit13=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulenexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit13.tree);
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:37:6: crit
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_crit_in_nexpr114);
- + crit14=crit(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulenexprEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, crit14.tree);
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulenexprEx; /* Prevent compiler warnings */
- + rulenexprEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end nexpr */
- +
- +/**
- + * $ANTLR start crit
- + * SMARTPL.g:40:1: crit : ( LPAR expression RPAR -> expression | STRTAG ( INCLUDES | IS ) STR | INTTAG INTBOOL INT | DATETAG ( AFTER | BEFORE ) dateval | ENUMTAG IS ENUMVAL );
- + */
- +static SMARTPLParser_crit_return
- +crit(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_crit_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN LPAR15;
- + pANTLR3_COMMON_TOKEN RPAR17;
- + pANTLR3_COMMON_TOKEN STRTAG18;
- + pANTLR3_COMMON_TOKEN set19;
- + pANTLR3_COMMON_TOKEN STR20;
- + pANTLR3_COMMON_TOKEN INTTAG21;
- + pANTLR3_COMMON_TOKEN INTBOOL22;
- + pANTLR3_COMMON_TOKEN INT23;
- + pANTLR3_COMMON_TOKEN DATETAG24;
- + pANTLR3_COMMON_TOKEN set25;
- + pANTLR3_COMMON_TOKEN ENUMTAG27;
- + pANTLR3_COMMON_TOKEN IS28;
- + pANTLR3_COMMON_TOKEN ENUMVAL29;
- + SMARTPLParser_expression_return expression16;
- + #undef RETURN_TYPE_expression16
- + #define RETURN_TYPE_expression16 SMARTPLParser_expression_return
- +
- + SMARTPLParser_dateval_return dateval26;
- + #undef RETURN_TYPE_dateval26
- + #define RETURN_TYPE_dateval26 SMARTPLParser_dateval_return
- +
- + pANTLR3_BASE_TREE LPAR15_tree;
- + pANTLR3_BASE_TREE RPAR17_tree;
- + pANTLR3_BASE_TREE STRTAG18_tree;
- + pANTLR3_BASE_TREE set19_tree;
- + pANTLR3_BASE_TREE STR20_tree;
- + pANTLR3_BASE_TREE INTTAG21_tree;
- + pANTLR3_BASE_TREE INTBOOL22_tree;
- + pANTLR3_BASE_TREE INT23_tree;
- + pANTLR3_BASE_TREE DATETAG24_tree;
- + pANTLR3_BASE_TREE set25_tree;
- + pANTLR3_BASE_TREE ENUMTAG27_tree;
- + pANTLR3_BASE_TREE IS28_tree;
- + pANTLR3_BASE_TREE ENUMVAL29_tree;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
- + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expression;
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + LPAR15 = NULL;
- + RPAR17 = NULL;
- + STRTAG18 = NULL;
- + set19 = NULL;
- + STR20 = NULL;
- + INTTAG21 = NULL;
- + INTBOOL22 = NULL;
- + INT23 = NULL;
- + DATETAG24 = NULL;
- + set25 = NULL;
- + ENUMTAG27 = NULL;
- + IS28 = NULL;
- + ENUMVAL29 = NULL;
- + expression16.tree = NULL;
- +
- + dateval26.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + LPAR15_tree = NULL;
- + RPAR17_tree = NULL;
- + STRTAG18_tree = NULL;
- + set19_tree = NULL;
- + STR20_tree = NULL;
- + INTTAG21_tree = NULL;
- + INTBOOL22_tree = NULL;
- + INT23_tree = NULL;
- + DATETAG24_tree = NULL;
- + set25_tree = NULL;
- + ENUMTAG27_tree = NULL;
- + IS28_tree = NULL;
- + ENUMVAL29_tree = NULL;
- +
- + stream_RPAR = NULL;
- + #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
- + stream_LPAR = NULL;
- + #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
- + stream_expression = NULL;
- + #define CREATE_stream_expression if (stream_expression == NULL) {stream_expression = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expression"); }
- +
- + retval.tree = NULL;
- + {
- + {
- + // SMARTPL.g:40:7: ( LPAR expression RPAR -> expression | STRTAG ( INCLUDES | IS ) STR | INTTAG INTBOOL INT | DATETAG ( AFTER | BEFORE ) dateval | ENUMTAG IS ENUMVAL )
- +
- + ANTLR3_UINT32 alt4;
- +
- + alt4=5;
- +
- + switch ( LA(1) )
- + {
- + case LPAR:
- + {
- + alt4=1;
- + }
- + break;
- + case STRTAG:
- + {
- + alt4=2;
- + }
- + break;
- + case INTTAG:
- + {
- + alt4=3;
- + }
- + break;
- + case DATETAG:
- + {
- + alt4=4;
- + }
- + break;
- + case ENUMTAG:
- + {
- + alt4=5;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 4;
- + EXCEPTION->state = 0;
- +
- +
- + goto rulecritEx;
- + }
- +
- + switch (alt4)
- + {
- + case 1:
- + // SMARTPL.g:40:9: LPAR expression RPAR
- + {
- + LPAR15 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit127);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR15, NULL);
- +
- + FOLLOWPUSH(FOLLOW_expression_in_crit129);
- + expression16=expression(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_expression; stream_expression->add(stream_expression, expression16.tree, NULL);
- + RPAR17 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit131);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR17, NULL);
- +
- +
- +
- + /* AST REWRITE
- + * elements : expression
- + * token labels :
- + * rule labels : retval
- + * token list labels :
- + * rule list labels :
- + */
- + {
- + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
- +
- + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
- +
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- + retval.tree = root_0;
- + // 40:30: -> expression
- + {
- + ADAPTOR->addChild(ADAPTOR, root_0, stream_expression == NULL ? NULL : stream_expression->nextTree(stream_expression));
- +
- + }
- +
- + retval.tree = root_0; // set result root
- + if (stream_retval != NULL) stream_retval->free(stream_retval);
- +
- +
- + }
- + }
- + break;
- + case 2:
- + // SMARTPL.g:41:6: STRTAG ( INCLUDES | IS ) STR
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + STRTAG18 = (pANTLR3_COMMON_TOKEN) MATCHT(STRTAG, &FOLLOW_STRTAG_in_crit142);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + STRTAG18_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STRTAG18));
- + ADAPTOR->addChild(ADAPTOR, root_0, STRTAG18_tree);
- +
- + set19=(pANTLR3_COMMON_TOKEN)LT(1);
- + if ( ((LA(1) >= INCLUDES) && (LA(1) <= IS)) )
- + {
- + CONSUME();
- + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set19)));
- + PERRORRECOVERY=ANTLR3_FALSE;
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- + EXCEPTION->expectingSet = &FOLLOW_set_in_crit144;
- + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_crit144); goto rulecritEx;
- + }
- +
- + STR20 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit150);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + STR20_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR20));
- + ADAPTOR->addChild(ADAPTOR, root_0, STR20_tree);
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:42:6: INTTAG INTBOOL INT
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + INTTAG21 = (pANTLR3_COMMON_TOKEN) MATCHT(INTTAG, &FOLLOW_INTTAG_in_crit157);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + INTTAG21_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, INTTAG21));
- + ADAPTOR->addChild(ADAPTOR, root_0, INTTAG21_tree);
- +
- + INTBOOL22 = (pANTLR3_COMMON_TOKEN) MATCHT(INTBOOL, &FOLLOW_INTBOOL_in_crit159);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + INTBOOL22_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, INTBOOL22));
- + ADAPTOR->addChild(ADAPTOR, root_0, INTBOOL22_tree);
- +
- + INT23 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_crit161);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + INT23_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, INT23));
- + ADAPTOR->addChild(ADAPTOR, root_0, INT23_tree);
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:43:6: DATETAG ( AFTER | BEFORE ) dateval
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + DATETAG24 = (pANTLR3_COMMON_TOKEN) MATCHT(DATETAG, &FOLLOW_DATETAG_in_crit168);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + DATETAG24_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, DATETAG24));
- + ADAPTOR->addChild(ADAPTOR, root_0, DATETAG24_tree);
- +
- + set25=(pANTLR3_COMMON_TOKEN)LT(1);
- + if ( ((LA(1) >= AFTER) && (LA(1) <= BEFORE)) )
- + {
- + CONSUME();
- + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set25)));
- + PERRORRECOVERY=ANTLR3_FALSE;
- + }
- + else
- + {
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
- + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
- + EXCEPTION->expectingSet = &FOLLOW_set_in_crit170;
- + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_crit170); goto rulecritEx;
- + }
- +
- + FOLLOWPUSH(FOLLOW_dateval_in_crit176);
- + dateval26=dateval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, dateval26.tree);
- +
- + }
- + break;
- + case 5:
- + // SMARTPL.g:44:6: ENUMTAG IS ENUMVAL
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + ENUMTAG27 = (pANTLR3_COMMON_TOKEN) MATCHT(ENUMTAG, &FOLLOW_ENUMTAG_in_crit183);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ENUMTAG27_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, ENUMTAG27));
- + ADAPTOR->addChild(ADAPTOR, root_0, ENUMTAG27_tree);
- +
- + IS28 = (pANTLR3_COMMON_TOKEN) MATCHT(IS, &FOLLOW_IS_in_crit185);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + IS28_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IS28));
- + ADAPTOR->addChild(ADAPTOR, root_0, IS28_tree);
- +
- + ENUMVAL29 = (pANTLR3_COMMON_TOKEN) MATCHT(ENUMVAL, &FOLLOW_ENUMVAL_in_crit187);
- + if (HASEXCEPTION())
- + {
- + goto rulecritEx;
- + }
- +
- + ENUMVAL29_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, ENUMVAL29));
- + ADAPTOR->addChild(ADAPTOR, root_0, ENUMVAL29_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto rulecritEx; /* Prevent compiler warnings */
- + rulecritEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- + if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
- + if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
- + if (stream_expression != NULL) stream_expression->free(stream_expression);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end crit */
- +
- +/**
- + * $ANTLR start dateval
- + * SMARTPL.g:47:1: dateval : ( DATE | interval BEFORE DATE | interval AFTER DATE | interval AGO );
- + */
- +static SMARTPLParser_dateval_return
- +dateval(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_dateval_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN DATE30;
- + pANTLR3_COMMON_TOKEN BEFORE32;
- + pANTLR3_COMMON_TOKEN DATE33;
- + pANTLR3_COMMON_TOKEN AFTER35;
- + pANTLR3_COMMON_TOKEN DATE36;
- + pANTLR3_COMMON_TOKEN AGO38;
- + SMARTPLParser_interval_return interval31;
- + #undef RETURN_TYPE_interval31
- + #define RETURN_TYPE_interval31 SMARTPLParser_interval_return
- +
- + SMARTPLParser_interval_return interval34;
- + #undef RETURN_TYPE_interval34
- + #define RETURN_TYPE_interval34 SMARTPLParser_interval_return
- +
- + SMARTPLParser_interval_return interval37;
- + #undef RETURN_TYPE_interval37
- + #define RETURN_TYPE_interval37 SMARTPLParser_interval_return
- +
- + pANTLR3_BASE_TREE DATE30_tree;
- + pANTLR3_BASE_TREE BEFORE32_tree;
- + pANTLR3_BASE_TREE DATE33_tree;
- + pANTLR3_BASE_TREE AFTER35_tree;
- + pANTLR3_BASE_TREE DATE36_tree;
- + pANTLR3_BASE_TREE AGO38_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + DATE30 = NULL;
- + BEFORE32 = NULL;
- + DATE33 = NULL;
- + AFTER35 = NULL;
- + DATE36 = NULL;
- + AGO38 = NULL;
- + interval31.tree = NULL;
- +
- + interval34.tree = NULL;
- +
- + interval37.tree = NULL;
- +
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + DATE30_tree = NULL;
- + BEFORE32_tree = NULL;
- + DATE33_tree = NULL;
- + AFTER35_tree = NULL;
- + DATE36_tree = NULL;
- + AGO38_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + {
- + // SMARTPL.g:47:10: ( DATE | interval BEFORE DATE | interval AFTER DATE | interval AGO )
- +
- + ANTLR3_UINT32 alt5;
- +
- + alt5=4;
- +
- + switch ( LA(1) )
- + {
- + case DATE:
- + {
- + alt5=1;
- + }
- + break;
- + case INT:
- + {
- + switch ( LA(2) )
- + {
- + case DATINTERVAL:
- + {
- + switch ( LA(3) )
- + {
- + case AGO:
- + {
- + alt5=4;
- + }
- + break;
- + case AFTER:
- + {
- + alt5=3;
- + }
- + break;
- + case BEFORE:
- + {
- + alt5=2;
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 3;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 2;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + }
- + break;
- +
- + default:
- + CONSTRUCTEX();
- + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
- + EXCEPTION->message = (void *)"";
- + EXCEPTION->decisionNum = 5;
- + EXCEPTION->state = 0;
- +
- +
- + goto ruledatevalEx;
- + }
- +
- + switch (alt5)
- + {
- + case 1:
- + // SMARTPL.g:47:12: DATE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + DATE30 = (pANTLR3_COMMON_TOKEN) MATCHT(DATE, &FOLLOW_DATE_in_dateval200);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + DATE30_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, DATE30));
- + ADAPTOR->addChild(ADAPTOR, root_0, DATE30_tree);
- +
- +
- + }
- + break;
- + case 2:
- + // SMARTPL.g:48:6: interval BEFORE DATE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_interval_in_dateval207);
- + interval31=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, interval31.tree);
- + BEFORE32 = (pANTLR3_COMMON_TOKEN) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateval209);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + BEFORE32_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, BEFORE32));
- + ADAPTOR->addChild(ADAPTOR, root_0, BEFORE32_tree);
- +
- + DATE33 = (pANTLR3_COMMON_TOKEN) MATCHT(DATE, &FOLLOW_DATE_in_dateval211);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + DATE33_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, DATE33));
- + ADAPTOR->addChild(ADAPTOR, root_0, DATE33_tree);
- +
- +
- + }
- + break;
- + case 3:
- + // SMARTPL.g:49:6: interval AFTER DATE
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_interval_in_dateval218);
- + interval34=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, interval34.tree);
- + AFTER35 = (pANTLR3_COMMON_TOKEN) MATCHT(AFTER, &FOLLOW_AFTER_in_dateval220);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + AFTER35_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AFTER35));
- + ADAPTOR->addChild(ADAPTOR, root_0, AFTER35_tree);
- +
- + DATE36 = (pANTLR3_COMMON_TOKEN) MATCHT(DATE, &FOLLOW_DATE_in_dateval222);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + DATE36_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, DATE36));
- + ADAPTOR->addChild(ADAPTOR, root_0, DATE36_tree);
- +
- +
- + }
- + break;
- + case 4:
- + // SMARTPL.g:50:6: interval AGO
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + FOLLOWPUSH(FOLLOW_interval_in_dateval229);
- + interval37=interval(ctx);
- +
- + FOLLOWPOP();
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + ADAPTOR->addChild(ADAPTOR, root_0, interval37.tree);
- + AGO38 = (pANTLR3_COMMON_TOKEN) MATCHT(AGO, &FOLLOW_AGO_in_dateval231);
- + if (HASEXCEPTION())
- + {
- + goto ruledatevalEx;
- + }
- +
- + AGO38_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AGO38));
- + ADAPTOR->addChild(ADAPTOR, root_0, AGO38_tree);
- +
- +
- + }
- + break;
- +
- + }
- + }
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruledatevalEx; /* Prevent compiler warnings */
- + ruledatevalEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end dateval */
- +
- +/**
- + * $ANTLR start interval
- + * SMARTPL.g:53:1: interval : INT DATINTERVAL ;
- + */
- +static SMARTPLParser_interval_return
- +interval(pSMARTPLParser ctx)
- +{
- + SMARTPLParser_interval_return retval;
- +
- + pANTLR3_BASE_TREE root_0;
- +
- + pANTLR3_COMMON_TOKEN INT39;
- + pANTLR3_COMMON_TOKEN DATINTERVAL40;
- +
- + pANTLR3_BASE_TREE INT39_tree;
- + pANTLR3_BASE_TREE DATINTERVAL40_tree;
- +
- + /* Initialize rule variables
- + */
- +
- +
- + root_0 = NULL;
- +
- + INT39 = NULL;
- + DATINTERVAL40 = NULL;
- + retval.start = LT(1); retval.stop = retval.start;
- +
- + INT39_tree = NULL;
- + DATINTERVAL40_tree = NULL;
- +
- +
- + retval.tree = NULL;
- + {
- + // SMARTPL.g:53:10: ( INT DATINTERVAL )
- + // SMARTPL.g:53:12: INT DATINTERVAL
- + {
- + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
- +
- + INT39 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_interval243);
- + if (HASEXCEPTION())
- + {
- + goto ruleintervalEx;
- + }
- +
- + INT39_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, INT39));
- + ADAPTOR->addChild(ADAPTOR, root_0, INT39_tree);
- +
- + DATINTERVAL40 = (pANTLR3_COMMON_TOKEN) MATCHT(DATINTERVAL, &FOLLOW_DATINTERVAL_in_interval245);
- + if (HASEXCEPTION())
- + {
- + goto ruleintervalEx;
- + }
- +
- + DATINTERVAL40_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, DATINTERVAL40));
- + ADAPTOR->addChild(ADAPTOR, root_0, DATINTERVAL40_tree);
- +
- +
- + }
- +
- + }
- +
- +
- + // This is where rules clean up and exit
- + //
- + goto ruleintervalEx; /* Prevent compiler warnings */
- + ruleintervalEx: ;
- + retval.stop = LT(-1);
- +
- + retval.stop = LT(-1);
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
- + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
- +
- + if (HASEXCEPTION())
- + {
- + PREPORTERROR();
- + PRECOVER();
- + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
- + }
- +
- +
- + return retval;
- +}
- +/* $ANTLR end interval */
- +/* End of parsing rules
- + * ==============================================
- + */
- +
- +/* ==============================================
- + * Syntactic predicates
- + */
- +/* End of syntactic predicates
- + * ==============================================
- + */
- +
- +
- +
- +
- +
- +
- +/* End of code
- + * =============================================================================
- + */
- diff --git a/src/pregen/SMARTPLParser.h b/src/pregen/SMARTPLParser.h
- new file mode 100644
- index 0000000..38ef500
- --- /dev/null
- +++ b/src/pregen/SMARTPLParser.h
- @@ -0,0 +1,285 @@
- +/** \file
- + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
- + *
- + * - From the grammar source file : SMARTPL.g
- + * - On : 2016-01-01 12:23:40
- + * - for the parser : SMARTPLParserParser *
- + * Editing it, at least manually, is not wise.
- + *
- + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
- + *
- + *
- + * The parser SMARTPLParser has the callable functions (rules) shown below,
- + * which will invoke the code for the associated rule in the source grammar
- + * assuming that the input stream is pointing to a token/text stream that could begin
- + * this rule.
- + *
- + * For instance if you call the first (topmost) rule in a parser grammar, you will
- + * get the results of a full parse, but calling a rule half way through the grammar will
- + * allow you to pass part of a full token stream to the parser, such as for syntax checking
- + * in editors and so on.
- + *
- + * The parser entry points are called indirectly (by function pointer to function) via
- + * a parser context typedef pSMARTPLParser, which is returned from a call to SMARTPLParserNew().
- + *
- + * The methods in pSMARTPLParser are as follows:
- + *
- + * - SMARTPLParser_playlist_return pSMARTPLParser->playlist(pSMARTPLParser)
- + * - SMARTPLParser_expression_return pSMARTPLParser->expression(pSMARTPLParser)
- + * - SMARTPLParser_aexpr_return pSMARTPLParser->aexpr(pSMARTPLParser)
- + * - SMARTPLParser_nexpr_return pSMARTPLParser->nexpr(pSMARTPLParser)
- + * - SMARTPLParser_crit_return pSMARTPLParser->crit(pSMARTPLParser)
- + * - SMARTPLParser_dateval_return pSMARTPLParser->dateval(pSMARTPLParser)
- + * - SMARTPLParser_interval_return pSMARTPLParser->interval(pSMARTPLParser)
- + *
- + * The return type for any particular rule is of course determined by the source
- + * grammar file.
- + */
- +// [The "BSD licence"]
- +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
- +// http://www.temporal-wave.com
- +// http://www.linkedin.com/in/jimidle
- +//
- +// All rights reserved.
- +//
- +// Redistribution and use in source and binary forms, with or without
- +// modification, are permitted provided that the following conditions
- +// are met:
- +// 1. Redistributions of source code must retain the above copyright
- +// notice, this list of conditions and the following disclaimer.
- +// 2. Redistributions in binary form must reproduce the above copyright
- +// notice, this list of conditions and the following disclaimer in the
- +// documentation and/or other materials provided with the distribution.
- +// 3. The name of the author may not be used to endorse or promote products
- +// derived from this software without specific prior written permission.
- +//
- +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
- +#ifndef _SMARTPLParser_H
- +#define _SMARTPLParser_H
- +/* =============================================================================
- + * Standard antlr3 C runtime definitions
- + */
- +#include <antlr3.h>
- +
- +/* End of standard antlr 3 runtime definitions
- + * =============================================================================
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +// Forward declare the context typedef so that we can use it before it is
- +// properly defined. Delegators and delegates (from import statements) are
- +// interdependent and their context structures contain pointers to each other
- +// C only allows such things to be declared if you pre-declare the typedef.
- +//
- +typedef struct SMARTPLParser_Ctx_struct SMARTPLParser, * pSMARTPLParser;
- +
- +
- +
- +#ifdef ANTLR3_WINDOWS
- +// Disable: Unreferenced parameter, - Rules with parameters that are not used
- +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
- +// initialized but unused variable - tree rewrite variables declared but not needed
- +// Unreferenced local variable - lexer rule declares but does not always use _type
- +// potentially unitialized variable used - retval always returned from a rule
- +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
- +//
- +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
- +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
- +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
- +// this is a matter of orthogonality hence I disable that one.
- +//
- +#pragma warning( disable : 4100 )
- +#pragma warning( disable : 4101 )
- +#pragma warning( disable : 4127 )
- +#pragma warning( disable : 4189 )
- +#pragma warning( disable : 4505 )
- +#pragma warning( disable : 4701 )
- +#endif
- +typedef struct SMARTPLParser_playlist_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_playlist_return;
- +
- +typedef struct SMARTPLParser_expression_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_expression_return;
- +
- +typedef struct SMARTPLParser_aexpr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_aexpr_return;
- +
- +typedef struct SMARTPLParser_nexpr_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_nexpr_return;
- +
- +typedef struct SMARTPLParser_crit_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_crit_return;
- +
- +typedef struct SMARTPLParser_dateval_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_dateval_return;
- +
- +typedef struct SMARTPLParser_interval_return_struct
- +{
- + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
- + */
- + pANTLR3_COMMON_TOKEN start;
- + pANTLR3_COMMON_TOKEN stop;
- + pANTLR3_BASE_TREE tree;
- +
- +}
- + SMARTPLParser_interval_return;
- +
- +
- +
- +/** Context tracking structure for SMARTPLParser
- + */
- +struct SMARTPLParser_Ctx_struct
- +{
- + /** Built in ANTLR3 context tracker contains all the generic elements
- + * required for context tracking.
- + */
- + pANTLR3_PARSER pParser;
- +
- +
- + SMARTPLParser_playlist_return (*playlist) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_expression_return (*expression) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_aexpr_return (*aexpr) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_nexpr_return (*nexpr) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_crit_return (*crit) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_dateval_return (*dateval) (struct SMARTPLParser_Ctx_struct * ctx);
- + SMARTPLParser_interval_return (*interval) (struct SMARTPLParser_Ctx_struct * ctx);
- + // Delegated rules
- + const char * (*getGrammarFileName)();
- + void (*free) (struct SMARTPLParser_Ctx_struct * ctx);
- + /* @headerFile.members() */
- + pANTLR3_BASE_TREE_ADAPTOR adaptor;
- + pANTLR3_VECTOR_FACTORY vectors;
- + /* End @headerFile.members() */
- +};
- +
- +// Function protoypes for the constructor functions that external translation units
- +// such as delegators and delegates may wish to call.
- +//
- +ANTLR3_API pSMARTPLParser SMARTPLParserNew (pANTLR3_COMMON_TOKEN_STREAM instream);
- +ANTLR3_API pSMARTPLParser SMARTPLParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
- +
- +/** Symbolic definitions of all the tokens that the parser will work with.
- + * \{
- + *
- + * Antlr will define EOF, but we can't use that as it it is too common in
- + * in C header files and that would be confusing. There is no way to filter this out at the moment
- + * so we just undef it here for now. That isn't the value we get back from C recognizers
- + * anyway. We are looking for ANTLR3_TOKEN_EOF.
- + */
- +#ifdef EOF
- +#undef EOF
- +#endif
- +#ifdef Tokens
- +#undef Tokens
- +#endif
- +#define INTBOOL 14
- +#define STRTAG 10
- +#define AGO 22
- +#define WHITESPACE 29
- +#define GREATEREQUAL 25
- +#define BEFORE 18
- +#define DATETAG 16
- +#define INT 15
- +#define NOT 7
- +#define AFTER 17
- +#define AND 6
- +#define EOF -1
- +#define INCLUDES 11
- +#define STR 4
- +#define T__30 30
- +#define T__31 31
- +#define GREATER 24
- +#define LPAR 8
- +#define ENUMTAG 19
- +#define IS 12
- +#define ENUMVAL 20
- +#define EQUAL 28
- +#define OR 5
- +#define LESS 26
- +#define RPAR 9
- +#define DATE 21
- +#define LESSEQUAL 27
- +#define DATINTERVAL 23
- +#define INTTAG 13
- +#ifdef EOF
- +#undef EOF
- +#define EOF ANTLR3_TOKEN_EOF
- +#endif
- +
- +#ifndef TOKENSOURCE
- +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
- +#endif
- +
- +/* End of token definitions for SMARTPLParser
- + * =============================================================================
- + */
- +/** \} */
- +
- +#ifdef __cplusplus
- +}
- +#endif
- +
- +#endif
- +
- +/* END - Note:Keep extra line feed to satisfy UNIX systems */
|