_vs1.0_lexer.cpp 129 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041
  1. #include <ctype.h>
  2. #define yy_create_buffer vs10__create_buffer
  3. #define yy_delete_buffer vs10__delete_buffer
  4. #define yy_scan_buffer vs10__scan_buffer
  5. #define yy_scan_string vs10__scan_string
  6. #define yy_scan_bytes vs10__scan_bytes
  7. #define yy_flex_debug vs10__flex_debug
  8. #define yy_init_buffer vs10__init_buffer
  9. #define yy_flush_buffer vs10__flush_buffer
  10. #define yy_load_buffer_state vs10__load_buffer_state
  11. #define yy_switch_to_buffer vs10__switch_to_buffer
  12. #define yyin vs10_in
  13. #define yyleng vs10_leng
  14. #define yylex vs10_lex
  15. #define yyout vs10_out
  16. #define yyrestart vs10_restart
  17. #define yytext vs10_text
  18. #define yywrap vs10_wrap
  19. #line 20 "_vs1.0_lexer.cpp"
  20. /* A lexical scanner generated by flex */
  21. /* Scanner skeleton version:
  22. * $Header: /home/shared/backups/ogre/cvs/ogrenew/RenderSystems/GL/src/nvparse/_vs1.0_lexer.cpp,v 1.4 2005-11-10 07:24:20 nfz Exp $
  23. */
  24. #define FLEX_SCANNER
  25. #define YY_FLEX_MAJOR_VERSION 2
  26. #define YY_FLEX_MINOR_VERSION 5
  27. #include <stdio.h>
  28. #include <unistd.h>
  29. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  30. #ifdef c_plusplus
  31. #ifndef __cplusplus
  32. #define __cplusplus
  33. #endif
  34. #endif
  35. #ifdef __cplusplus
  36. #include <stdlib.h>
  37. /* Use prototypes in function declarations. */
  38. #define YY_USE_PROTOS
  39. /* The "const" storage-class-modifier is valid. */
  40. #define YY_USE_CONST
  41. /* yyunput is never used */
  42. #define YY_NO_UNPUT
  43. #else /* ! __cplusplus */
  44. #if __STDC__
  45. #define YY_USE_PROTOS
  46. #define YY_USE_CONST
  47. #endif /* __STDC__ */
  48. #endif /* ! __cplusplus */
  49. #ifdef __TURBOC__
  50. #pragma warn -rch
  51. #pragma warn -use
  52. #include <io.h>
  53. #include <stdlib.h>
  54. #define YY_USE_CONST
  55. #define YY_USE_PROTOS
  56. #endif
  57. #ifdef YY_USE_CONST
  58. #define yyconst const
  59. #else
  60. #define yyconst
  61. #endif
  62. #ifdef YY_USE_PROTOS
  63. #define YY_PROTO(proto) proto
  64. #else
  65. #define YY_PROTO(proto) ()
  66. #endif
  67. /* Returned upon end-of-file. */
  68. #define YY_NULL 0
  69. /* Promotes a possibly negative, possibly signed char to an unsigned
  70. * integer for use as an array index. If the signed char is negative,
  71. * we want to instead treat it as an 8-bit unsigned char, hence the
  72. * double cast.
  73. */
  74. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  75. /* Enter a start condition. This macro really ought to take a parameter,
  76. * but we do it the disgusting crufty way forced on us by the ()-less
  77. * definition of BEGIN.
  78. */
  79. #define BEGIN yy_start = 1 + 2 *
  80. /* Translate the current start state into a value that can be later handed
  81. * to BEGIN to return to the state. The YYSTATE alias is for lex
  82. * compatibility.
  83. */
  84. #define YY_START ((yy_start - 1) / 2)
  85. #define YYSTATE YY_START
  86. /* Action number for EOF rule of a given start state. */
  87. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  88. /* Special action meaning "start processing a new file". */
  89. #define YY_NEW_FILE yyrestart( yyin )
  90. #define YY_END_OF_BUFFER_CHAR 0
  91. /* Size of default input buffer. */
  92. #define YY_BUF_SIZE 16384
  93. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  94. extern int yyleng;
  95. extern FILE *yyin, *yyout;
  96. #define EOB_ACT_CONTINUE_SCAN 0
  97. #define EOB_ACT_END_OF_FILE 1
  98. #define EOB_ACT_LAST_MATCH 2
  99. /* The funky do-while in the following #define is used to turn the definition
  100. * int a single C statement (which needs a semi-colon terminator). This
  101. * avoids problems with code like:
  102. *
  103. * if ( condition_holds )
  104. * yyless( 5 );
  105. * else
  106. * do_something_else();
  107. *
  108. * Prior to using the do-while the compiler would get upset at the
  109. * "else" because it interpreted the "if" statement as being all
  110. * done when it reached the ';' after the yyless() call.
  111. */
  112. /* Return all but the first 'n' matched characters back to the input stream. */
  113. #define yyless(n) \
  114. do \
  115. { \
  116. /* Undo effects of setting up yytext. */ \
  117. *yy_cp = yy_hold_char; \
  118. YY_RESTORE_YY_MORE_OFFSET \
  119. yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
  120. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  121. } \
  122. while ( 0 )
  123. #define unput(c) yyunput( c, yytext_ptr )
  124. /* The following is because we cannot portably get our hands on size_t
  125. * (without autoconf's help, which isn't available because we want
  126. * flex-generated scanners to compile on their own).
  127. */
  128. typedef unsigned int yy_size_t;
  129. struct yy_buffer_state
  130. {
  131. FILE *yy_input_file;
  132. char *yy_ch_buf; /* input buffer */
  133. char *yy_buf_pos; /* current position in input buffer */
  134. /* Size of input buffer in bytes, not including room for EOB
  135. * characters.
  136. */
  137. yy_size_t yy_buf_size;
  138. /* Number of characters read into yy_ch_buf, not including EOB
  139. * characters.
  140. */
  141. int yy_n_chars;
  142. /* Whether we "own" the buffer - i.e., we know we created it,
  143. * and can realloc() it to grow it, and should free() it to
  144. * delete it.
  145. */
  146. int yy_is_our_buffer;
  147. /* Whether this is an "interactive" input source; if so, and
  148. * if we're using stdio for input, then we want to use getc()
  149. * instead of fread(), to make sure we stop fetching input after
  150. * each newline.
  151. */
  152. int yy_is_interactive;
  153. /* Whether we're considered to be at the beginning of a line.
  154. * If so, '^' rules will be active on the next match, otherwise
  155. * not.
  156. */
  157. int yy_at_bol;
  158. /* Whether to try to fill the input buffer when we reach the
  159. * end of it.
  160. */
  161. int yy_fill_buffer;
  162. int yy_buffer_status;
  163. #define YY_BUFFER_NEW 0
  164. #define YY_BUFFER_NORMAL 1
  165. /* When an EOF's been seen but there's still some text to process
  166. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  167. * shouldn't try reading from the input source any more. We might
  168. * still have a bunch of tokens to match, though, because of
  169. * possible backing-up.
  170. *
  171. * When we actually see the EOF, we change the status to "new"
  172. * (via yyrestart()), so that the user can continue scanning by
  173. * just pointing yyin at a new input file.
  174. */
  175. #define YY_BUFFER_EOF_PENDING 2
  176. };
  177. static YY_BUFFER_STATE yy_current_buffer = 0;
  178. /* We provide macros for accessing buffer states in case in the
  179. * future we want to put the buffer states in a more general
  180. * "scanner state".
  181. */
  182. #define YY_CURRENT_BUFFER yy_current_buffer
  183. /* yy_hold_char holds the character lost when yytext is formed. */
  184. static char yy_hold_char;
  185. static int yy_n_chars; /* number of characters read into yy_ch_buf */
  186. int yyleng;
  187. /* Points to current character in buffer. */
  188. static char *yy_c_buf_p = (char *) 0;
  189. static int yy_init = 1; /* whether we need to initialize */
  190. static int yy_start = 0; /* start state number */
  191. /* Flag which is used to allow yywrap()'s to do buffer switches
  192. * instead of setting up a fresh yyin. A bit of a hack ...
  193. */
  194. static int yy_did_buffer_switch_on_eof;
  195. void yyrestart YY_PROTO(( FILE *input_file ));
  196. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  197. void yy_load_buffer_state YY_PROTO(( void ));
  198. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  199. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  200. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  201. void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  202. #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
  203. YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
  204. YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
  205. YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
  206. static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
  207. #if !defined(YY_USES_REJECT) && defined(YY_NO_PUSH_STATE)
  208. static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
  209. #endif
  210. static void yy_flex_free YY_PROTO(( void * ));
  211. #define yy_new_buffer yy_create_buffer
  212. #define yy_set_interactive(is_interactive) \
  213. { \
  214. if ( ! yy_current_buffer ) \
  215. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  216. yy_current_buffer->yy_is_interactive = is_interactive; \
  217. }
  218. #define yy_set_bol(at_bol) \
  219. { \
  220. if ( ! yy_current_buffer ) \
  221. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  222. yy_current_buffer->yy_at_bol = at_bol; \
  223. }
  224. #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
  225. #define YY_USES_REJECT
  226. typedef unsigned char YY_CHAR;
  227. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  228. typedef int yy_state_type;
  229. extern char *yytext;
  230. #define yytext_ptr yytext
  231. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  232. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  233. static int yy_get_next_buffer YY_PROTO(( void ));
  234. static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
  235. /* Done after the current pattern has been matched and before the
  236. * corresponding action - sets up yytext.
  237. */
  238. #define YY_DO_BEFORE_ACTION \
  239. yytext_ptr = yy_bp; \
  240. yyleng = (int) (yy_cp - yy_bp); \
  241. yy_hold_char = *yy_cp; \
  242. *yy_cp = '\0'; \
  243. yy_c_buf_p = yy_cp;
  244. #define YY_NUM_RULES 72
  245. #define YY_END_OF_BUFFER 73
  246. static yyconst short int yy_acclist[406] =
  247. { 0,
  248. 2, 2, 56, 56, 46, 46, 31, 31, 29, 29,
  249. 73, 69, 71, 72, 64, 69, 71, 72, 66, 69,
  250. 72, 71, 72, 71, 72, 63, 71, 72, 63, 71,
  251. 72, 37, 63, 71, 72, 63, 71, 72, 36, 71,
  252. 72, 13, 71, 72, 62, 71, 72, 62, 63, 71,
  253. 72, 62, 71, 72, 62, 71, 72, 62, 71, 72,
  254. 62, 71, 72, 62, 71, 72, 64, 69, 71, 72,
  255. 16, 63, 71, 72, 72, 72, 22, 65, 72, 21,
  256. 72, 23, 72, 72, 34, 72, 72, 20, 72, 68,
  257. 70, 72, 68, 72, 70, 72, 67, 70, 72, 2,
  258. 72, 1, 72, 41, 72, 41, 42, 72, 56, 72,
  259. 56, 72, 57, 72, 56, 72, 56, 72, 56, 72,
  260. 50, 72, 46, 50, 72, 49, 72, 48, 72, 50,
  261. 72, 47, 50, 72, 72, 72, 59, 72, 72, 72,
  262. 61, 72, 72, 40, 72, 40, 62, 72, 39, 40,
  263. 62, 72, 45, 72, 44, 45, 72, 43, 45, 72,
  264. 72, 27, 72, 31, 72, 31, 72, 32, 72, 31,
  265. 72, 29, 72, 30, 72, 51, 72, 64, 15, 17,
  266. 14, 36, 13, 62, 62, 3, 62, 6, 62, 62,
  267. 62, 62, 62, 5, 62, 4, 62, 62, 64, 16,
  268. 16, 19, 34, 20, 67, 2, 1, 41, 56, 56,
  269. 56, 56, 17, 56, 56, 54, 56, 50, 46, 50,
  270. 47, 50, 47, 50, 47, 59, 61, 60, 61, 39,
  271. 39, 39, 62, 44, 27, 31, 31, 31, 31, 29,
  272. 51, 53, 51, 51, 14, 12, 12, 62, 3, 12,
  273. 3, 12, 6, 12, 6, 12, 8, 62, 62, 62,
  274. 62, 7, 62, 5, 12, 5, 12, 4, 12, 4,
  275. 12, 16, 56, 39, 62, 31, 31, 31, 52, 3,
  276. 3, 6, 6, 8, 12, 8, 12, 9, 62, 10,
  277. 62, 11, 62, 7, 12, 7, 12, 5, 5, 4,
  278. 4, 55, 56, 38, 39, 62, 31, 31, 26, 8,
  279. 8, 9, 12, 9, 12, 10, 12, 10, 12, 11,
  280. 12, 11, 12, 7, 7, 55, 56, 56, 55, 56,
  281. 58, 59, 38, 39, 38, 39, 26, 31, 31, 26,
  282. 26, 28, 9, 9, 10, 10, 11, 11, 35, 55,
  283. 56, 55, 56, 55, 56, 55, 56, 26, 31, 31,
  284. 26, 31, 28, 31, 26, 26, 26, 28, 28, 24,
  285. 35, 35, 55, 56, 55, 56, 26, 31, 26, 31,
  286. 26, 31, 28, 31, 31, 28, 31, 33, 26, 28,
  287. 28, 28, 25, 26, 31, 28, 31, 28, 31, 28,
  288. 31, 28, 18, 28, 31
  289. } ;
  290. static yyconst short int yy_accept[330] =
  291. { 0,
  292. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  293. 1, 1, 1, 1, 1, 1, 1, 2, 3, 3,
  294. 3, 4, 5, 6, 7, 7, 7, 7, 7, 7,
  295. 7, 7, 7, 7, 7, 8, 9, 10, 11, 11,
  296. 11, 12, 15, 19, 22, 24, 26, 29, 32, 36,
  297. 39, 42, 45, 48, 52, 55, 58, 61, 64, 67,
  298. 71, 75, 76, 77, 80, 82, 84, 85, 87, 88,
  299. 90, 93, 95, 97, 100, 102, 104, 106, 109, 111,
  300. 113, 115, 117, 119, 121, 123, 126, 128, 130, 132,
  301. 135, 136, 137, 139, 140, 141, 143, 144, 146, 149,
  302. 153, 155, 158, 161, 162, 164, 166, 168, 170, 172,
  303. 174, 176, 178, 179, 179, 179, 179, 179, 179, 180,
  304. 181, 182, 183, 184, 185, 186, 188, 190, 191, 192,
  305. 193, 194, 196, 198, 199, 200, 201, 202, 202, 203,
  306. 203, 204, 204, 205, 206, 207, 208, 209, 210, 211,
  307. 212, 213, 215, 216, 217, 218, 219, 221, 223, 225,
  308. 226, 226, 227, 227, 227, 227, 227, 228, 228, 230,
  309. 231, 232, 234, 235, 235, 236, 237, 238, 239, 240,
  310. 241, 243, 244, 244, 244, 245, 245, 245, 245, 245,
  311. 245, 245, 246, 247, 249, 251, 253, 255, 257, 259,
  312. 260, 261, 262, 264, 266, 268, 270, 272, 272, 273,
  313. 274, 274, 276, 277, 278, 279, 279, 280, 280, 280,
  314. 280, 280, 280, 280, 281, 282, 283, 284, 286, 288,
  315. 290, 292, 294, 296, 298, 299, 300, 301, 302, 302,
  316. 304, 304, 307, 308, 309, 309, 310, 310, 310, 310,
  317. 310, 311, 312, 314, 316, 318, 320, 322, 324, 325,
  318. 326, 326, 328, 329, 331, 331, 333, 335, 337, 339,
  319. 340, 340, 341, 341, 342, 343, 343, 343, 343, 344,
  320. 345, 346, 347, 348, 349, 350, 352, 354, 356, 358,
  321. 360, 361, 363, 365, 365, 366, 367, 368, 369, 369,
  322. 370, 371, 371, 371, 372, 373, 375, 377, 379, 381,
  323. 383, 385, 386, 388, 389, 390, 391, 392, 393, 394,
  324. 394, 396, 398, 400, 402, 403, 404, 406, 406
  325. } ;
  326. static yyconst int yy_ec[256] =
  327. { 0,
  328. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  329. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  330. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  331. 1, 2, 4, 4, 5, 4, 6, 4, 4, 7,
  332. 8, 9, 10, 11, 6, 12, 13, 14, 14, 14,
  333. 14, 14, 14, 14, 14, 14, 14, 4, 15, 6,
  334. 4, 6, 4, 4, 16, 16, 16, 17, 16, 18,
  335. 16, 16, 16, 16, 16, 16, 16, 16, 16, 19,
  336. 16, 16, 16, 20, 16, 16, 16, 16, 16, 16,
  337. 6, 21, 6, 4, 22, 4, 23, 16, 24, 25,
  338. 26, 27, 28, 16, 29, 16, 16, 30, 31, 32,
  339. 33, 16, 16, 34, 35, 36, 37, 38, 39, 39,
  340. 39, 39, 4, 4, 4, 4, 4, 4, 4, 4,
  341. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  342. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  343. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  344. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  345. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  346. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  347. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  348. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  349. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  350. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  351. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  352. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  353. 4, 4, 4, 4, 4
  354. } ;
  355. static yyconst int yy_meta[40] =
  356. { 0,
  357. 1, 2, 3, 1, 1, 1, 2, 1, 1, 1,
  358. 4, 1, 1, 5, 1, 5, 5, 5, 5, 5,
  359. 1, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  360. 5, 5, 5, 5, 5, 5, 5, 5, 5
  361. } ;
  362. static yyconst short int yy_base[369] =
  363. { 0,
  364. 0, 38, 764, 763, 761, 760, 759, 758, 757, 756,
  365. 755, 754, 753, 752, 48, 69, 751, 750, 39, 84,
  366. 86, 90, 93, 107, 41, 95, 44, 80, 122, 0,
  367. 112, 160, 749, 748, 163, 167, 747, 746, 740, 739,
  368. 746, 767, 100, 767, 767, 148, 767, 173, 767, 53,
  369. 731, 0, 722, 0, 157, 164, 163, 170, 173, 186,
  370. 187, 740, 767, 767, 767, 767, 739, 767, 738, 767,
  371. 767, 767, 767, 0, 737, 767, 0, 0, 718, 191,
  372. 767, 185, 195, 178, 0, 736, 767, 767, 724, 725,
  373. 732, 198, 767, 199, 200, 767, 201, 767, 0, 211,
  374. 767, 732, 767, 730, 767, 0, 213, 767, 706, 0,
  375. 767, 217, 221, 705, 704, 175, 201, 232, 767, 767,
  376. 0, 715, 0, 234, 0, 237, 239, 241, 243, 245,
  377. 255, 268, 270, 277, 281, 726, 272, 724, 767, 723,
  378. 767, 722, 767, 0, 721, 767, 0, 702, 285, 283,
  379. 228, 701, 291, 767, 43, 0, 719, 709, 708, 0,
  380. 715, 767, 293, 222, 295, 206, 767, 208, 767, 298,
  381. 767, 300, 715, 713, 767, 0, 303, 689, 232, 0,
  382. 308, 711, 700, 709, 294, 679, 683, 674, 683, 282,
  383. 683, 0, 767, 0, 314, 767, 322, 767, 324, 328,
  384. 330, 332, 339, 334, 767, 341, 767, 692, 703, 297,
  385. 82, 345, 672, 668, 675, 692, 767, 661, 659, 651,
  386. 644, 640, 630, 355, 767, 357, 767, 360, 767, 366,
  387. 368, 370, 372, 767, 374, 767, 376, 767, 254, 378,
  388. 379, 383, 629, 606, 599, 381, 603, 598, 593, 558,
  389. 395, 767, 398, 767, 400, 767, 402, 767, 404, 767,
  390. 502, 406, 374, 396, 410, 767, 412, 767, 416, 453,
  391. 439, 420, 445, 336, 421, 452, 423, 395, 422, 767,
  392. 435, 767, 437, 767, 439, 430, 431, 434, 454, 446,
  393. 403, 351, 458, 408, 413, 417, 449, 461, 376, 453,
  394. 353, 343, 314, 475, 767, 466, 480, 457, 471, 475,
  395. 483, 309, 476, 311, 479, 484, 487, 490, 250, 162,
  396. 491, 494, 495, 498, 499, 115, 502, 767, 517, 522,
  397. 527, 532, 537, 542, 547, 552, 557, 562, 567, 572,
  398. 577, 582, 587, 592, 95, 89, 597, 602, 607, 40,
  399. 612, 617, 622, 627, 632, 637, 642, 647, 652, 657,
  400. 662, 667, 672, 677, 682, 687, 692, 697
  401. } ;
  402. static yyconst short int yy_def[369] =
  403. { 0,
  404. 328, 1, 329, 329, 330, 330, 330, 330, 330, 330,
  405. 331, 331, 332, 332, 333, 333, 334, 334, 335, 335,
  406. 336, 336, 337, 337, 338, 338, 339, 339, 328, 29,
  407. 340, 340, 341, 341, 342, 342, 343, 343, 330, 330,
  408. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  409. 328, 344, 345, 346, 345, 345, 345, 345, 345, 328,
  410. 328, 347, 328, 328, 328, 328, 348, 328, 349, 328,
  411. 328, 328, 328, 350, 351, 328, 352, 352, 353, 353,
  412. 328, 353, 353, 353, 354, 354, 328, 328, 354, 355,
  413. 356, 356, 328, 356, 357, 328, 357, 328, 346, 346,
  414. 328, 328, 328, 358, 328, 359, 359, 328, 359, 360,
  415. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  416. 361, 328, 344, 345, 346, 345, 345, 345, 345, 345,
  417. 345, 345, 345, 345, 328, 328, 328, 347, 328, 348,
  418. 328, 349, 328, 350, 351, 328, 352, 353, 353, 353,
  419. 353, 353, 353, 328, 353, 354, 354, 355, 355, 362,
  420. 356, 328, 356, 356, 356, 357, 328, 357, 328, 328,
  421. 328, 346, 328, 358, 328, 359, 359, 359, 359, 360,
  422. 328, 328, 328, 363, 328, 328, 328, 328, 328, 328,
  423. 328, 361, 328, 346, 328, 328, 328, 328, 345, 345,
  424. 345, 345, 345, 328, 328, 328, 328, 328, 328, 353,
  425. 356, 346, 359, 359, 359, 363, 328, 328, 328, 328,
  426. 328, 328, 328, 328, 328, 328, 328, 328, 328, 345,
  427. 345, 345, 328, 328, 328, 328, 328, 328, 328, 353,
  428. 356, 346, 359, 359, 328, 328, 328, 328, 328, 328,
  429. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  430. 328, 353, 353, 364, 356, 328, 328, 328, 359, 359,
  431. 328, 328, 328, 365, 328, 328, 328, 328, 328, 328,
  432. 328, 328, 328, 328, 328, 364, 364, 364, 364, 359,
  433. 359, 366, 359, 328, 365, 365, 365, 328, 328, 367,
  434. 328, 328, 328, 328, 328, 364, 364, 366, 366, 366,
  435. 359, 359, 368, 328, 365, 367, 367, 367, 328, 328,
  436. 366, 368, 368, 368, 367, 328, 368, 0, 328, 328,
  437. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  438. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  439. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  440. 328, 328, 328, 328, 328, 328, 328, 328
  441. } ;
  442. static yyconst short int yy_nxt[807] =
  443. { 0,
  444. 42, 43, 44, 45, 46, 47, 47, 47, 47, 48,
  445. 47, 49, 50, 51, 52, 53, 53, 53, 53, 53,
  446. 45, 54, 55, 56, 53, 53, 53, 53, 53, 53,
  447. 53, 53, 57, 58, 53, 53, 53, 59, 53, 60,
  448. 63, 78, 92, 93, 144, 63, 96, 61, 71, 71,
  449. 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
  450. 73, 120, 73, 149, 97, 121, 94, 210, 73, 71,
  451. 71, 72, 73, 73, 73, 73, 73, 73, 73, 73,
  452. 73, 73, 96, 73, 162, 63, 78, 80, 81, 73,
  453. 63, 80, 81, 125, 86, 87, 92, 93, 82, 124,
  454. 97, 113, 82, 88, 114, 89, 83, 90, 86, 87,
  455. 83, 84, 241, 102, 63, 84, 326, 88, 103, 89,
  456. 94, 90, 98, 98, 63, 98, 98, 98, 98, 98,
  457. 98, 98, 98, 98, 98, 98, 98, 99, 99, 99,
  458. 99, 99, 98, 99, 99, 99, 99, 99, 99, 99,
  459. 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
  460. 100, 102, 63, 326, 107, 108, 103, 109, 107, 108,
  461. 126, 109, 115, 116, 118, 119, 117, 127, 125, 128,
  462. 129, 130, 131, 132, 125, 125, 133, 135, 137, 119,
  463. 114, 125, 150, 152, 125, 136, 153, 154, 149, 163,
  464. 162, 162, 167, 169, 188, 149, 189, 134, 167, 155,
  465. 169, 149, 170, 171, 177, 149, 151, 178, 181, 182,
  466. 168, 168, 113, 164, 162, 114, 168, 190, 168, 183,
  467. 165, 184, 191, 118, 119, 193, 193, 185, 195, 196,
  468. 197, 198, 193, 193, 193, 193, 193, 193, 149, 172,
  469. 126, 319, 127, 165, 199, 194, 193, 193, 194, 155,
  470. 194, 214, 194, 215, 194, 261, 194, 239, 203, 204,
  471. 205, 206, 207, 137, 119, 200, 194, 201, 193, 193,
  472. 202, 132, 135, 133, 150, 114, 153, 154, 208, 194,
  473. 136, 194, 153, 154, 163, 162, 182, 162, 194, 170,
  474. 171, 170, 171, 149, 177, 149, 221, 178, 151, 181,
  475. 182, 149, 314, 222, 185, 224, 225, 149, 164, 211,
  476. 183, 313, 184, 226, 227, 228, 229, 240, 185, 193,
  477. 193, 193, 193, 193, 193, 235, 236, 199, 212, 320,
  478. 233, 234, 237, 238, 319, 194, 170, 171, 296, 194,
  479. 297, 194, 203, 194, 301, 230, 224, 225, 226, 227,
  480. 194, 251, 252, 309, 231, 310, 232, 253, 254, 255,
  481. 256, 257, 258, 259, 260, 235, 236, 237, 238, 262,
  482. 265, 266, 272, 242, 267, 268, 264, 194, 300, 194,
  483. 263, 194, 264, 273, 149, 274, 251, 252, 149, 279,
  484. 280, 281, 282, 283, 284, 259, 260, 262, 287, 314,
  485. 288, 265, 266, 267, 268, 292, 289, 290, 263, 303,
  486. 264, 272, 298, 279, 280, 296, 149, 297, 291, 315,
  487. 292, 297, 273, 299, 274, 300, 281, 282, 283, 284,
  488. 304, 305, 287, 306, 288, 288, 287, 290, 288, 302,
  489. 289, 289, 285, 301, 289, 307, 154, 274, 291, 311,
  490. 292, 296, 298, 297, 294, 317, 287, 318, 288, 309,
  491. 312, 310, 313, 299, 289, 300, 304, 305, 306, 293,
  492. 288, 307, 154, 321, 311, 310, 289, 309, 323, 310,
  493. 324, 315, 287, 297, 288, 312, 317, 313, 318, 325,
  494. 289, 318, 317, 321, 318, 310, 323, 327, 324, 324,
  495. 323, 325, 324, 318, 327, 285, 324, 62, 62, 62,
  496. 62, 62, 63, 63, 63, 63, 63, 67, 67, 67,
  497. 67, 67, 69, 69, 69, 69, 69, 74, 74, 74,
  498. 74, 74, 75, 75, 75, 75, 75, 77, 77, 77,
  499. 77, 77, 79, 79, 79, 79, 79, 85, 85, 85,
  500. 85, 85, 91, 91, 91, 91, 91, 95, 95, 95,
  501. 95, 95, 101, 101, 101, 101, 101, 104, 104, 104,
  502. 104, 104, 106, 106, 106, 106, 106, 110, 110, 110,
  503. 110, 110, 123, 123, 278, 123, 123, 138, 138, 138,
  504. 138, 138, 140, 140, 140, 140, 140, 142, 142, 142,
  505. 142, 142, 145, 145, 145, 145, 145, 147, 277, 147,
  506. 147, 147, 148, 148, 276, 148, 148, 156, 156, 275,
  507. 271, 156, 159, 159, 270, 159, 159, 161, 161, 161,
  508. 161, 161, 166, 166, 166, 166, 166, 174, 174, 174,
  509. 174, 174, 176, 176, 269, 176, 176, 180, 180, 250,
  510. 180, 180, 192, 192, 249, 192, 192, 160, 160, 248,
  511. 160, 160, 216, 216, 216, 216, 216, 286, 286, 247,
  512. 286, 286, 295, 295, 246, 295, 295, 308, 308, 245,
  513. 308, 308, 316, 316, 217, 316, 316, 322, 322, 244,
  514. 322, 322, 243, 215, 209, 239, 223, 220, 219, 218,
  515. 189, 217, 184, 182, 213, 175, 173, 162, 160, 160,
  516. 157, 149, 149, 146, 143, 141, 139, 209, 122, 187,
  517. 186, 179, 175, 173, 162, 160, 158, 157, 149, 146,
  518. 143, 141, 139, 125, 122, 328, 112, 112, 111, 111,
  519. 105, 105, 76, 76, 70, 70, 68, 68, 66, 66,
  520. 65, 65, 64, 64, 63, 63, 41, 328, 328, 328,
  521. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  522. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  523. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  524. 328, 328, 328, 328, 328, 328
  525. } ;
  526. static yyconst short int yy_chk[807] =
  527. { 0,
  528. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  529. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  530. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  531. 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
  532. 19, 19, 25, 25, 350, 19, 27, 2, 15, 15,
  533. 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
  534. 15, 50, 15, 155, 27, 50, 25, 155, 15, 16,
  535. 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  536. 16, 16, 28, 16, 211, 20, 20, 21, 21, 16,
  537. 20, 22, 22, 346, 23, 23, 26, 26, 21, 345,
  538. 28, 43, 22, 23, 43, 23, 21, 23, 24, 24,
  539. 22, 21, 211, 31, 31, 22, 326, 24, 31, 24,
  540. 26, 24, 29, 29, 29, 29, 29, 29, 29, 29,
  541. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  542. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  543. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  544. 29, 32, 32, 320, 35, 35, 32, 35, 36, 36,
  545. 55, 36, 46, 46, 48, 48, 46, 56, 55, 57,
  546. 57, 57, 57, 58, 57, 56, 59, 60, 61, 61,
  547. 60, 58, 80, 82, 59, 60, 83, 83, 84, 92,
  548. 92, 94, 95, 97, 116, 82, 116, 59, 166, 84,
  549. 168, 80, 100, 100, 107, 83, 80, 107, 112, 112,
  550. 95, 97, 113, 92, 164, 113, 166, 117, 168, 112,
  551. 94, 112, 117, 118, 118, 124, 124, 112, 126, 126,
  552. 127, 127, 128, 128, 129, 129, 130, 130, 151, 100,
  553. 126, 319, 127, 164, 128, 124, 131, 131, 126, 151,
  554. 127, 179, 128, 179, 129, 239, 130, 239, 131, 132,
  555. 132, 133, 133, 137, 137, 129, 131, 130, 134, 134,
  556. 130, 132, 135, 133, 150, 135, 149, 149, 134, 132,
  557. 135, 133, 153, 153, 163, 163, 185, 165, 134, 170,
  558. 170, 172, 172, 150, 177, 149, 190, 177, 150, 181,
  559. 181, 153, 314, 190, 185, 195, 195, 210, 163, 165,
  560. 181, 312, 181, 197, 197, 199, 199, 210, 181, 200,
  561. 200, 201, 201, 202, 202, 204, 204, 199, 172, 303,
  562. 203, 203, 206, 206, 302, 199, 212, 212, 274, 200,
  563. 274, 201, 203, 202, 301, 200, 224, 224, 226, 226,
  564. 203, 228, 228, 292, 201, 292, 202, 230, 230, 231,
  565. 231, 232, 232, 233, 233, 235, 235, 237, 237, 240,
  566. 241, 241, 246, 212, 242, 242, 263, 230, 299, 231,
  567. 240, 232, 240, 246, 263, 246, 251, 251, 240, 253,
  568. 253, 255, 255, 257, 257, 259, 259, 262, 264, 294,
  569. 264, 265, 265, 267, 267, 291, 264, 269, 262, 278,
  570. 262, 272, 275, 279, 279, 295, 262, 295, 269, 296,
  571. 269, 296, 272, 275, 272, 275, 281, 281, 283, 283,
  572. 285, 285, 286, 287, 286, 287, 288, 290, 288, 277,
  573. 286, 287, 285, 276, 288, 289, 289, 273, 290, 293,
  574. 290, 297, 298, 297, 271, 300, 289, 300, 289, 308,
  575. 293, 308, 293, 298, 289, 298, 304, 304, 306, 270,
  576. 306, 307, 307, 309, 311, 309, 306, 310, 313, 310,
  577. 313, 315, 307, 315, 307, 311, 316, 311, 316, 317,
  578. 307, 317, 318, 321, 318, 321, 322, 323, 322, 323,
  579. 324, 325, 324, 325, 327, 261, 327, 329, 329, 329,
  580. 329, 329, 330, 330, 330, 330, 330, 331, 331, 331,
  581. 331, 331, 332, 332, 332, 332, 332, 333, 333, 333,
  582. 333, 333, 334, 334, 334, 334, 334, 335, 335, 335,
  583. 335, 335, 336, 336, 336, 336, 336, 337, 337, 337,
  584. 337, 337, 338, 338, 338, 338, 338, 339, 339, 339,
  585. 339, 339, 340, 340, 340, 340, 340, 341, 341, 341,
  586. 341, 341, 342, 342, 342, 342, 342, 343, 343, 343,
  587. 343, 343, 344, 344, 250, 344, 344, 347, 347, 347,
  588. 347, 347, 348, 348, 348, 348, 348, 349, 349, 349,
  589. 349, 349, 351, 351, 351, 351, 351, 352, 249, 352,
  590. 352, 352, 353, 353, 248, 353, 353, 354, 354, 247,
  591. 245, 354, 355, 355, 244, 355, 355, 356, 356, 356,
  592. 356, 356, 357, 357, 357, 357, 357, 358, 358, 358,
  593. 358, 358, 359, 359, 243, 359, 359, 360, 360, 223,
  594. 360, 360, 361, 361, 222, 361, 361, 362, 362, 221,
  595. 362, 362, 363, 363, 363, 363, 363, 364, 364, 220,
  596. 364, 364, 365, 365, 219, 365, 365, 366, 366, 218,
  597. 366, 366, 367, 367, 216, 367, 367, 368, 368, 215,
  598. 368, 368, 214, 213, 209, 208, 191, 189, 188, 187,
  599. 186, 184, 183, 182, 178, 174, 173, 161, 159, 158,
  600. 157, 152, 148, 145, 142, 140, 138, 136, 122, 115,
  601. 114, 109, 104, 102, 91, 90, 89, 86, 79, 75,
  602. 69, 67, 62, 53, 51, 41, 40, 39, 38, 37,
  603. 34, 33, 18, 17, 14, 13, 12, 11, 10, 9,
  604. 8, 7, 6, 5, 4, 3, 328, 328, 328, 328,
  605. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  606. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  607. 328, 328, 328, 328, 328, 328, 328, 328, 328, 328,
  608. 328, 328, 328, 328, 328, 328
  609. } ;
  610. static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
  611. static char *yy_full_match;
  612. static int yy_lp;
  613. #define REJECT \
  614. { \
  615. *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
  616. yy_cp = yy_full_match; /* restore poss. backed-over text */ \
  617. ++yy_lp; \
  618. goto find_rule; \
  619. }
  620. #define yymore() yymore_used_but_not_detected
  621. #define YY_MORE_ADJ 0
  622. #define YY_RESTORE_YY_MORE_OFFSET
  623. char *yytext;
  624. #line 1 "vs1.0_tokens.l"
  625. #define INITIAL 0
  626. #define INCLUDE 1
  627. #define DEFINE 2
  628. #define DEFSTR 3
  629. #define DEFSPACE 4
  630. #define SKIPLINE 5
  631. #define EATCOMMENT 6
  632. #define EATSTRING 7
  633. #define SAVELINE 8
  634. #define MACRONAME 9
  635. #define MACROBODY 10
  636. #define MACROPARM 11
  637. #define EATMACRO 12
  638. #define EATDEFINE 13
  639. #define MODIFIER 14
  640. #define MACROPARMSTART 15
  641. #define IFDEFNAME 16
  642. #define IFDEFBODY 17
  643. #define ENDMACRO 18
  644. #define MACROPARMEND 19
  645. #line 8 "vs1.0_tokens.l"
  646. #include <stdarg.h>
  647. #include <stdlib.h>
  648. #ifdef _WIN32
  649. #include <io.h>
  650. # ifdef __GNUC__
  651. # include <sys/types.h>
  652. # include <ctype.h>
  653. # endif
  654. #else
  655. #include <sys/types.h>
  656. #include <ctype.h>
  657. #define _stat stat
  658. #define _open open
  659. #define _O_RDONLY O_RDONLY
  660. #define _fstat fstat
  661. #define _close close
  662. #define stricmp strcasecmp
  663. #endif
  664. #include <sys/stat.h>
  665. #include <fcntl.h>
  666. #include <string.h>
  667. #include "macro.h"
  668. #include "nvparse_errors.h"
  669. #include "vs1.0_inst_list.h"
  670. #include "_vs1.0_parser.h"
  671. #define yylineno line_number
  672. #include "nvparse_externs.h"
  673. #define yylineno line_number
  674. int line_incr;
  675. void LexError(const char *format, ...);
  676. void LexWarning(const char *format, ...);
  677. char *ReadTextFile(const char * filename);
  678. unsigned int MakeRegisterMask(char *findName);
  679. unsigned int FindSwizzleValue(char *swizzleText);
  680. enum ERROR_VALUES {
  681. ERROR_NONE = 0,
  682. ERROR_MEMORY_ALLOC,
  683. ERROR_FILE_OPEN,
  684. ERROR_UNSUCCESSFUL_ASSEMBLE,
  685. ERROR_TOO_MANY_PARMS,
  686. ERROR_DEST_WRITE,
  687. ERROR_LIST_OPEN,
  688. ERROR_DEST_OPEN,
  689. ERROR_NO_ARGUMENTS,
  690. ERROR_MACRO_OVERRUN
  691. };
  692. //extern void GenSwitchFileNames(char *fileName);
  693. //extern unsigned int gLinesAssembled;
  694. unsigned int gLinesAssembled;
  695. #define YY_INPUT(buf,result,max_size) \
  696. { \
  697. int c = *myin++; \
  698. result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \
  699. }
  700. #define SAFEDELETEARRAY(x) if ((x) != NULL) \
  701. delete [] (x)
  702. #define SAFEFREE(x) if ((x) != NULL) \
  703. free((x))
  704. #define MAXREPLACESTRING 255
  705. char gReplaceText[MAXREPLACESTRING+1];
  706. //
  707. // forward prototypes for macro functions
  708. //
  709. void MacroIncFunction(char *, unsigned int *, char **);
  710. void MacroDecFunction(char *, unsigned int *, char **);
  711. void MacroAddFunction(char *, unsigned int *, char **);
  712. void MacroSubFunction(char *, unsigned int *, char **);
  713. MACROFUNCTIONS gMacroFunctions[] = {
  714. { "inc(", MacroIncFunction },
  715. { "dec(", MacroDecFunction },
  716. { "add(", MacroAddFunction },
  717. { "sub(", MacroSubFunction }
  718. };
  719. #define NUM_MACRO_FUNCTIONS (sizeof(gMacroFunctions) / sizeof(MACROFUNCTIONS))
  720. #define MAX_INCLUDE_DEPTH 1024
  721. typedef struct INCLUDEINFO
  722. {
  723. char *fileName;
  724. unsigned int lineNo;
  725. YY_BUFFER_STATE buffer;
  726. MACROENTRY *lastInvokeMacro; // save off in case nested macros.
  727. MACROENTRY *lastParseMacro; // recursive macros
  728. MACROTEXT *lastMacroLineParse; // save off for recursive lines of macros working on.
  729. bool lastbInsideMacro; // save off for recursive macros
  730. bool lastbInsideDefine; // save off for recursive macros/defines
  731. bool lastbInsideInclude;
  732. bool lastbProcessingIFDEF; // save off #define information
  733. // FILE *fileHandle;
  734. char *prevString;
  735. char *nextString;
  736. } INCLUDEINFO;
  737. INCLUDEINFO gIncludeStack[MAX_INCLUDE_DEPTH];
  738. int gIncludeStackIndex = 0;
  739. IFDEFINFO gIfDefStack[MAX_IFDEF_DEPTH];
  740. int gIfDefStackIndex = 0;
  741. unsigned int &base_linenumber = gIncludeStack[0].lineNo;
  742. bool gbInsideInclude = false;
  743. bool gbProcessingBuiltIn = false;
  744. bool gbProcessingDefine = false;
  745. unsigned int gCountParen = 0;
  746. bool gbProcessingIFDEF = false;
  747. bool gbIFDEF = false;
  748. bool gbCompareDefine = false;
  749. unsigned int gIfDefStartLine;
  750. MACROENTRY *gLastMacro;
  751. MACROENTRY *gInvokeMacro;
  752. MACROENTRY *gTempMacro; // until all the parameters are read
  753. MACROENTRY *FindMacro(char *macroName);
  754. MACROENTRY *FindNMacro(char *macroName, unsigned int sLen);
  755. MACROFUNCTIONPTR gMacroCallFunction;
  756. const char *builtInMacros = "macro m3x2 reg1, reg2, reg3\n"
  757. " dp3 %reg1.x, %reg2, %reg3\n"
  758. " dp3 %reg1.y, %reg2, %inc(%reg3)\n"
  759. "endm";
  760. //
  761. // local prototypes
  762. //
  763. void CleanUp();
  764. void ReplaceMacroParms(char *srcLine, char *destLine,
  765. MACROENTRY *srcParms, MACROENTRY *invParms);
  766. MACROTEXT *SaveMacroText(char *srcText, MACROTEXT *lastMacroText);
  767. void FreeMacroEntry(MACROENTRY *macEntry);
  768. void EndMacroParms();
  769. char *FindAlphaNum(char *srcStr, unsigned int *sLen);
  770. void DebugUnhandledState();
  771. unsigned int gCommentStartLine;
  772. unsigned int gMacroStartLine;
  773. char *gCurFileName = NULL;
  774. #define MAXSAVELINE 4095
  775. char gSaveLine[MAXSAVELINE+1];
  776. char gMacroLine[MAXSAVELINE+1];
  777. #if 1
  778. #ifdef _DEBUG
  779. #define ECHO DebugUnhandledState();
  780. #else
  781. #define ECHO
  782. #endif
  783. #endif
  784. bool gbInsideMacro = false; // flag if we are doing a macro replace or not.
  785. bool gbTempInsideMacro = false;
  786. unsigned int gInvokeState = INITIAL;
  787. MACROENTRY *gParseMacro; // which source macro entry we are using
  788. MACROENTRY *gTempParseMacro; // temporary holder until parameters are received.
  789. MACROTEXT *gMacroLineParse; // which line we are currently parsing inside the macro invocation
  790. enum OPCODETYPE
  791. {
  792. TYPE_NONE = 0,
  793. TYPE_VERTEX_SHADER = 1,
  794. TYPE_PIXEL_SHADER = 2
  795. };
  796. typedef struct OPCODEMAP
  797. {
  798. const char *string; // string for opcode
  799. int tokenName; // name of the corresponding token
  800. int numArguments; // number of arguments for opcode
  801. float version; // minimum version supported in.
  802. int opcodeTypeFlags; // whether opcode can be used in vertex shader or pixel shader
  803. bool opcodeModify; // if opcode modifiers can be used
  804. bool textureOpcode; // only outputs to the texture unit
  805. } OPCODEMAP;
  806. #ifndef TRUE
  807. #define TRUE true
  808. #endif
  809. #ifndef FALSE
  810. #define FALSE false
  811. #endif
  812. OPCODEMAP theOpcodes[] = {
  813. { "add", ADD_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  814. { "dp3", DP3_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  815. { "dp4", DP4_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  816. { "dst", DST_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  817. { "exp", EXP_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  818. { "expp", EXPP_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  819. { "frc", FRC_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  820. { "lit", LIT_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  821. { "log", LOG_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  822. { "logp", LOGP_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  823. { "m3x2", M3X2_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  824. { "m3x3", M3X3_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  825. { "m3x4", M3X4_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  826. { "m4x3", M4X3_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  827. { "m4x4", M4X4_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  828. { "mad", MAD_INSTR, 4, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  829. { "max", MAX_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  830. { "min", MIN_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  831. { "mov", MOV_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  832. { "mul", MUL_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  833. { "nop", NOP_INSTR, 0, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  834. { "rcp", RCP_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  835. { "rsq", RSQ_INSTR, 2, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  836. { "sge", SGE_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  837. { "slt", SLT_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER, FALSE, FALSE },
  838. { "sub", SUB_INSTR, 3, 1.0f, TYPE_VERTEX_SHADER | TYPE_PIXEL_SHADER, TRUE, FALSE },
  839. };
  840. #define NUMOPCODES (sizeof(theOpcodes) / sizeof(OPCODEMAP))
  841. OPCODEMAP *FindOpcode(char *findName);
  842. #line 990 "_vs1.0_lexer.cpp"
  843. /* Macros after this point can all be overridden by user definitions in
  844. * section 1.
  845. */
  846. #ifndef YY_SKIP_YYWRAP
  847. #ifdef __cplusplus
  848. extern "C" int yywrap YY_PROTO(( void ));
  849. #else
  850. extern int yywrap YY_PROTO(( void ));
  851. #endif
  852. #endif
  853. #ifndef YY_NO_UNPUT
  854. static void yyunput YY_PROTO(( int c, char *buf_ptr ));
  855. #endif
  856. #ifndef yytext_ptr
  857. static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
  858. #endif
  859. #ifdef YY_NEED_STRLEN
  860. static int yy_flex_strlen YY_PROTO(( yyconst char * ));
  861. #endif
  862. #ifndef YY_NO_INPUT
  863. #ifdef __cplusplus
  864. static int yyinput YY_PROTO(( void ));
  865. #else
  866. static int input YY_PROTO(( void ));
  867. #endif
  868. #endif
  869. #if YY_STACK_USED
  870. static int yy_start_stack_ptr = 0;
  871. static int yy_start_stack_depth = 0;
  872. static int *yy_start_stack = 0;
  873. #ifndef YY_NO_PUSH_STATE
  874. static void yy_push_state YY_PROTO(( int new_state ));
  875. #endif
  876. #ifndef YY_NO_POP_STATE
  877. static void yy_pop_state YY_PROTO(( void ));
  878. #endif
  879. #ifndef YY_NO_TOP_STATE
  880. static int yy_top_state YY_PROTO(( void ));
  881. #endif
  882. #else
  883. #define YY_NO_PUSH_STATE 1
  884. #define YY_NO_POP_STATE 1
  885. #define YY_NO_TOP_STATE 1
  886. #endif
  887. #ifdef YY_MALLOC_DECL
  888. YY_MALLOC_DECL
  889. #else
  890. #if __STDC__
  891. #ifndef __cplusplus
  892. #include <stdlib.h>
  893. #endif
  894. #else
  895. /* Just try to get by without declaring the routines. This will fail
  896. * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
  897. * or sizeof(void*) != sizeof(int).
  898. */
  899. #endif
  900. #endif
  901. /* Amount of stuff to slurp up with each read. */
  902. #ifndef YY_READ_BUF_SIZE
  903. #define YY_READ_BUF_SIZE 8192
  904. #endif
  905. /* Copy whatever the last rule matched to the standard output. */
  906. #ifndef ECHO
  907. /* This used to be an fputs(), but since the string might contain NUL's,
  908. * we now use fwrite().
  909. */
  910. #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
  911. #endif
  912. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  913. * is returned in "result".
  914. */
  915. #ifndef YY_INPUT
  916. #define YY_INPUT(buf,result,max_size) \
  917. if ( yy_current_buffer->yy_is_interactive ) \
  918. { \
  919. int c = '*', n; \
  920. for ( n = 0; n < max_size && \
  921. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  922. buf[n] = (char) c; \
  923. if ( c == '\n' ) \
  924. buf[n++] = (char) c; \
  925. if ( c == EOF && ferror( yyin ) ) \
  926. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  927. result = n; \
  928. } \
  929. else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
  930. && ferror( yyin ) ) \
  931. YY_FATAL_ERROR( "input in flex scanner failed" );
  932. #endif
  933. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  934. * we don't want an extra ';' after the "return" because that will cause
  935. * some compilers to complain about unreachable statements.
  936. */
  937. #ifndef yyterminate
  938. #define yyterminate() return YY_NULL
  939. #endif
  940. /* Number of entries by which start-condition stack grows. */
  941. #ifndef YY_START_STACK_INCR
  942. #define YY_START_STACK_INCR 25
  943. #endif
  944. /* Report a fatal error. */
  945. #ifndef YY_FATAL_ERROR
  946. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  947. #endif
  948. /* Default declaration of generated scanner - a define so the user can
  949. * easily add parameters.
  950. */
  951. #ifndef YY_DECL
  952. #define YY_DECL int yylex YY_PROTO(( void ))
  953. #endif
  954. /* Code executed at the beginning of each rule, after yytext and yyleng
  955. * have been set up.
  956. */
  957. #ifndef YY_USER_ACTION
  958. #define YY_USER_ACTION
  959. #endif
  960. /* Code executed at the end of each rule. */
  961. #ifndef YY_BREAK
  962. #define YY_BREAK break;
  963. #endif
  964. #define YY_RULE_SETUP \
  965. if ( yyleng > 0 ) \
  966. yy_current_buffer->yy_at_bol = \
  967. (yytext[yyleng - 1] == '\n'); \
  968. YY_USER_ACTION
  969. YY_DECL
  970. {
  971. register yy_state_type yy_current_state;
  972. register char *yy_cp = NULL, *yy_bp = NULL;
  973. register int yy_act;
  974. #line 261 "vs1.0_tokens.l"
  975. #line 1147 "_vs1.0_lexer.cpp"
  976. if ( yy_init )
  977. {
  978. yy_init = 0;
  979. #ifdef YY_USER_INIT
  980. YY_USER_INIT;
  981. #endif
  982. if ( ! yy_start )
  983. yy_start = 1; /* first start state */
  984. if ( ! yyin )
  985. yyin = stdin;
  986. if ( ! yyout )
  987. yyout = stdout;
  988. if ( ! yy_current_buffer )
  989. yy_current_buffer =
  990. yy_create_buffer( yyin, YY_BUF_SIZE );
  991. yy_load_buffer_state();
  992. }
  993. while ( 1 ) /* loops until end-of-file is reached */
  994. {
  995. yy_cp = yy_c_buf_p;
  996. /* Support of yytext. */
  997. *yy_cp = yy_hold_char;
  998. /* yy_bp points to the position in yy_ch_buf of the start of
  999. * the current run.
  1000. */
  1001. yy_bp = yy_cp;
  1002. yy_current_state = yy_start;
  1003. yy_current_state += YY_AT_BOL();
  1004. yy_state_ptr = yy_state_buf;
  1005. *yy_state_ptr++ = yy_current_state;
  1006. yy_match:
  1007. do
  1008. {
  1009. register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  1010. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1011. {
  1012. yy_current_state = (int) yy_def[yy_current_state];
  1013. if ( yy_current_state >= 329 )
  1014. yy_c = yy_meta[(unsigned int) yy_c];
  1015. }
  1016. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1017. *yy_state_ptr++ = yy_current_state;
  1018. ++yy_cp;
  1019. }
  1020. while ( yy_base[yy_current_state] != 767 );
  1021. yy_find_action:
  1022. yy_current_state = *--yy_state_ptr;
  1023. yy_lp = yy_accept[yy_current_state];
  1024. find_rule: /* we branch to this label when backing up */
  1025. for ( ; ; ) /* until we find what rule we matched */
  1026. {
  1027. if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
  1028. {
  1029. yy_act = yy_acclist[yy_lp];
  1030. {
  1031. yy_full_match = yy_cp;
  1032. break;
  1033. }
  1034. }
  1035. --yy_cp;
  1036. yy_current_state = *--yy_state_ptr;
  1037. yy_lp = yy_accept[yy_current_state];
  1038. }
  1039. YY_DO_BEFORE_ACTION;
  1040. do_action: /* This label is used only to access EOF actions. */
  1041. switch ( yy_act )
  1042. { /* beginning of action switch */
  1043. case 1:
  1044. YY_RULE_SETUP
  1045. #line 263 "vs1.0_tokens.l"
  1046. {
  1047. gbProcessingDefine = false;
  1048. gSaveLine[0] = '\0';
  1049. strncat(gSaveLine, yytext, MAXSAVELINE);
  1050. // GenDebugLine();
  1051. if (gbProcessingIFDEF && (gbCompareDefine != gbIFDEF))
  1052. {
  1053. BEGIN(IFDEFBODY);
  1054. }
  1055. else
  1056. {
  1057. BEGIN(INITIAL);
  1058. }
  1059. yyless(0);
  1060. }
  1061. YY_BREAK
  1062. case 2:
  1063. YY_RULE_SETUP
  1064. #line 279 "vs1.0_tokens.l"
  1065. {
  1066. gbProcessingDefine = false;
  1067. gSaveLine[0] = '\0';
  1068. strncat(gSaveLine, yytext, MAXSAVELINE);
  1069. // GenDebugLine();
  1070. if (gbProcessingIFDEF && (gbCompareDefine != gbIFDEF))
  1071. {
  1072. BEGIN(IFDEFBODY);
  1073. }
  1074. else
  1075. {
  1076. BEGIN(INITIAL);
  1077. }
  1078. yyless(0);
  1079. }
  1080. YY_BREAK
  1081. case 3:
  1082. YY_RULE_SETUP
  1083. #line 295 "vs1.0_tokens.l"
  1084. {
  1085. // fprintf( stderr, "%s", yytext );
  1086. vs10_lval.reg.type = TYPE_ADDRESS_REG;
  1087. vs10_lval.reg.index = atoi(&yytext[1]);
  1088. if ( yytext[yyleng-1] == '\n' )
  1089. line_incr = 1;
  1090. return REGISTER;
  1091. }
  1092. YY_BREAK
  1093. case 4:
  1094. YY_RULE_SETUP
  1095. #line 304 "vs1.0_tokens.l"
  1096. {
  1097. // fprintf( stderr, "%s", yytext );
  1098. vs10_lval.reg.type = TYPE_VERTEX_ATTRIB_REG;
  1099. vs10_lval.reg.index = atoi(&yytext[1]);
  1100. if ( yytext[yyleng-1] == '\n' )
  1101. line_incr = 1;
  1102. return REGISTER;
  1103. }
  1104. YY_BREAK
  1105. case 5:
  1106. YY_RULE_SETUP
  1107. #line 313 "vs1.0_tokens.l"
  1108. {
  1109. // fprintf( stderr, "%s", yytext );
  1110. vs10_lval.reg.type = TYPE_TEMPORARY_REG;
  1111. vs10_lval.reg.index = atoi(&yytext[1]);
  1112. if ( yytext[yyleng-1] == '\n' )
  1113. line_incr = 1;
  1114. return REGISTER;
  1115. }
  1116. YY_BREAK
  1117. case 6:
  1118. YY_RULE_SETUP
  1119. #line 322 "vs1.0_tokens.l"
  1120. {
  1121. // fprintf( stderr, "%s", yytext );
  1122. vs10_lval.reg.type = TYPE_CONSTANT_MEM_REG;
  1123. vs10_lval.reg.index = atoi(&yytext[1]);
  1124. if ( yytext[yyleng-1] == '\n' )
  1125. line_incr = 1;
  1126. return REGISTER;
  1127. }
  1128. YY_BREAK
  1129. case 7:
  1130. YY_RULE_SETUP
  1131. #line 331 "vs1.0_tokens.l"
  1132. {
  1133. // fprintf( stderr, "%s", yytext );
  1134. vs10_lval.reg.type = TYPE_TEXTURE_RESULT_REG;
  1135. vs10_lval.reg.index = atoi(&yytext[2]);
  1136. if ( yytext[yyleng-1] == '\n' )
  1137. line_incr = 1;
  1138. return REGISTER;
  1139. }
  1140. YY_BREAK
  1141. case 8:
  1142. YY_RULE_SETUP
  1143. #line 340 "vs1.0_tokens.l"
  1144. {
  1145. // fprintf( stderr, "%s", yytext );
  1146. vs10_lval.reg.type = TYPE_COLOR_RESULT_REG;
  1147. vs10_lval.reg.index = atoi(&yytext[2]);
  1148. if ( yytext[yyleng-1] == '\n' )
  1149. line_incr = 1;
  1150. return REGISTER;
  1151. }
  1152. YY_BREAK
  1153. case 9:
  1154. YY_RULE_SETUP
  1155. #line 349 "vs1.0_tokens.l"
  1156. {
  1157. // fprintf( stderr, "%s", yytext );
  1158. vs10_lval.reg.type = TYPE_FOG_RESULT_REG;
  1159. if ( yytext[yyleng-1] == '\n' )
  1160. line_incr = 1;
  1161. return REGISTER;
  1162. }
  1163. YY_BREAK
  1164. case 10:
  1165. YY_RULE_SETUP
  1166. #line 357 "vs1.0_tokens.l"
  1167. {
  1168. // fprintf( stderr, "%s", yytext );
  1169. vs10_lval.reg.type = TYPE_POSITION_RESULT_REG;
  1170. if ( yytext[yyleng-1] == '\n' )
  1171. line_incr = 1;
  1172. return REGISTER;
  1173. }
  1174. YY_BREAK
  1175. case 11:
  1176. YY_RULE_SETUP
  1177. #line 365 "vs1.0_tokens.l"
  1178. {
  1179. // fprintf( stderr, "%s", yytext );
  1180. vs10_lval.reg.type = TYPE_POINTS_RESULT_REG;
  1181. if ( yytext[yyleng-1] == '\n' )
  1182. line_incr = 1;
  1183. return REGISTER;
  1184. }
  1185. YY_BREAK
  1186. case 12:
  1187. YY_RULE_SETUP
  1188. #line 373 "vs1.0_tokens.l"
  1189. {
  1190. unsigned int offset;
  1191. offset = strcspn(yytext, " \t\n_");
  1192. yyless(offset);
  1193. OPCODEMAP *opcodeMap = FindOpcode(yytext);
  1194. if ( opcodeMap != NULL )
  1195. {
  1196. // fprintf( stderr, "%s\t", opcodeMap->string );
  1197. return( opcodeMap->tokenName );
  1198. }
  1199. else
  1200. {
  1201. gTempParseMacro = FindMacro(yytext);
  1202. if (gTempParseMacro != NULL)
  1203. {
  1204. if (gIncludeStackIndex >= MAX_INCLUDE_DEPTH )
  1205. {
  1206. LexError("macros nested too deeply");
  1207. exit( 1 );
  1208. }
  1209. if (gTempParseMacro->firstMacroLines != NULL)
  1210. {
  1211. gTempMacro = (MACROENTRY *)malloc(sizeof(MACROENTRY));
  1212. if (gTempMacro == NULL)
  1213. {
  1214. LexError("Out of memory allocating MACROENTRY structure.\n");
  1215. }
  1216. else
  1217. {
  1218. gTempMacro->next = NULL;
  1219. gTempMacro->prev = NULL;
  1220. gTempMacro->macroName = NULL;
  1221. gTempMacro->firstMacroParms = NULL;
  1222. gTempMacro->lastMacroParms = NULL;
  1223. gTempMacro->firstMacroLines = NULL;
  1224. gTempMacro->lastMacroLines = NULL;
  1225. gTempMacro->numParms = 0;
  1226. gTempMacro->nLines = 0;
  1227. gbTempInsideMacro = true; // flag we are currently doing a macro replace.
  1228. gInvokeState = YYSTATE;
  1229. if (gTempParseMacro->numParms > 0)
  1230. {
  1231. BEGIN(MACROPARMSTART);
  1232. }
  1233. else
  1234. {
  1235. EndMacroParms();
  1236. gbTempInsideMacro = false; // no longer waiting for macro invocation
  1237. }
  1238. }
  1239. }
  1240. }
  1241. else
  1242. {
  1243. // fprintf( stderr, "Opcode: \"%s\" not found\n", yytext );
  1244. REJECT;
  1245. }
  1246. }
  1247. //unsigned int offset;
  1248. //
  1249. //INSTRMAP *opcodeMap;
  1250. //
  1251. //offset = strcspn(yytext, " \t\n_");
  1252. //yyless(offset);
  1253. //opcodeMap = FindInstruction(yytext);
  1254. //if (opcodeMap == NULL)
  1255. //{
  1256. // REJECT;
  1257. //}
  1258. //
  1259. //yylval.opcodeInfo.opcodeMap = opcodeMap;
  1260. //
  1261. //return OPCODE;
  1262. }
  1263. YY_BREAK
  1264. case 13:
  1265. YY_RULE_SETUP
  1266. #line 460 "vs1.0_tokens.l"
  1267. {
  1268. // fprintf( stderr, "%s", yytext );
  1269. char *cmt = new char[yyleng+1];
  1270. strncpy( cmt, yytext, yyleng );
  1271. cmt[0] = '#';
  1272. cmt[yyleng] = '\0';
  1273. vs10_lval.comment = cmt;
  1274. return COMMENT;
  1275. }
  1276. YY_BREAK
  1277. case 14:
  1278. YY_RULE_SETUP
  1279. #line 470 "vs1.0_tokens.l"
  1280. {
  1281. // fprintf( stderr, "%s", yytext );
  1282. char *cmt = new char[yyleng+1];
  1283. strncpy( cmt+1, yytext+1, yyleng-1 );
  1284. cmt[0] = '#';
  1285. cmt[1] = ' ';
  1286. cmt[yyleng] = '\0';
  1287. vs10_lval.comment = cmt;
  1288. return COMMENT;
  1289. }
  1290. YY_BREAK
  1291. case 15:
  1292. YY_RULE_SETUP
  1293. #line 481 "vs1.0_tokens.l"
  1294. {
  1295. fprintf( stderr, "COISSUE found\n" );
  1296. yyless(yyleng-1);
  1297. //return COISSUE;
  1298. }
  1299. YY_BREAK
  1300. case 16:
  1301. YY_RULE_SETUP
  1302. #line 487 "vs1.0_tokens.l"
  1303. {
  1304. fprintf( stderr, "COISSUE found\n" );
  1305. //return COISSUE;
  1306. }
  1307. YY_BREAK
  1308. case 17:
  1309. YY_RULE_SETUP
  1310. #line 492 "vs1.0_tokens.l"
  1311. {
  1312. gCommentStartLine = yylineno;
  1313. yyless(0);
  1314. BEGIN(EATCOMMENT);
  1315. }
  1316. YY_BREAK
  1317. case 18:
  1318. YY_RULE_SETUP
  1319. #line 498 "vs1.0_tokens.l"
  1320. {
  1321. BEGIN(INCLUDE);
  1322. }
  1323. YY_BREAK
  1324. case 19:
  1325. YY_RULE_SETUP
  1326. #line 502 "vs1.0_tokens.l"
  1327. { /* got the include file name */
  1328. // FILE *newyyin;
  1329. char *newyyin;
  1330. char incFileName[1024];
  1331. unsigned long sLen;
  1332. bool validFileName;
  1333. if ( gIncludeStackIndex >= MAX_INCLUDE_DEPTH )
  1334. {
  1335. LexError("Includes nested too deeply, aborting\n");
  1336. exit( 1 );
  1337. }
  1338. // GenDebugLine();
  1339. // GenListString();
  1340. yylineno++;
  1341. gLinesAssembled++;
  1342. validFileName = true;
  1343. // zap "" and <>
  1344. if ((yytext[0] == '"') || (yytext[0] == '<'))
  1345. {
  1346. char *endQuote;
  1347. endQuote = strchr(&yytext[1], yytext[0]);
  1348. sLen = (endQuote - yytext)-1;
  1349. if (endQuote == NULL)
  1350. {
  1351. LexError("Unable to open include file %s\n", incFileName);
  1352. BEGIN(INITIAL);
  1353. validFileName = false;
  1354. }
  1355. else
  1356. {
  1357. incFileName[0] ='\0';
  1358. strncat(incFileName, &yytext[1], sLen);
  1359. }
  1360. }
  1361. else
  1362. {
  1363. strcpy(incFileName, yytext);
  1364. }
  1365. if (validFileName)
  1366. {
  1367. sLen = strlen(incFileName);
  1368. if ((incFileName[sLen-1] == '"') || (incFileName[sLen-1] == '>'))
  1369. {
  1370. incFileName[sLen-1] = '\0';
  1371. }
  1372. newyyin = ReadTextFile( incFileName );
  1373. // newyyin = fopen( incFileName, "r" );
  1374. if ( ! newyyin )
  1375. {
  1376. LexError("Unable to open include file %s\n", incFileName);
  1377. BEGIN(SAVELINE);
  1378. }
  1379. else
  1380. {
  1381. gIncludeStack[gIncludeStackIndex].fileName = gCurFileName;
  1382. gIncludeStack[gIncludeStackIndex].lineNo = yylineno;
  1383. // gIncludeStack[gIncludeStackIndex].fileHandle = yyin;
  1384. gIncludeStack[gIncludeStackIndex].prevString = myin;
  1385. gIncludeStack[gIncludeStackIndex].nextString = newyyin;
  1386. gIncludeStack[gIncludeStackIndex].lastInvokeMacro = gInvokeMacro;
  1387. gIncludeStack[gIncludeStackIndex].lastParseMacro = gParseMacro;
  1388. gIncludeStack[gIncludeStackIndex].lastMacroLineParse = gMacroLineParse;
  1389. gIncludeStack[gIncludeStackIndex].lastbInsideMacro = gbInsideMacro;
  1390. gIncludeStack[gIncludeStackIndex].lastbInsideInclude = gbInsideInclude;
  1391. gIncludeStack[gIncludeStackIndex].buffer = YY_CURRENT_BUFFER;
  1392. gIncludeStack[gIncludeStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
  1393. gIncludeStackIndex++;
  1394. gbProcessingIFDEF = false;
  1395. gCurFileName = strdup(incFileName);
  1396. // yyin = newyyin;
  1397. myin = newyyin;
  1398. // GenSwitchFileNames(gCurFileName);
  1399. yylineno = 1;
  1400. yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) );
  1401. gbInsideInclude = true;
  1402. BEGIN(SAVELINE);
  1403. }
  1404. }
  1405. }
  1406. YY_BREAK
  1407. case YY_STATE_EOF(EATCOMMENT):
  1408. #line 597 "vs1.0_tokens.l"
  1409. {
  1410. LexError("End of file reached before end of comment started on line %d.\n", gCommentStartLine);
  1411. BEGIN(INITIAL);
  1412. }
  1413. YY_BREAK
  1414. case 20:
  1415. YY_RULE_SETUP
  1416. #line 602 "vs1.0_tokens.l"
  1417. {
  1418. char *endComment;
  1419. unsigned int keepSize;
  1420. strcpy(gSaveLine, yytext);
  1421. endComment = strstr(yytext, "*/");
  1422. char *cmt;
  1423. if (endComment != NULL)
  1424. {
  1425. keepSize = (endComment - yytext+2);
  1426. yyless(keepSize);
  1427. BEGIN(INITIAL);
  1428. if ( yytext[0] == '/' && yytext[1] == '*' )
  1429. {
  1430. cmt = new char[yyleng];
  1431. strncpy( cmt+3, yytext+2, yyleng-2 );
  1432. cmt[0] = '#';
  1433. cmt[1] = ' ';
  1434. cmt[2] = ' ';
  1435. cmt[yyleng-1] = '\0';
  1436. }
  1437. else
  1438. {
  1439. cmt = new char[yyleng];
  1440. strncpy( cmt+1, yytext, yyleng-2 );
  1441. cmt[0] = '#';
  1442. cmt[yyleng-1] = '\0';
  1443. }
  1444. vs10_lval.comment = cmt;
  1445. return COMMENT;
  1446. }
  1447. else
  1448. {
  1449. // GenDebugLine();
  1450. // GenListString();
  1451. gLinesAssembled++;
  1452. yylineno++;
  1453. if ( yytext[0] == '/' && yytext[1] == '*' )
  1454. {
  1455. cmt = new char[yyleng+2];
  1456. strncpy( cmt+3, yytext+2, yyleng-2 );
  1457. cmt[0] = '#';
  1458. cmt[1] = ' ';
  1459. cmt[2] = ' ';
  1460. cmt[yyleng+1] = '\0';
  1461. }
  1462. else
  1463. {
  1464. cmt = new char[yyleng+2];
  1465. strncpy( cmt+1, yytext, yyleng );
  1466. cmt[0] = '#';
  1467. cmt[yyleng+1] = '\0';
  1468. }
  1469. vs10_lval.comment = cmt;
  1470. return COMMENT;
  1471. }
  1472. }
  1473. YY_BREAK
  1474. case YY_STATE_EOF(DEFSTR):
  1475. #line 663 "vs1.0_tokens.l"
  1476. {
  1477. LexError("#define was incomplete before end of file\n");
  1478. BEGIN(INITIAL);
  1479. }
  1480. YY_BREAK
  1481. case YY_STATE_EOF(DEFINE):
  1482. #line 668 "vs1.0_tokens.l"
  1483. {
  1484. LexError("#define was incomplete before end of file\n");
  1485. BEGIN(INITIAL);
  1486. }
  1487. YY_BREAK
  1488. case YY_STATE_EOF(DEFSPACE):
  1489. #line 673 "vs1.0_tokens.l"
  1490. {
  1491. LexError("#define was incomplete before end of file\n");
  1492. BEGIN(INITIAL);
  1493. }
  1494. YY_BREAK
  1495. case YY_STATE_EOF(INCLUDE):
  1496. #line 678 "vs1.0_tokens.l"
  1497. {
  1498. LexError("#include was incomplete before end of file\n");
  1499. BEGIN(INITIAL);
  1500. }
  1501. YY_BREAK
  1502. case YY_STATE_EOF(MACROBODY):
  1503. #line 683 "vs1.0_tokens.l"
  1504. {
  1505. LexError("End of file reached before end of #define or endm was found, macro started on line %d.\n", gMacroStartLine);
  1506. BEGIN(INITIAL);
  1507. }
  1508. YY_BREAK
  1509. case YY_STATE_EOF(IFDEFBODY):
  1510. #line 688 "vs1.0_tokens.l"
  1511. {
  1512. LexError("End of file reached before #endif found, macro started on line %d.\n", gIfDefStartLine);
  1513. BEGIN(INITIAL);
  1514. }
  1515. YY_BREAK
  1516. case 21:
  1517. YY_RULE_SETUP
  1518. #line 693 "vs1.0_tokens.l"
  1519. {
  1520. LexError("#define was incomplete before end of line\n");
  1521. BEGIN(SAVELINE);
  1522. // GenDebugLine();
  1523. // GenListString();
  1524. gLinesAssembled++;
  1525. yylineno++;
  1526. }
  1527. YY_BREAK
  1528. case 22:
  1529. YY_RULE_SETUP
  1530. #line 702 "vs1.0_tokens.l"
  1531. {
  1532. LexError("#define was incomplete before end of line\n");
  1533. BEGIN(SAVELINE);
  1534. // GenDebugLine();
  1535. // GenListString();
  1536. gLinesAssembled++;
  1537. yylineno++;
  1538. }
  1539. YY_BREAK
  1540. case 23:
  1541. YY_RULE_SETUP
  1542. #line 711 "vs1.0_tokens.l"
  1543. {
  1544. LexError("#define was incomplete before end of line\n");
  1545. BEGIN(SAVELINE);
  1546. // GenDebugLine();
  1547. // GenListString();
  1548. gLinesAssembled++;
  1549. yylineno++;
  1550. }
  1551. YY_BREAK
  1552. case 24:
  1553. YY_RULE_SETUP
  1554. #line 720 "vs1.0_tokens.l"
  1555. {
  1556. if (gIfDefStackIndex >= MAX_IFDEF_DEPTH)
  1557. {
  1558. LexError("Out of stack space for #ifdef, aborting.\n");
  1559. exit( 1 );
  1560. }
  1561. else
  1562. {
  1563. gIfDefStack[gIfDefStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
  1564. gIfDefStack[gIfDefStackIndex].lastbIFDEF = gbIFDEF;
  1565. gIfDefStack[gIfDefStackIndex].lastbCompareDefine = gbCompareDefine;
  1566. gIfDefStack[gIfDefStackIndex].lastIfDefStartLine = gIfDefStartLine;
  1567. gIfDefStackIndex++;
  1568. gIfDefStartLine = yylineno;
  1569. gbCompareDefine = true;
  1570. BEGIN(IFDEFNAME);
  1571. }
  1572. }
  1573. YY_BREAK
  1574. case 25:
  1575. YY_RULE_SETUP
  1576. #line 740 "vs1.0_tokens.l"
  1577. {
  1578. if (gIfDefStackIndex >= MAX_IFDEF_DEPTH)
  1579. {
  1580. LexError("Out of stack space for #ifdef, aborting.\n");
  1581. exit( 1 );
  1582. }
  1583. else
  1584. {
  1585. gIfDefStack[gIfDefStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
  1586. gIfDefStack[gIfDefStackIndex].lastbIFDEF = gbIFDEF;
  1587. gIfDefStack[gIfDefStackIndex].lastbCompareDefine = gbCompareDefine;
  1588. gIfDefStack[gIfDefStackIndex].lastIfDefStartLine = gIfDefStartLine;
  1589. gIfDefStackIndex++;
  1590. gIfDefStartLine = yylineno;
  1591. gbCompareDefine = false;
  1592. BEGIN(IFDEFNAME);
  1593. }
  1594. }
  1595. YY_BREAK
  1596. case 26:
  1597. YY_RULE_SETUP
  1598. #line 760 "vs1.0_tokens.l"
  1599. {
  1600. if (!gbProcessingIFDEF)
  1601. {
  1602. LexError("Unexpected #else found at line %d, skipping.\n", yylineno);
  1603. }
  1604. else
  1605. {
  1606. gbCompareDefine = !gbCompareDefine;
  1607. BEGIN(INITIAL);
  1608. }
  1609. }
  1610. YY_BREAK
  1611. case 27:
  1612. YY_RULE_SETUP
  1613. #line 772 "vs1.0_tokens.l"
  1614. {
  1615. char *defineName;
  1616. unsigned int sLen;
  1617. defineName = FindAlphaNum(yytext, &sLen);
  1618. if (defineName == NULL)
  1619. {
  1620. defineName = strdup(yytext);
  1621. defineName[yyleng-1] = '\0'; // kill \n
  1622. LexWarning("Mangled name (%s) for #ifdef, assuming not defined.\n", defineName);
  1623. free(defineName);
  1624. gbIFDEF = false;
  1625. }
  1626. else
  1627. {
  1628. if (FindNMacro(defineName, sLen) != NULL)
  1629. {
  1630. gbIFDEF = true;
  1631. }
  1632. else
  1633. {
  1634. gbIFDEF = false;
  1635. }
  1636. }
  1637. gbProcessingIFDEF = true;
  1638. if (gbIFDEF != gbCompareDefine)
  1639. {
  1640. BEGIN(IFDEFBODY);
  1641. }
  1642. else
  1643. {
  1644. BEGIN(SAVELINE);
  1645. }
  1646. // GenDebugLine();
  1647. // GenListString();
  1648. gLinesAssembled++;
  1649. yylineno++;
  1650. }
  1651. YY_BREAK
  1652. case 28:
  1653. YY_RULE_SETUP
  1654. #line 814 "vs1.0_tokens.l"
  1655. {
  1656. if (!gbProcessingIFDEF)
  1657. {
  1658. LexError("Unexpected #endif found at line %d, skipping.\n", yylineno);
  1659. }
  1660. else
  1661. {
  1662. gIfDefStackIndex--;
  1663. gbProcessingIFDEF = gIfDefStack[gIfDefStackIndex].lastbProcessingIFDEF;
  1664. gbIFDEF = gIfDefStack[gIfDefStackIndex].lastbIFDEF;
  1665. gbCompareDefine = gIfDefStack[gIfDefStackIndex].lastbCompareDefine;
  1666. gIfDefStartLine = gIfDefStack[gIfDefStackIndex].lastIfDefStartLine;
  1667. }
  1668. if (YYSTATE == IFDEFBODY)
  1669. {
  1670. strncpy(gSaveLine, yytext, MAXSAVELINE);
  1671. }
  1672. BEGIN(ENDMACRO);
  1673. }
  1674. YY_BREAK
  1675. case 29:
  1676. YY_RULE_SETUP
  1677. #line 838 "vs1.0_tokens.l"
  1678. {
  1679. LexWarning("Garbage at end of #endif or endm will be ignored.\n");
  1680. }
  1681. YY_BREAK
  1682. case 30:
  1683. YY_RULE_SETUP
  1684. #line 842 "vs1.0_tokens.l"
  1685. {
  1686. BEGIN(SAVELINE);
  1687. return '\n';
  1688. }
  1689. YY_BREAK
  1690. case YY_STATE_EOF(ENDMACRO):
  1691. #line 847 "vs1.0_tokens.l"
  1692. {
  1693. BEGIN(INITIAL);
  1694. }
  1695. YY_BREAK
  1696. case 31:
  1697. YY_RULE_SETUP
  1698. #line 851 "vs1.0_tokens.l"
  1699. {
  1700. // eat line, because we are not in a TRUE #ifdef, or FALSE #ifndef
  1701. strncpy(gSaveLine, yytext, MAXSAVELINE);
  1702. }
  1703. YY_BREAK
  1704. case 32:
  1705. YY_RULE_SETUP
  1706. #line 856 "vs1.0_tokens.l"
  1707. {
  1708. strcat(gSaveLine, yytext);
  1709. // GenDebugLine();
  1710. // GenListString();
  1711. yylineno++;
  1712. gLinesAssembled++;
  1713. }
  1714. YY_BREAK
  1715. case 33:
  1716. YY_RULE_SETUP
  1717. #line 864 "vs1.0_tokens.l"
  1718. {
  1719. gbProcessingDefine = true;
  1720. gMacroStartLine = yylineno;
  1721. gCountParen = 0;
  1722. BEGIN(MACRONAME);
  1723. }
  1724. YY_BREAK
  1725. case 34:
  1726. YY_RULE_SETUP
  1727. #line 871 "vs1.0_tokens.l"
  1728. {
  1729. BEGIN(SAVELINE);
  1730. // GenDebugLine();
  1731. // GenListString();
  1732. gLinesAssembled++;
  1733. yylineno++;
  1734. }
  1735. YY_BREAK
  1736. case 35:
  1737. YY_RULE_SETUP
  1738. #line 879 "vs1.0_tokens.l"
  1739. {
  1740. // unsigned int majorVersion;
  1741. // unsigned int minorVersion;
  1742. // int minorOffset;
  1743. //
  1744. //
  1745. // majorVersion = (unsigned int)(atoi(&yytext[3]));
  1746. // // skip "ps." + second '.'
  1747. // minorOffset = strcspn(&yytext[3], ".")+4;
  1748. // minorVersion = (unsigned int)(atoi(&yytext[minorOffset]));
  1749. // yylval.ival = D3DVS_VERSION(majorVersion, minorVersion);
  1750. //
  1751. // fprintf( stderr, "%s", yytext );
  1752. if ( yytext[yyleng-1] == '\n' )
  1753. line_incr = 1;
  1754. return VERTEX_SHADER;
  1755. }
  1756. YY_BREAK
  1757. case 36:
  1758. YY_RULE_SETUP
  1759. #line 898 "vs1.0_tokens.l"
  1760. {
  1761. // fprintf( stderr, "%s", yytext );
  1762. vs10_lval.ival = atoi(yytext);
  1763. return INTVAL;
  1764. }
  1765. YY_BREAK
  1766. case 37:
  1767. YY_RULE_SETUP
  1768. #line 905 "vs1.0_tokens.l"
  1769. {
  1770. BEGIN(MODIFIER);
  1771. //fprintf( stderr, "." );
  1772. return yytext[0];
  1773. }
  1774. YY_BREAK
  1775. case 38:
  1776. YY_RULE_SETUP
  1777. #line 911 "vs1.0_tokens.l"
  1778. {
  1779. // fprintf( stderr, "%s", yytext );
  1780. BEGIN(INITIAL);
  1781. vs10_lval.mask[0] = tolower(yytext[0]);
  1782. vs10_lval.mask[1] = tolower(yytext[1]);
  1783. vs10_lval.mask[2] = tolower(yytext[2]);
  1784. vs10_lval.mask[3] = tolower(yytext[3]);
  1785. if ( yytext[yyleng-1] == '\n' )
  1786. line_incr = 1;
  1787. return XYZW_MODIFIER;
  1788. #if 0
  1789. char temp[6];
  1790. temp[0] = '\0';
  1791. strncat(temp, yytext, 4);
  1792. strlwr(temp);
  1793. vs10_lval.lval = FindSwizzleValue(temp);
  1794. BEGIN(INITIAL);
  1795. return SWIZZLE_MODIFIER;
  1796. #endif
  1797. }
  1798. YY_BREAK
  1799. case 39:
  1800. YY_RULE_SETUP
  1801. #line 939 "vs1.0_tokens.l"
  1802. {
  1803. // fprintf( stderr, "%s", yytext );
  1804. BEGIN(INITIAL);
  1805. int validLen = strspn(yytext, "xyzw");
  1806. int i;
  1807. for ( i = 0; i < validLen; i++ )
  1808. vs10_lval.mask[i] = tolower( yytext[i] );
  1809. while ( i < 4 )
  1810. {
  1811. vs10_lval.mask[i] = 0;
  1812. i++;
  1813. }
  1814. if ( yytext[yyleng-1] == '\n' )
  1815. line_incr = 1;
  1816. return XYZW_MODIFIER;
  1817. #if 0
  1818. //char temp[6];
  1819. char *temp = new char[6];
  1820. unsigned int registerMask;
  1821. unsigned int validLen;
  1822. temp[0] = '\0';
  1823. validLen = strspn(yytext, "xyzw");
  1824. strncat(temp, yytext, validLen);
  1825. for ( int i = 0; i < validLen; i++ )
  1826. temp[i] = tolower( temp[i] );
  1827. registerMask = MakeRegisterMask(temp);
  1828. if (registerMask != 0)
  1829. {
  1830. //vs10_lval.sval = temp;
  1831. vs10_lval.lval = registerMask;
  1832. BEGIN(INITIAL);
  1833. return XYZW_MODIFIER;
  1834. }
  1835. else
  1836. {
  1837. //vs10_lval.sval = temp;
  1838. vs10_lval.lval = FindSwizzleValue(temp);
  1839. BEGIN(INITIAL);
  1840. return SWIZZLE_MODIFIER;
  1841. }
  1842. #endif
  1843. }
  1844. YY_BREAK
  1845. case 40:
  1846. YY_RULE_SETUP
  1847. #line 988 "vs1.0_tokens.l"
  1848. {
  1849. BEGIN(INITIAL);
  1850. yyless(0);
  1851. }
  1852. YY_BREAK
  1853. case 41:
  1854. YY_RULE_SETUP
  1855. #line 993 "vs1.0_tokens.l"
  1856. {
  1857. /* setup and save off #define/macro name */
  1858. if (FindMacro(yytext) != NULL)
  1859. {
  1860. LexWarning("Redefinition of #define/macro %s, ignoring.\n", yytext);
  1861. if (gbProcessingDefine)
  1862. {
  1863. BEGIN(EATDEFINE);
  1864. }
  1865. else
  1866. {
  1867. BEGIN(EATMACRO);
  1868. }
  1869. }
  1870. else
  1871. {
  1872. BEGIN(MACROPARMSTART);
  1873. // %%%%% This should be setup to use memory pools
  1874. gTempMacro = (MACROENTRY *)malloc(sizeof(MACROENTRY));
  1875. if (gTempMacro == NULL)
  1876. {
  1877. LexError("Out of memory for macro table.\n");
  1878. if (gbProcessingDefine)
  1879. {
  1880. BEGIN(EATDEFINE);
  1881. }
  1882. else
  1883. {
  1884. BEGIN(EATMACRO);
  1885. }
  1886. }
  1887. else
  1888. {
  1889. gTempMacro->prev = gLastMacro;
  1890. gTempMacro->next = NULL;
  1891. gTempMacro->firstMacroParms = NULL;
  1892. gTempMacro->lastMacroParms = NULL;
  1893. gTempMacro->firstMacroLines = NULL;
  1894. gTempMacro->lastMacroLines = NULL;
  1895. gTempMacro->numParms = 0;
  1896. gTempMacro->bIsDefine = gbProcessingDefine;
  1897. gTempMacro->nLines = 0;
  1898. if (gCurFileName != NULL)
  1899. {
  1900. gTempMacro->fileName = strdup(gCurFileName);
  1901. }
  1902. else
  1903. {
  1904. gTempMacro->fileName = NULL;
  1905. }
  1906. gTempMacro->lineNo = yylineno;
  1907. /* %%%%% this should be set up in memory pools. */
  1908. gTempMacro->macroName = (char *)malloc(strlen(yytext)+1);
  1909. if (gTempMacro->macroName == NULL)
  1910. {
  1911. LexError("Out of memory for string table.\n");
  1912. SAFEFREE(gTempMacro);
  1913. if (gbProcessingDefine)
  1914. {
  1915. BEGIN(EATDEFINE);
  1916. }
  1917. else
  1918. {
  1919. BEGIN(EATMACRO);
  1920. }
  1921. }
  1922. else
  1923. {
  1924. strcpy(gTempMacro->macroName, yytext);
  1925. }
  1926. }
  1927. }
  1928. }
  1929. YY_BREAK
  1930. case 42:
  1931. YY_RULE_SETUP
  1932. #line 1072 "vs1.0_tokens.l"
  1933. {
  1934. LexError("No macro name specified, skipping macro definition.\n");
  1935. SAFEFREE(gTempMacro->fileName);
  1936. SAFEFREE(gTempMacro);
  1937. if (gbProcessingDefine)
  1938. {
  1939. BEGIN(EATDEFINE);
  1940. }
  1941. else
  1942. {
  1943. BEGIN(EATMACRO);
  1944. }
  1945. // GenDebugLine();
  1946. // GenListString();
  1947. gLinesAssembled++;
  1948. yylineno++;
  1949. }
  1950. YY_BREAK
  1951. case 43:
  1952. YY_RULE_SETUP
  1953. #line 1091 "vs1.0_tokens.l"
  1954. {
  1955. gCountParen++;
  1956. }
  1957. YY_BREAK
  1958. case 44:
  1959. YY_RULE_SETUP
  1960. #line 1095 "vs1.0_tokens.l"
  1961. {}
  1962. YY_BREAK
  1963. case 45:
  1964. YY_RULE_SETUP
  1965. #line 1097 "vs1.0_tokens.l"
  1966. {
  1967. if (gbProcessingDefine && (gCountParen == 0))
  1968. {
  1969. EndMacroParms();
  1970. }
  1971. else
  1972. {
  1973. BEGIN(MACROPARM);
  1974. }
  1975. yyless(0);
  1976. }
  1977. YY_BREAK
  1978. case 46:
  1979. YY_RULE_SETUP
  1980. #line 1109 "vs1.0_tokens.l"
  1981. {
  1982. if ((gCountParen == 0) && gbProcessingDefine)
  1983. {
  1984. EndMacroParms();
  1985. }
  1986. }
  1987. YY_BREAK
  1988. case 47:
  1989. YY_RULE_SETUP
  1990. #line 1116 "vs1.0_tokens.l"
  1991. {
  1992. if (gCountParen == 0)
  1993. {
  1994. EndMacroParms();
  1995. }
  1996. }
  1997. YY_BREAK
  1998. case 48:
  1999. YY_RULE_SETUP
  2000. #line 1123 "vs1.0_tokens.l"
  2001. {}
  2002. YY_BREAK
  2003. case YY_STATE_EOF(MACROPARM):
  2004. #line 1125 "vs1.0_tokens.l"
  2005. {
  2006. EndMacroParms();
  2007. // GenDebugLine();
  2008. // GenListString();
  2009. yylineno++;
  2010. gLinesAssembled++;
  2011. BEGIN(INITIAL);
  2012. }
  2013. YY_BREAK
  2014. case 49:
  2015. YY_RULE_SETUP
  2016. #line 1134 "vs1.0_tokens.l"
  2017. {
  2018. if (gbProcessingDefine && (gCountParen > 0))
  2019. {
  2020. LexError("Malformed #define, skipping.\n");
  2021. BEGIN(SAVELINE);
  2022. }
  2023. else
  2024. {
  2025. EndMacroParms();
  2026. // GenDebugLine();
  2027. // GenListString();
  2028. yylineno++;
  2029. gLinesAssembled++;
  2030. if (gbProcessingDefine)
  2031. {
  2032. gbProcessingDefine = false;
  2033. BEGIN(SAVELINE);
  2034. }
  2035. }
  2036. }
  2037. YY_BREAK
  2038. case 50:
  2039. YY_RULE_SETUP
  2040. #line 1156 "vs1.0_tokens.l"
  2041. {
  2042. MACROTEXT *tMacro;
  2043. char *macroParmEnd;
  2044. unsigned int startOffset;
  2045. bool bFoundEndParen;
  2046. unsigned int leftParenCount;
  2047. unsigned int rightParenCount;
  2048. bFoundEndParen = false;
  2049. // sheesh, we gotta count the parenthesis....
  2050. macroParmEnd = yytext;
  2051. leftParenCount = 0;
  2052. rightParenCount = 0;
  2053. while (*macroParmEnd)
  2054. {
  2055. if (*macroParmEnd == ')')
  2056. {
  2057. rightParenCount++;
  2058. }
  2059. if (*macroParmEnd == '(')
  2060. {
  2061. leftParenCount++;
  2062. }
  2063. macroParmEnd++;
  2064. }
  2065. // if we found the last right parenthesis.
  2066. if (rightParenCount == leftParenCount+1)
  2067. {
  2068. // find if we got the last parenthesis on this line
  2069. macroParmEnd = strrchr(yytext, ')');
  2070. yyless((macroParmEnd - yytext));
  2071. BEGIN(MACROPARMEND);
  2072. }
  2073. startOffset = strspn(yytext, " \t");
  2074. tMacro = SaveMacroText(&yytext[startOffset], gTempMacro->lastMacroParms);
  2075. if (tMacro == NULL)
  2076. {
  2077. LexError("Out of memory for string table for macro parameter(s).\n");
  2078. FreeMacroEntry(gTempMacro);
  2079. BEGIN(EATMACRO);
  2080. }
  2081. else
  2082. {
  2083. // if first one wasn't set then set it
  2084. if (gTempMacro->firstMacroParms == NULL)
  2085. {
  2086. gTempMacro->firstMacroParms = tMacro;
  2087. }
  2088. gTempMacro->lastMacroParms = tMacro;
  2089. gTempMacro->numParms++;
  2090. }
  2091. }
  2092. YY_BREAK
  2093. case 51:
  2094. YY_RULE_SETUP
  2095. #line 1218 "vs1.0_tokens.l"
  2096. {
  2097. if (!gbProcessingDefine && !gbTempInsideMacro)
  2098. {
  2099. LexError("Malformed macro, skipping.\n");
  2100. BEGIN(EATMACRO);
  2101. }
  2102. else
  2103. {
  2104. gCountParen--;
  2105. // we can get multiple \n's here
  2106. while (yytext[yyleng-2] == '\n')
  2107. {
  2108. yyleng--;
  2109. }
  2110. yyless(yyleng);
  2111. // if there isn't a \n on this line, macro starts on this line,
  2112. // not next, like in a macro definition
  2113. if (yytext[yyleng-1] != '\n')
  2114. {
  2115. EndMacroParms();
  2116. }
  2117. else
  2118. {
  2119. if (yytext[yyleng-1] == '\n')
  2120. {
  2121. gTempMacro->lineNo++;
  2122. }
  2123. // count this line
  2124. gTempMacro->nLines++;
  2125. // GenDebugLine();
  2126. // GenListString();
  2127. EndMacroParms();
  2128. if (!gbInsideMacro)
  2129. {
  2130. yylineno++;
  2131. }
  2132. gLinesAssembled++;
  2133. }
  2134. }
  2135. }
  2136. YY_BREAK
  2137. case 52:
  2138. YY_RULE_SETUP
  2139. #line 1263 "vs1.0_tokens.l"
  2140. {
  2141. if (!gbProcessingDefine && !gbTempInsideMacro)
  2142. {
  2143. LexError("Malformed macro, skipping.\n");
  2144. BEGIN(EATMACRO);
  2145. }
  2146. else
  2147. {
  2148. // no matter what count this line
  2149. gTempMacro->nLines++;
  2150. gCountParen--;
  2151. EndMacroParms();
  2152. if (!gbInsideMacro)
  2153. {
  2154. yylineno++;
  2155. }
  2156. gLinesAssembled++;
  2157. }
  2158. }
  2159. YY_BREAK
  2160. case 53:
  2161. YY_RULE_SETUP
  2162. #line 1285 "vs1.0_tokens.l"
  2163. {
  2164. if (!gbProcessingDefine && !gbTempInsideMacro)
  2165. {
  2166. LexError("Malformed macro, skipping.\n");
  2167. BEGIN(EATMACRO);
  2168. }
  2169. else
  2170. {
  2171. gCountParen--;
  2172. if (gCountParen == 0)
  2173. {
  2174. // no matter what count this line
  2175. gTempMacro->nLines++;
  2176. EndMacroParms();
  2177. if (!gbInsideMacro)
  2178. {
  2179. yylineno++;
  2180. }
  2181. gLinesAssembled++;
  2182. }
  2183. else
  2184. {
  2185. REJECT;
  2186. }
  2187. }
  2188. }
  2189. YY_BREAK
  2190. case 54:
  2191. YY_RULE_SETUP
  2192. #line 1313 "vs1.0_tokens.l"
  2193. {
  2194. MACROTEXT *tMacro;
  2195. unsigned int copyLen;
  2196. char *endLine;
  2197. gSaveLine[0] ='\0';
  2198. endLine = strchr(yytext, '\\');
  2199. copyLen = (endLine - yytext);
  2200. if (copyLen > MAXSAVELINE)
  2201. {
  2202. copyLen = MAXSAVELINE;
  2203. }
  2204. strncat(gSaveLine, yytext, copyLen);
  2205. strcat(gSaveLine, "\n");
  2206. tMacro = SaveMacroText(gSaveLine, gLastMacro->lastMacroLines);
  2207. if (tMacro == NULL)
  2208. {
  2209. LexError("Out of memory for string table for macro parameter(s).\n");
  2210. BEGIN(EATDEFINE);
  2211. }
  2212. else
  2213. {
  2214. gLastMacro->nLines++;
  2215. // if first one wasn't set then set it
  2216. if (gLastMacro->firstMacroLines == NULL)
  2217. {
  2218. gLastMacro->firstMacroLines = tMacro;
  2219. }
  2220. gLastMacro->lastMacroLines = tMacro;
  2221. }
  2222. // GenDebugLine();
  2223. // GenListString();
  2224. yylineno++;
  2225. gLinesAssembled++;
  2226. }
  2227. YY_BREAK
  2228. case 55:
  2229. YY_RULE_SETUP
  2230. #line 1352 "vs1.0_tokens.l"
  2231. {
  2232. strncpy(gSaveLine, yytext, MAXSAVELINE);
  2233. if (gbProcessingDefine)
  2234. {
  2235. LexError("Malformed #define, skipping.\n");
  2236. }
  2237. BEGIN(ENDMACRO);
  2238. }
  2239. YY_BREAK
  2240. case 56:
  2241. YY_RULE_SETUP
  2242. #line 1363 "vs1.0_tokens.l"
  2243. {
  2244. MACROTEXT *tMacro;
  2245. // check if processing #define and only one line, if not then append \n
  2246. if (!gbProcessingDefine || (gLastMacro->nLines >= 1))
  2247. {
  2248. gSaveLine[0] = '\0';
  2249. strncat(gSaveLine, yytext, MAXSAVELINE);
  2250. strcat(gSaveLine, "\n");
  2251. tMacro = SaveMacroText(gSaveLine, gLastMacro->lastMacroLines);
  2252. gLastMacro->nLines++;
  2253. }
  2254. else if (gLastMacro->numParms > 0) // check if parameters were there
  2255. {
  2256. // if so, we need the '\n' appended
  2257. gMacroLine[0] = '\0';
  2258. strncat(gMacroLine, yytext, MAXSAVELINE);
  2259. strcat(gMacroLine, "\n");
  2260. tMacro = SaveMacroText(gMacroLine, gLastMacro->lastMacroLines);
  2261. gLastMacro->nLines++;
  2262. }
  2263. else // straight no newline macro replace
  2264. {
  2265. tMacro = SaveMacroText(yytext, gLastMacro->lastMacroLines);
  2266. }
  2267. if (tMacro == NULL)
  2268. {
  2269. LexError("Out of memory for string table for macro parameter(s).\n");
  2270. BEGIN(EATMACRO);
  2271. }
  2272. else
  2273. {
  2274. // if first one wasn't set then set it
  2275. if (gLastMacro->firstMacroLines == NULL)
  2276. {
  2277. gLastMacro->firstMacroLines = tMacro;
  2278. }
  2279. gLastMacro->lastMacroLines = tMacro;
  2280. }
  2281. }
  2282. YY_BREAK
  2283. case 57:
  2284. YY_RULE_SETUP
  2285. #line 1406 "vs1.0_tokens.l"
  2286. {
  2287. MACROTEXT *tMacro;
  2288. // GenDebugLine();
  2289. // GenListString();
  2290. yylineno++;
  2291. gLinesAssembled++;
  2292. if (gbProcessingDefine)
  2293. {
  2294. gbProcessingDefine = false;
  2295. BEGIN(SAVELINE);
  2296. }
  2297. else
  2298. {
  2299. // this means \n by itself inside macro body
  2300. if (((yylineno-1) - gLastMacro->lineNo) != gLastMacro->nLines)
  2301. {
  2302. strcpy(gMacroLine, "\n");
  2303. tMacro = SaveMacroText(gMacroLine, gLastMacro->lastMacroLines);
  2304. gLastMacro->nLines++;
  2305. if (tMacro == NULL)
  2306. {
  2307. LexError("Out of memory for string table for macro parameter(s).\n");
  2308. BEGIN(EATMACRO);
  2309. }
  2310. else
  2311. {
  2312. // if first one wasn't set then set it
  2313. if (gLastMacro->firstMacroLines == NULL)
  2314. {
  2315. gLastMacro->firstMacroLines = tMacro;
  2316. }
  2317. gLastMacro->lastMacroLines = tMacro;
  2318. }
  2319. }
  2320. }
  2321. }
  2322. YY_BREAK
  2323. case 58:
  2324. YY_RULE_SETUP
  2325. #line 1446 "vs1.0_tokens.l"
  2326. {
  2327. BEGIN(SAVELINE);
  2328. // GenDebugLine();
  2329. // GenListString();
  2330. gLinesAssembled++;
  2331. yylineno++;
  2332. }
  2333. YY_BREAK
  2334. case 59:
  2335. YY_RULE_SETUP
  2336. #line 1454 "vs1.0_tokens.l"
  2337. {
  2338. strncpy(gSaveLine, yytext, MAXSAVELINE);
  2339. // GenDebugLine();
  2340. // GenListString();
  2341. gLinesAssembled++;
  2342. yylineno++;
  2343. }
  2344. YY_BREAK
  2345. case 60:
  2346. YY_RULE_SETUP
  2347. #line 1462 "vs1.0_tokens.l"
  2348. {
  2349. strncpy(gSaveLine, yytext, MAXSAVELINE);
  2350. // GenDebugLine();
  2351. // GenListString();
  2352. gLinesAssembled++;
  2353. yylineno++;
  2354. }
  2355. YY_BREAK
  2356. case 61:
  2357. YY_RULE_SETUP
  2358. #line 1470 "vs1.0_tokens.l"
  2359. {
  2360. strncpy(gSaveLine, yytext, MAXSAVELINE);
  2361. // GenDebugLine();
  2362. // GenListString();
  2363. gLinesAssembled++;
  2364. yylineno++;
  2365. BEGIN(SAVELINE);
  2366. }
  2367. YY_BREAK
  2368. case 62:
  2369. YY_RULE_SETUP
  2370. #line 1479 "vs1.0_tokens.l"
  2371. {
  2372. gTempParseMacro = FindMacro(yytext);
  2373. if (gTempParseMacro != NULL)
  2374. {
  2375. if (gIncludeStackIndex >= MAX_INCLUDE_DEPTH )
  2376. {
  2377. LexError("macros nested too deeply");
  2378. exit( 1 );
  2379. }
  2380. if (gTempParseMacro->firstMacroLines != NULL)
  2381. {
  2382. gTempMacro = (MACROENTRY *)malloc(sizeof(MACROENTRY));
  2383. if (gTempMacro == NULL)
  2384. {
  2385. LexError("Out of memory allocating MACROENTRY structure.\n");
  2386. }
  2387. else
  2388. {
  2389. gTempMacro->next = NULL;
  2390. gTempMacro->prev = NULL;
  2391. gTempMacro->macroName = NULL;
  2392. gTempMacro->firstMacroParms = NULL;
  2393. gTempMacro->lastMacroParms = NULL;
  2394. gTempMacro->firstMacroLines = NULL;
  2395. gTempMacro->lastMacroLines = NULL;
  2396. gTempMacro->numParms = 0;
  2397. gTempMacro->nLines = 0;
  2398. gbTempInsideMacro = true; // flag we are currently doing a macro replace.
  2399. gInvokeState = YYSTATE;
  2400. if (gTempParseMacro->numParms > 0)
  2401. {
  2402. BEGIN(MACROPARMSTART);
  2403. }
  2404. else
  2405. {
  2406. EndMacroParms();
  2407. gbTempInsideMacro = false; // no longer waiting for macro invocation
  2408. }
  2409. }
  2410. }
  2411. }
  2412. else
  2413. {
  2414. BEGIN(INITIAL);
  2415. REJECT;
  2416. }
  2417. }
  2418. YY_BREAK
  2419. case 63:
  2420. YY_RULE_SETUP
  2421. #line 1533 "vs1.0_tokens.l"
  2422. {
  2423. // fprintf( stderr, "%c ", yytext[0] );
  2424. return yytext[0];
  2425. }
  2426. YY_BREAK
  2427. case 64:
  2428. YY_RULE_SETUP
  2429. #line 1539 "vs1.0_tokens.l"
  2430. {}
  2431. YY_BREAK
  2432. case 65:
  2433. YY_RULE_SETUP
  2434. #line 1541 "vs1.0_tokens.l"
  2435. {
  2436. LexError("Didn't find label string for #define.\n");
  2437. BEGIN(SAVELINE);
  2438. // return '\n';
  2439. }
  2440. YY_BREAK
  2441. case 66:
  2442. YY_RULE_SETUP
  2443. #line 1547 "vs1.0_tokens.l"
  2444. {
  2445. //fprintf(stderr, "\n");
  2446. // line_incr = 1;
  2447. line_incr++;
  2448. BEGIN(SAVELINE);
  2449. return '\n';
  2450. }
  2451. YY_BREAK
  2452. case 67:
  2453. YY_RULE_SETUP
  2454. #line 1555 "vs1.0_tokens.l"
  2455. {
  2456. BEGIN(INITIAL);
  2457. // fprintf( stderr, "%s", yytext );
  2458. if (yyleng == 1)
  2459. return yytext[0];
  2460. else
  2461. LexError("Unrecognized Token: %s\n", yytext);
  2462. return UNKNOWN_STRING;
  2463. }
  2464. YY_BREAK
  2465. case 68:
  2466. YY_RULE_SETUP
  2467. #line 1565 "vs1.0_tokens.l"
  2468. {
  2469. // vs10_lval.ival = yytext[0];
  2470. LexError("Illegal character: %d decimal.\n", yytext[0]);
  2471. return(ILLEGAL);
  2472. }
  2473. YY_BREAK
  2474. case 69:
  2475. YY_RULE_SETUP
  2476. #line 1571 "vs1.0_tokens.l"
  2477. {
  2478. // vs10_lval.ival = yytext[0];
  2479. LexError("Illegal character: %d decimal.\n", yytext[0]);
  2480. return(ILLEGAL);
  2481. }
  2482. YY_BREAK
  2483. case 70:
  2484. YY_RULE_SETUP
  2485. #line 1577 "vs1.0_tokens.l"
  2486. {
  2487. return yytext[0];
  2488. }
  2489. YY_BREAK
  2490. case 71:
  2491. YY_RULE_SETUP
  2492. #line 1581 "vs1.0_tokens.l"
  2493. {
  2494. BEGIN(EATSTRING);
  2495. yyless(0);
  2496. }
  2497. YY_BREAK
  2498. case YY_STATE_EOF(INITIAL):
  2499. case YY_STATE_EOF(SKIPLINE):
  2500. case YY_STATE_EOF(EATSTRING):
  2501. case YY_STATE_EOF(SAVELINE):
  2502. case YY_STATE_EOF(MACRONAME):
  2503. case YY_STATE_EOF(EATMACRO):
  2504. case YY_STATE_EOF(EATDEFINE):
  2505. case YY_STATE_EOF(MODIFIER):
  2506. case YY_STATE_EOF(MACROPARMSTART):
  2507. case YY_STATE_EOF(IFDEFNAME):
  2508. case YY_STATE_EOF(MACROPARMEND):
  2509. #line 1586 "vs1.0_tokens.l"
  2510. {
  2511. bool wasInMacro;
  2512. bool oneLiner;
  2513. char *macroText;
  2514. wasInMacro = gbInsideMacro;
  2515. oneLiner = false;
  2516. // if we are inside the macro then do next line until their are no more
  2517. if (gbInsideMacro)
  2518. {
  2519. oneLiner = (gParseMacro->nLines == 0);
  2520. // free the temporary parameter replaced line we were working on.
  2521. // get next line in macro text, if any
  2522. gMacroLineParse = gMacroLineParse->next;
  2523. // more lines to parse?
  2524. if (gMacroLineParse != NULL)
  2525. {
  2526. macroText = gMacroLine;
  2527. // if no replacement text, just use source line
  2528. if (gParseMacro->firstMacroParms == NULL)
  2529. {
  2530. macroText = gMacroLineParse->macroText;
  2531. }
  2532. else
  2533. {
  2534. // replace the macro parameters
  2535. ReplaceMacroParms(gMacroLineParse->macroText, gMacroLine, gParseMacro, gInvokeMacro);
  2536. }
  2537. // if (gExpandMacros)
  2538. // {
  2539. // strcpy(gSaveLine, macroText);
  2540. // }
  2541. BEGIN(INITIAL);
  2542. // and lex it.
  2543. yy_scan_string(macroText);
  2544. }
  2545. else
  2546. {
  2547. // no more lines in this macro, so free the working macro
  2548. SAFEFREE(gInvokeMacro);
  2549. // shut off flag for inside a macro replacement state.
  2550. gbInsideMacro = false;
  2551. }
  2552. }
  2553. if (gbProcessingIFDEF && !wasInMacro)
  2554. {
  2555. LexError("End of file reached before #endif found, macro started on line %d.\n", gIfDefStartLine);
  2556. }
  2557. if (!gbInsideMacro)
  2558. {
  2559. if ( gIncludeStackIndex == 0 )
  2560. {
  2561. if (!gbProcessingBuiltIn)
  2562. CleanUp();
  2563. return 0;
  2564. // return TOKEN_EOF;
  2565. }
  2566. else
  2567. {
  2568. yy_delete_buffer( YY_CURRENT_BUFFER );
  2569. SAFEFREE(gCurFileName);
  2570. // SAFEDELETE(myin);
  2571. // SAFECLOSE(yyin);
  2572. }
  2573. gIncludeStackIndex--;
  2574. SAFEDELETEARRAY( gIncludeStack[gIncludeStackIndex].nextString );
  2575. yy_switch_to_buffer(gIncludeStack[gIncludeStackIndex].buffer );
  2576. gCurFileName = gIncludeStack[gIncludeStackIndex].fileName;
  2577. // yyin = gIncludeStack[gIncludeStackIndex].fileHandle;
  2578. myin = gIncludeStack[gIncludeStackIndex].prevString;
  2579. yylineno = gIncludeStack[gIncludeStackIndex].lineNo;
  2580. gInvokeMacro = gIncludeStack[gIncludeStackIndex].lastInvokeMacro;
  2581. gParseMacro = gIncludeStack[gIncludeStackIndex].lastParseMacro;
  2582. gMacroLineParse = gIncludeStack[gIncludeStackIndex].lastMacroLineParse;
  2583. gbInsideInclude = gIncludeStack[gIncludeStackIndex].lastbInsideInclude;
  2584. gbInsideMacro = gIncludeStack[gIncludeStackIndex].lastbInsideMacro;
  2585. gbProcessingIFDEF = gIncludeStack[gIncludeStackIndex].lastbProcessingIFDEF;
  2586. if (!gbInsideMacro && !oneLiner)
  2587. {
  2588. // GenSwitchFileNames(gCurFileName);
  2589. BEGIN(SAVELINE);
  2590. }
  2591. else
  2592. {
  2593. BEGIN(INITIAL);
  2594. }
  2595. // gSaveLine was last line saved, before macro invocation
  2596. if (wasInMacro && !gbInsideMacro && !oneLiner)
  2597. {
  2598. // GenDebugLine();
  2599. // GenListString();
  2600. gLinesAssembled++;
  2601. yylineno++;
  2602. }
  2603. }
  2604. }
  2605. YY_BREAK
  2606. case 72:
  2607. YY_RULE_SETUP
  2608. #line 1695 "vs1.0_tokens.l"
  2609. ECHO;
  2610. YY_BREAK
  2611. #line 2908 "_vs1.0_lexer.cpp"
  2612. case YY_END_OF_BUFFER:
  2613. {
  2614. /* Amount of text matched not including the EOB char. */
  2615. int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
  2616. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  2617. *yy_cp = yy_hold_char;
  2618. YY_RESTORE_YY_MORE_OFFSET
  2619. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
  2620. {
  2621. /* We're scanning a new file or input source. It's
  2622. * possible that this happened because the user
  2623. * just pointed yyin at a new source and called
  2624. * yylex(). If so, then we have to assure
  2625. * consistency between yy_current_buffer and our
  2626. * globals. Here is the right place to do so, because
  2627. * this is the first action (other than possibly a
  2628. * back-up) that will match for the new input source.
  2629. */
  2630. yy_n_chars = yy_current_buffer->yy_n_chars;
  2631. yy_current_buffer->yy_input_file = yyin;
  2632. yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
  2633. }
  2634. /* Note that here we test for yy_c_buf_p "<=" to the position
  2635. * of the first EOB in the buffer, since yy_c_buf_p will
  2636. * already have been incremented past the NUL character
  2637. * (since all states make transitions on EOB to the
  2638. * end-of-buffer state). Contrast this with the test
  2639. * in input().
  2640. */
  2641. if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  2642. { /* This was really a NUL. */
  2643. yy_state_type yy_next_state;
  2644. yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
  2645. yy_current_state = yy_get_previous_state();
  2646. /* Okay, we're now positioned to make the NUL
  2647. * transition. We couldn't have
  2648. * yy_get_previous_state() go ahead and do it
  2649. * for us because it doesn't know how to deal
  2650. * with the possibility of jamming (and we don't
  2651. * want to build jamming into it because then it
  2652. * will run more slowly).
  2653. */
  2654. yy_next_state = yy_try_NUL_trans( yy_current_state );
  2655. yy_bp = yytext_ptr + YY_MORE_ADJ;
  2656. if ( yy_next_state )
  2657. {
  2658. /* Consume the NUL. */
  2659. yy_cp = ++yy_c_buf_p;
  2660. yy_current_state = yy_next_state;
  2661. goto yy_match;
  2662. }
  2663. else
  2664. {
  2665. yy_cp = yy_c_buf_p;
  2666. goto yy_find_action;
  2667. }
  2668. }
  2669. else switch ( yy_get_next_buffer() )
  2670. {
  2671. case EOB_ACT_END_OF_FILE:
  2672. {
  2673. yy_did_buffer_switch_on_eof = 0;
  2674. if ( yywrap() )
  2675. {
  2676. /* Note: because we've taken care in
  2677. * yy_get_next_buffer() to have set up
  2678. * yytext, we can now set up
  2679. * yy_c_buf_p so that if some total
  2680. * hoser (like flex itself) wants to
  2681. * call the scanner after we return the
  2682. * YY_NULL, it'll still work - another
  2683. * YY_NULL will get returned.
  2684. */
  2685. yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  2686. yy_act = YY_STATE_EOF(YY_START);
  2687. goto do_action;
  2688. }
  2689. else
  2690. {
  2691. if ( ! yy_did_buffer_switch_on_eof )
  2692. YY_NEW_FILE;
  2693. }
  2694. break;
  2695. }
  2696. case EOB_ACT_CONTINUE_SCAN:
  2697. yy_c_buf_p =
  2698. yytext_ptr + yy_amount_of_matched_text;
  2699. yy_current_state = yy_get_previous_state();
  2700. yy_cp = yy_c_buf_p;
  2701. yy_bp = yytext_ptr + YY_MORE_ADJ;
  2702. goto yy_match;
  2703. case EOB_ACT_LAST_MATCH:
  2704. yy_c_buf_p =
  2705. &yy_current_buffer->yy_ch_buf[yy_n_chars];
  2706. yy_current_state = yy_get_previous_state();
  2707. yy_cp = yy_c_buf_p;
  2708. yy_bp = yytext_ptr + YY_MORE_ADJ;
  2709. goto yy_find_action;
  2710. }
  2711. break;
  2712. }
  2713. default:
  2714. YY_FATAL_ERROR(
  2715. "fatal flex scanner internal error--no action found" );
  2716. } /* end of action switch */
  2717. } /* end of scanning one token */
  2718. } /* end of yylex */
  2719. /* yy_get_next_buffer - try to read in a new buffer
  2720. *
  2721. * Returns a code representing an action:
  2722. * EOB_ACT_LAST_MATCH -
  2723. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  2724. * EOB_ACT_END_OF_FILE - end of file
  2725. */
  2726. static int yy_get_next_buffer()
  2727. {
  2728. register char *dest = yy_current_buffer->yy_ch_buf;
  2729. register char *source = yytext_ptr;
  2730. register int number_to_move, i;
  2731. int ret_val;
  2732. if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  2733. YY_FATAL_ERROR(
  2734. "fatal flex scanner internal error--end of buffer missed" );
  2735. if ( yy_current_buffer->yy_fill_buffer == 0 )
  2736. { /* Don't try to fill the buffer, so this is an EOF. */
  2737. if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
  2738. {
  2739. /* We matched a single character, the EOB, so
  2740. * treat this as a final EOF.
  2741. */
  2742. return EOB_ACT_END_OF_FILE;
  2743. }
  2744. else
  2745. {
  2746. /* We matched some text prior to the EOB, first
  2747. * process it.
  2748. */
  2749. return EOB_ACT_LAST_MATCH;
  2750. }
  2751. }
  2752. /* Try to read more data. */
  2753. /* First move last chars to start of buffer. */
  2754. number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
  2755. for ( i = 0; i < number_to_move; ++i )
  2756. *(dest++) = *(source++);
  2757. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  2758. /* don't do the read, it's not guaranteed to return an EOF,
  2759. * just force an EOF
  2760. */
  2761. yy_current_buffer->yy_n_chars = yy_n_chars = 0;
  2762. else
  2763. {
  2764. int num_to_read =
  2765. yy_current_buffer->yy_buf_size - number_to_move - 1;
  2766. while ( num_to_read <= 0 )
  2767. { /* Not enough room in the buffer - grow it. */
  2768. #ifdef YY_USES_REJECT
  2769. YY_FATAL_ERROR(
  2770. "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
  2771. #else
  2772. /* just a shorter name for the current buffer */
  2773. YY_BUFFER_STATE b = yy_current_buffer;
  2774. int yy_c_buf_p_offset =
  2775. (int) (yy_c_buf_p - b->yy_ch_buf);
  2776. if ( b->yy_is_our_buffer )
  2777. {
  2778. int new_size = b->yy_buf_size * 2;
  2779. if ( new_size <= 0 )
  2780. b->yy_buf_size += b->yy_buf_size / 8;
  2781. else
  2782. b->yy_buf_size *= 2;
  2783. b->yy_ch_buf = (char *)
  2784. /* Include room in for 2 EOB chars. */
  2785. yy_flex_realloc( (void *) b->yy_ch_buf,
  2786. b->yy_buf_size + 2 );
  2787. }
  2788. else
  2789. /* Can't grow it, we don't own it. */
  2790. b->yy_ch_buf = 0;
  2791. if ( ! b->yy_ch_buf )
  2792. YY_FATAL_ERROR(
  2793. "fatal error - scanner input buffer overflow" );
  2794. yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
  2795. num_to_read = yy_current_buffer->yy_buf_size -
  2796. number_to_move - 1;
  2797. #endif
  2798. }
  2799. if ( num_to_read > YY_READ_BUF_SIZE )
  2800. num_to_read = YY_READ_BUF_SIZE;
  2801. /* Read in more data. */
  2802. YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  2803. yy_n_chars, num_to_read );
  2804. yy_current_buffer->yy_n_chars = yy_n_chars;
  2805. }
  2806. if ( yy_n_chars == 0 )
  2807. {
  2808. if ( number_to_move == YY_MORE_ADJ )
  2809. {
  2810. ret_val = EOB_ACT_END_OF_FILE;
  2811. yyrestart( yyin );
  2812. }
  2813. else
  2814. {
  2815. ret_val = EOB_ACT_LAST_MATCH;
  2816. yy_current_buffer->yy_buffer_status =
  2817. YY_BUFFER_EOF_PENDING;
  2818. }
  2819. }
  2820. else
  2821. ret_val = EOB_ACT_CONTINUE_SCAN;
  2822. yy_n_chars += number_to_move;
  2823. yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  2824. yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  2825. yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
  2826. return ret_val;
  2827. }
  2828. /* yy_get_previous_state - get the state just before the EOB char was reached */
  2829. static yy_state_type yy_get_previous_state()
  2830. {
  2831. register yy_state_type yy_current_state;
  2832. register char *yy_cp;
  2833. yy_current_state = yy_start;
  2834. yy_current_state += YY_AT_BOL();
  2835. yy_state_ptr = yy_state_buf;
  2836. *yy_state_ptr++ = yy_current_state;
  2837. for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  2838. {
  2839. register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 4);
  2840. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  2841. {
  2842. yy_current_state = (int) yy_def[yy_current_state];
  2843. if ( yy_current_state >= 329 )
  2844. yy_c = yy_meta[(unsigned int) yy_c];
  2845. }
  2846. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  2847. *yy_state_ptr++ = yy_current_state;
  2848. }
  2849. return yy_current_state;
  2850. }
  2851. /* yy_try_NUL_trans - try to make a transition on the NUL character
  2852. *
  2853. * synopsis
  2854. * next_state = yy_try_NUL_trans( current_state );
  2855. */
  2856. #ifdef YY_USE_PROTOS
  2857. static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
  2858. #else
  2859. static yy_state_type yy_try_NUL_trans( yy_current_state )
  2860. yy_state_type yy_current_state;
  2861. #endif
  2862. {
  2863. register int yy_is_jam;
  2864. register YY_CHAR yy_c = 4;
  2865. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  2866. {
  2867. yy_current_state = (int) yy_def[yy_current_state];
  2868. if ( yy_current_state >= 329 )
  2869. yy_c = yy_meta[(unsigned int) yy_c];
  2870. }
  2871. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  2872. yy_is_jam = (yy_current_state == 328);
  2873. if ( ! yy_is_jam )
  2874. *yy_state_ptr++ = yy_current_state;
  2875. return yy_is_jam ? 0 : yy_current_state;
  2876. }
  2877. #ifndef YY_NO_UNPUT
  2878. #ifdef YY_USE_PROTOS
  2879. static void yyunput( int c, register char *yy_bp )
  2880. #else
  2881. static void yyunput( c, yy_bp )
  2882. int c;
  2883. register char *yy_bp;
  2884. #endif
  2885. {
  2886. register char *yy_cp = yy_c_buf_p;
  2887. /* undo effects of setting up yytext */
  2888. *yy_cp = yy_hold_char;
  2889. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  2890. { /* need to shift things up to make room */
  2891. /* +2 for EOB chars. */
  2892. register int number_to_move = yy_n_chars + 2;
  2893. register char *dest = &yy_current_buffer->yy_ch_buf[
  2894. yy_current_buffer->yy_buf_size + 2];
  2895. register char *source =
  2896. &yy_current_buffer->yy_ch_buf[number_to_move];
  2897. while ( source > yy_current_buffer->yy_ch_buf )
  2898. *--dest = *--source;
  2899. yy_cp += (int) (dest - source);
  2900. yy_bp += (int) (dest - source);
  2901. yy_current_buffer->yy_n_chars =
  2902. yy_n_chars = yy_current_buffer->yy_buf_size;
  2903. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  2904. YY_FATAL_ERROR( "flex scanner push-back overflow" );
  2905. }
  2906. *--yy_cp = (char) c;
  2907. yytext_ptr = yy_bp;
  2908. yy_hold_char = *yy_cp;
  2909. yy_c_buf_p = yy_cp;
  2910. }
  2911. #endif /* ifndef YY_NO_UNPUT */
  2912. #ifdef __cplusplus
  2913. static int yyinput()
  2914. #else
  2915. static int input()
  2916. #endif
  2917. {
  2918. int c;
  2919. *yy_c_buf_p = yy_hold_char;
  2920. if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  2921. {
  2922. /* yy_c_buf_p now points to the character we want to return.
  2923. * If this occurs *before* the EOB characters, then it's a
  2924. * valid NUL; if not, then we've hit the end of the buffer.
  2925. */
  2926. if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  2927. /* This was really a NUL. */
  2928. *yy_c_buf_p = '\0';
  2929. else
  2930. { /* need more input */
  2931. int offset = yy_c_buf_p - yytext_ptr;
  2932. ++yy_c_buf_p;
  2933. switch ( yy_get_next_buffer() )
  2934. {
  2935. case EOB_ACT_LAST_MATCH:
  2936. /* This happens because yy_g_n_b()
  2937. * sees that we've accumulated a
  2938. * token and flags that we need to
  2939. * try matching the token before
  2940. * proceeding. But for input(),
  2941. * there's no matching to consider.
  2942. * So convert the EOB_ACT_LAST_MATCH
  2943. * to EOB_ACT_END_OF_FILE.
  2944. */
  2945. /* Reset buffer status. */
  2946. yyrestart( yyin );
  2947. /* fall through */
  2948. case EOB_ACT_END_OF_FILE:
  2949. {
  2950. if ( yywrap() )
  2951. return EOF;
  2952. if ( ! yy_did_buffer_switch_on_eof )
  2953. YY_NEW_FILE;
  2954. #ifdef __cplusplus
  2955. return yyinput();
  2956. #else
  2957. return input();
  2958. #endif
  2959. }
  2960. case EOB_ACT_CONTINUE_SCAN:
  2961. yy_c_buf_p = yytext_ptr + offset;
  2962. break;
  2963. }
  2964. }
  2965. }
  2966. c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
  2967. *yy_c_buf_p = '\0'; /* preserve yytext */
  2968. yy_hold_char = *++yy_c_buf_p;
  2969. yy_current_buffer->yy_at_bol = (c == '\n');
  2970. return c;
  2971. }
  2972. #ifdef YY_USE_PROTOS
  2973. void yyrestart( FILE *input_file )
  2974. #else
  2975. void yyrestart( input_file )
  2976. FILE *input_file;
  2977. #endif
  2978. {
  2979. if ( ! yy_current_buffer )
  2980. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  2981. yy_init_buffer( yy_current_buffer, input_file );
  2982. yy_load_buffer_state();
  2983. }
  2984. #ifdef YY_USE_PROTOS
  2985. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  2986. #else
  2987. void yy_switch_to_buffer( new_buffer )
  2988. YY_BUFFER_STATE new_buffer;
  2989. #endif
  2990. {
  2991. if ( yy_current_buffer == new_buffer )
  2992. return;
  2993. if ( yy_current_buffer )
  2994. {
  2995. /* Flush out information for old buffer. */
  2996. *yy_c_buf_p = yy_hold_char;
  2997. yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  2998. yy_current_buffer->yy_n_chars = yy_n_chars;
  2999. }
  3000. yy_current_buffer = new_buffer;
  3001. yy_load_buffer_state();
  3002. /* We don't actually know whether we did this switch during
  3003. * EOF (yywrap()) processing, but the only time this flag
  3004. * is looked at is after yywrap() is called, so it's safe
  3005. * to go ahead and always set it.
  3006. */
  3007. yy_did_buffer_switch_on_eof = 1;
  3008. }
  3009. #ifdef YY_USE_PROTOS
  3010. void yy_load_buffer_state( void )
  3011. #else
  3012. void yy_load_buffer_state()
  3013. #endif
  3014. {
  3015. yy_n_chars = yy_current_buffer->yy_n_chars;
  3016. yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  3017. yyin = yy_current_buffer->yy_input_file;
  3018. yy_hold_char = *yy_c_buf_p;
  3019. }
  3020. #ifdef YY_USE_PROTOS
  3021. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  3022. #else
  3023. YY_BUFFER_STATE yy_create_buffer( file, size )
  3024. FILE *file;
  3025. int size;
  3026. #endif
  3027. {
  3028. YY_BUFFER_STATE b;
  3029. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  3030. if ( ! b )
  3031. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  3032. b->yy_buf_size = size;
  3033. /* yy_ch_buf has to be 2 characters longer than the size given because
  3034. * we need to put in 2 end-of-buffer characters.
  3035. */
  3036. b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
  3037. if ( ! b->yy_ch_buf )
  3038. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  3039. b->yy_is_our_buffer = 1;
  3040. yy_init_buffer( b, file );
  3041. return b;
  3042. }
  3043. #ifdef YY_USE_PROTOS
  3044. void yy_delete_buffer( YY_BUFFER_STATE b )
  3045. #else
  3046. void yy_delete_buffer( b )
  3047. YY_BUFFER_STATE b;
  3048. #endif
  3049. {
  3050. if ( ! b )
  3051. return;
  3052. if ( b == yy_current_buffer )
  3053. yy_current_buffer = (YY_BUFFER_STATE) 0;
  3054. if ( b->yy_is_our_buffer )
  3055. yy_flex_free( (void *) b->yy_ch_buf );
  3056. yy_flex_free( (void *) b );
  3057. }
  3058. #ifdef YY_USE_PROTOS
  3059. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  3060. #else
  3061. void yy_init_buffer( b, file )
  3062. YY_BUFFER_STATE b;
  3063. FILE *file;
  3064. #endif
  3065. {
  3066. yy_flush_buffer( b );
  3067. b->yy_input_file = file;
  3068. b->yy_fill_buffer = 1;
  3069. #if YY_ALWAYS_INTERACTIVE
  3070. b->yy_is_interactive = 1;
  3071. #else
  3072. #if YY_NEVER_INTERACTIVE
  3073. b->yy_is_interactive = 0;
  3074. #else
  3075. b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  3076. #endif
  3077. #endif
  3078. }
  3079. #ifdef YY_USE_PROTOS
  3080. void yy_flush_buffer( YY_BUFFER_STATE b )
  3081. #else
  3082. void yy_flush_buffer( b )
  3083. YY_BUFFER_STATE b;
  3084. #endif
  3085. {
  3086. if ( ! b )
  3087. return;
  3088. b->yy_n_chars = 0;
  3089. /* We always need two end-of-buffer characters. The first causes
  3090. * a transition to the end-of-buffer state. The second causes
  3091. * a jam in that state.
  3092. */
  3093. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  3094. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  3095. b->yy_buf_pos = &b->yy_ch_buf[0];
  3096. b->yy_at_bol = 1;
  3097. b->yy_buffer_status = YY_BUFFER_NEW;
  3098. if ( b == yy_current_buffer )
  3099. yy_load_buffer_state();
  3100. }
  3101. #ifndef YY_NO_SCAN_BUFFER
  3102. #ifdef YY_USE_PROTOS
  3103. YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
  3104. #else
  3105. YY_BUFFER_STATE yy_scan_buffer( base, size )
  3106. char *base;
  3107. yy_size_t size;
  3108. #endif
  3109. {
  3110. YY_BUFFER_STATE b;
  3111. if ( size < 2 ||
  3112. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  3113. base[size-1] != YY_END_OF_BUFFER_CHAR )
  3114. /* They forgot to leave room for the EOB's. */
  3115. return 0;
  3116. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  3117. if ( ! b )
  3118. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  3119. b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
  3120. b->yy_buf_pos = b->yy_ch_buf = base;
  3121. b->yy_is_our_buffer = 0;
  3122. b->yy_input_file = 0;
  3123. b->yy_n_chars = b->yy_buf_size;
  3124. b->yy_is_interactive = 0;
  3125. b->yy_at_bol = 1;
  3126. b->yy_fill_buffer = 0;
  3127. b->yy_buffer_status = YY_BUFFER_NEW;
  3128. yy_switch_to_buffer( b );
  3129. return b;
  3130. }
  3131. #endif
  3132. #ifndef YY_NO_SCAN_STRING
  3133. #ifdef YY_USE_PROTOS
  3134. YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
  3135. #else
  3136. YY_BUFFER_STATE yy_scan_string( yy_str )
  3137. yyconst char *yy_str;
  3138. #endif
  3139. {
  3140. int len;
  3141. for ( len = 0; yy_str[len]; ++len )
  3142. ;
  3143. return yy_scan_bytes( yy_str, len );
  3144. }
  3145. #endif
  3146. #ifndef YY_NO_SCAN_BYTES
  3147. #ifdef YY_USE_PROTOS
  3148. YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
  3149. #else
  3150. YY_BUFFER_STATE yy_scan_bytes( bytes, len )
  3151. yyconst char *bytes;
  3152. int len;
  3153. #endif
  3154. {
  3155. YY_BUFFER_STATE b;
  3156. char *buf;
  3157. yy_size_t n;
  3158. int i;
  3159. /* Get memory for full buffer, including space for trailing EOB's. */
  3160. n = len + 2;
  3161. buf = (char *) yy_flex_alloc( n );
  3162. if ( ! buf )
  3163. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  3164. for ( i = 0; i < len; ++i )
  3165. buf[i] = bytes[i];
  3166. buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
  3167. b = yy_scan_buffer( buf, n );
  3168. if ( ! b )
  3169. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  3170. /* It's okay to grow etc. this buffer, and we should throw it
  3171. * away when we're done.
  3172. */
  3173. b->yy_is_our_buffer = 1;
  3174. return b;
  3175. }
  3176. #endif
  3177. #ifndef YY_NO_PUSH_STATE
  3178. #ifdef YY_USE_PROTOS
  3179. static void yy_push_state( int new_state )
  3180. #else
  3181. static void yy_push_state( new_state )
  3182. int new_state;
  3183. #endif
  3184. {
  3185. if ( yy_start_stack_ptr >= yy_start_stack_depth )
  3186. {
  3187. yy_size_t new_size;
  3188. yy_start_stack_depth += YY_START_STACK_INCR;
  3189. new_size = yy_start_stack_depth * sizeof( int );
  3190. if ( ! yy_start_stack )
  3191. yy_start_stack = (int *) yy_flex_alloc( new_size );
  3192. else
  3193. yy_start_stack = (int *) yy_flex_realloc(
  3194. (void *) yy_start_stack, new_size );
  3195. if ( ! yy_start_stack )
  3196. YY_FATAL_ERROR(
  3197. "out of memory expanding start-condition stack" );
  3198. }
  3199. yy_start_stack[yy_start_stack_ptr++] = YY_START;
  3200. BEGIN(new_state);
  3201. }
  3202. #endif
  3203. #ifndef YY_NO_POP_STATE
  3204. static void yy_pop_state()
  3205. {
  3206. if ( --yy_start_stack_ptr < 0 )
  3207. YY_FATAL_ERROR( "start-condition stack underflow" );
  3208. BEGIN(yy_start_stack[yy_start_stack_ptr]);
  3209. }
  3210. #endif
  3211. #ifndef YY_NO_TOP_STATE
  3212. static int yy_top_state()
  3213. {
  3214. return yy_start_stack[yy_start_stack_ptr - 1];
  3215. }
  3216. #endif
  3217. #ifndef YY_EXIT_FAILURE
  3218. #define YY_EXIT_FAILURE 2
  3219. #endif
  3220. #ifdef YY_USE_PROTOS
  3221. static void yy_fatal_error( yyconst char msg[] )
  3222. #else
  3223. static void yy_fatal_error( msg )
  3224. char msg[];
  3225. #endif
  3226. {
  3227. (void) fprintf( stderr, "%s\n", msg );
  3228. exit( YY_EXIT_FAILURE );
  3229. }
  3230. /* Redefine yyless() so it works in section 3 code. */
  3231. #undef yyless
  3232. #define yyless(n) \
  3233. do \
  3234. { \
  3235. /* Undo effects of setting up yytext. */ \
  3236. yytext[yyleng] = yy_hold_char; \
  3237. yy_c_buf_p = yytext + n; \
  3238. yy_hold_char = *yy_c_buf_p; \
  3239. *yy_c_buf_p = '\0'; \
  3240. yyleng = n; \
  3241. } \
  3242. while ( 0 )
  3243. /* Internal utility routines. */
  3244. #ifndef yytext_ptr
  3245. #ifdef YY_USE_PROTOS
  3246. static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
  3247. #else
  3248. static void yy_flex_strncpy( s1, s2, n )
  3249. char *s1;
  3250. yyconst char *s2;
  3251. int n;
  3252. #endif
  3253. {
  3254. register int i;
  3255. for ( i = 0; i < n; ++i )
  3256. s1[i] = s2[i];
  3257. }
  3258. #endif
  3259. #ifdef YY_NEED_STRLEN
  3260. #ifdef YY_USE_PROTOS
  3261. static int yy_flex_strlen( yyconst char *s )
  3262. #else
  3263. static int yy_flex_strlen( s )
  3264. yyconst char *s;
  3265. #endif
  3266. {
  3267. register int n;
  3268. for ( n = 0; s[n]; ++n )
  3269. ;
  3270. return n;
  3271. }
  3272. #endif
  3273. #ifdef YY_USE_PROTOS
  3274. static void *yy_flex_alloc( yy_size_t size )
  3275. #else
  3276. static void *yy_flex_alloc( size )
  3277. yy_size_t size;
  3278. #endif
  3279. {
  3280. return (void *) malloc( size );
  3281. }
  3282. // This function is never referenced under these specific conditions
  3283. // Removes a warning
  3284. #if !defined(YY_USES_REJECT) && defined(YY_NO_PUSH_STATE)
  3285. #ifdef YY_USE_PROTOS
  3286. static void *yy_flex_realloc( void *ptr, yy_size_t size )
  3287. #else
  3288. static void *yy_flex_realloc( ptr, size )
  3289. void *ptr;
  3290. yy_size_t size;
  3291. #endif
  3292. {
  3293. /* The cast to (char *) in the following accommodates both
  3294. * implementations that use char* generic pointers, and those
  3295. * that use void* generic pointers. It works with the latter
  3296. * because both ANSI C and C++ allow castless assignment from
  3297. * any pointer type to void*, and deal with argument conversions
  3298. * as though doing an assignment.
  3299. */
  3300. return (void *) realloc( (char *) ptr, size );
  3301. }
  3302. #endif
  3303. #ifdef YY_USE_PROTOS
  3304. static void yy_flex_free( void *ptr )
  3305. #else
  3306. static void yy_flex_free( ptr )
  3307. void *ptr;
  3308. #endif
  3309. {
  3310. free( ptr );
  3311. }
  3312. #if YY_MAIN
  3313. int main()
  3314. {
  3315. yylex();
  3316. return 0;
  3317. }
  3318. #endif
  3319. #line 1695 "vs1.0_tokens.l"
  3320. //=====================================================================
  3321. // Function: FindNMacro
  3322. // Description: Look through macros and see if it had been predefined
  3323. // Parameters: findName = name to lookup
  3324. // sLen = # characters valid in source (findName)
  3325. // Returns: MACROENTRY * = pointer to macro entry if found
  3326. //=====================================================================
  3327. MACROENTRY *FindNMacro(char *findName, unsigned int sLen)
  3328. {
  3329. MACROENTRY *curEntry;
  3330. curEntry = gLastMacro;
  3331. while (curEntry != NULL)
  3332. {
  3333. if (strlen(curEntry->macroName) == sLen)
  3334. {
  3335. if (!strncmp(curEntry->macroName, findName, sLen))
  3336. {
  3337. break;
  3338. }
  3339. }
  3340. curEntry = curEntry->prev;
  3341. }
  3342. return curEntry;
  3343. }
  3344. //=====================================================================
  3345. // Function: FindMacro
  3346. // Description: Look through macros and see if it had been predefined
  3347. // Parameters: findName = name to lookup
  3348. // Returns: MACROENTRY * = pointer to macro entry if found
  3349. //=====================================================================
  3350. MACROENTRY *FindMacro(char *findName)
  3351. {
  3352. MACROENTRY *curEntry;
  3353. curEntry = gLastMacro;
  3354. while (curEntry != NULL)
  3355. {
  3356. if (!strcmp(curEntry->macroName, findName))
  3357. {
  3358. break;
  3359. }
  3360. curEntry = curEntry->prev;
  3361. }
  3362. return curEntry;
  3363. }
  3364. //=====================================================================
  3365. // Function: CleanUp
  3366. // Description: Clean up the #define strings
  3367. // Parameters: .
  3368. // Returns: .
  3369. //=====================================================================
  3370. void CleanUp()
  3371. {
  3372. void *tPtr;
  3373. // free up the macros that were alloced
  3374. while (gLastMacro != NULL)
  3375. {
  3376. FreeMacroEntry(gLastMacro);
  3377. tPtr = gLastMacro;
  3378. gLastMacro = gLastMacro->prev;
  3379. SAFEFREE(tPtr);
  3380. }
  3381. }
  3382. //=====================================================================
  3383. // Function: FreeMacroEntry
  3384. // Description: Frees up the macro entry data, (parms, lines of text)
  3385. // Parameters: macEntry = pointer to the MACROENTRY structure
  3386. // Returns: .
  3387. //=====================================================================
  3388. void FreeMacroEntry(MACROENTRY *macEntry)
  3389. {
  3390. MACROTEXT *tText;
  3391. MACROTEXT *tNext;
  3392. SAFEFREE(macEntry->macroName);
  3393. SAFEFREE(macEntry->fileName);
  3394. // free the macro lines that were alloced
  3395. tText = macEntry->lastMacroLines;
  3396. while (tText != NULL)
  3397. {
  3398. tNext = tText->prev;
  3399. SAFEFREE(tText);
  3400. tText = tNext;
  3401. }
  3402. // free the text of the macro parms that were alloced
  3403. tText = macEntry->lastMacroParms;
  3404. while (tText != NULL)
  3405. {
  3406. tNext = tText->prev;
  3407. SAFEFREE(tText);
  3408. tText = tNext;
  3409. }
  3410. }
  3411. //=====================================================================
  3412. // Function: CheckMacroFunctions
  3413. // Description: Find if this text is a builtin macro function
  3414. // Parameters: lookString = non-null terminated string of possible
  3415. // and if found set global macro function call
  3416. // Returns: .
  3417. //=====================================================================
  3418. void CheckMacroFunctions(char *lookString, unsigned int *recognizedLen, char **invString)
  3419. {
  3420. unsigned int i;
  3421. unsigned int sLen;
  3422. for (i=0; i< NUM_MACRO_FUNCTIONS; i++)
  3423. {
  3424. sLen = strlen(gMacroFunctions[i].name);
  3425. if (!strncmp(gMacroFunctions[i].name, lookString, sLen))
  3426. {
  3427. gMacroCallFunction = gMacroFunctions[i].function;
  3428. *recognizedLen = sLen;
  3429. *invString = NULL;
  3430. return;
  3431. }
  3432. }
  3433. }
  3434. //=====================================================================
  3435. // Function: FindAlphaNum
  3436. // Description: Find a whole alpha numeric string, ie consists of
  3437. // [A-Za-z0-9_] only
  3438. // Parameters: srcStr = source string to search through.
  3439. // sLen = unsinged int pointer to length of string found
  3440. // Returns: pointer to found start of string.
  3441. // NULL if none.
  3442. //=====================================================================
  3443. char *FindAlphaNum(char *srcStr, unsigned int *sLen)
  3444. {
  3445. char curChar;
  3446. char *foundStr;
  3447. while (*srcStr != '\0')
  3448. {
  3449. curChar = toupper(*srcStr);
  3450. if ((curChar >= 'A') && (curChar <= 'Z'))
  3451. break;
  3452. if ((curChar >= '0') && (curChar <='9'))
  3453. break;
  3454. if (curChar == '_')
  3455. break;
  3456. srcStr++;
  3457. }
  3458. if (*srcStr == '\0')
  3459. {
  3460. return NULL;
  3461. }
  3462. foundStr = srcStr;
  3463. *sLen = 0;
  3464. // now search for end of string of [A-Za-z0-9_]
  3465. while (*srcStr != '\0')
  3466. {
  3467. curChar = toupper(*srcStr);
  3468. if ((curChar < 'A') || (curChar > 'Z'))
  3469. {
  3470. if ((curChar < '0') || (curChar > '9'))
  3471. {
  3472. if (curChar != '_')
  3473. break;
  3474. }
  3475. }
  3476. (*sLen)++;
  3477. srcStr++;
  3478. }
  3479. return foundStr;
  3480. }
  3481. //=====================================================================
  3482. // Function: FindDefineParm
  3483. // Description: Find if the MACROENTRY->macroText linked list contains
  3484. // replaceable parameters.
  3485. // Parameters: srcParms = pointer to MACROENTRY structure for source
  3486. // parameters
  3487. // invParms = MACROENTRY pointer to invocation parameters
  3488. // lookString = non-null terminated string of possible
  3489. // replaceable string
  3490. // recognizedLen = replacement string matched length
  3491. // invString = invocation string to replace with
  3492. // Returns: pointer to first character found in lookstring
  3493. //=====================================================================
  3494. char *FindDefineParm(MACROENTRY *srcParms, MACROENTRY *invParms,
  3495. char *lookString, unsigned int *recognizedLen, char **invString)
  3496. {
  3497. MACROTEXT *srcText;
  3498. MACROTEXT *invText;
  3499. char *checkStr;
  3500. unsigned int checkLen = 0;
  3501. unsigned int sLen;
  3502. checkStr = lookString;
  3503. *invString = NULL;
  3504. // first search for first [A-Za-z0-9_] only string
  3505. checkStr = FindAlphaNum(lookString, &checkLen);
  3506. while (checkStr != NULL)
  3507. {
  3508. // check all the #define parameters for match
  3509. srcText = srcParms->firstMacroParms;
  3510. invText = invParms->firstMacroParms;
  3511. while (srcText)
  3512. {
  3513. sLen = strlen(srcText->macroText);
  3514. // lengths should match
  3515. if (sLen == checkLen)
  3516. {
  3517. if (!strncmp(checkStr, srcText->macroText, checkLen))
  3518. {
  3519. // it matched so return replacement text
  3520. *invString = invText->macroText;
  3521. // and length that we reconized
  3522. *recognizedLen = checkLen;
  3523. return checkStr;
  3524. }
  3525. }
  3526. srcText = srcText->next;
  3527. invText = invText->next;
  3528. }
  3529. // not found yet, so go to next string.
  3530. checkStr = FindAlphaNum(checkStr+checkLen, &checkLen);
  3531. }
  3532. return NULL;
  3533. }
  3534. //=====================================================================
  3535. // Function: FindReplaceParm
  3536. // Description: Find if the MACROENTRY->macroText linked list contains
  3537. // a replaceable parameters.
  3538. // Parameters: srcParms = pointer to MACROENTRY structure for source
  3539. // parameters
  3540. // invParms = MACROENTRY pointer to invocation parameters
  3541. // lookString = non-null terminated string of possible
  3542. // replaceable string
  3543. // recognizedLen = replacement string matched length
  3544. // invString = invocation string to replace with
  3545. // Returns: .
  3546. //=====================================================================
  3547. void FindReplaceParm(MACROENTRY *srcParms, MACROENTRY *invParms,
  3548. char *lookString, unsigned int *recognizedLen, char **invString)
  3549. {
  3550. unsigned int sLen;
  3551. MACROTEXT *srcText;
  3552. MACROTEXT *invText;
  3553. *recognizedLen = 0;
  3554. *invString = NULL;
  3555. srcText = srcParms->firstMacroParms;
  3556. invText = invParms->firstMacroParms;
  3557. if (srcText != NULL)
  3558. {
  3559. // go until srcText # strings ends
  3560. while (srcText != NULL)
  3561. {
  3562. sLen = strlen(srcText->macroText);
  3563. if (!strncmp(srcText->macroText, lookString, sLen))
  3564. {
  3565. // found it so return src, replacement string
  3566. *recognizedLen = strlen(srcText->macroText);
  3567. *invString = invText->macroText;
  3568. // call function macro if it was invoked prior.
  3569. if (gMacroCallFunction != NULL)
  3570. {
  3571. gMacroCallFunction(lookString, recognizedLen, invString);
  3572. gMacroCallFunction = NULL;
  3573. }
  3574. return;
  3575. }
  3576. srcText = srcText->next;
  3577. invText = invText->next;
  3578. }
  3579. }
  3580. // ok, it wasn't found, look through builtin macro functions
  3581. CheckMacroFunctions(lookString, recognizedLen, invString);
  3582. }
  3583. //=====================================================================
  3584. // Function: ReplaceMacroParms
  3585. // Description: Replace macro parameters when macro was defined, with
  3586. // those specified on the macro invocation line
  3587. // Parameters: srcLine = source line to replace src macro parms with
  3588. // destLine = destination line save to.
  3589. // invocation macro parameters.
  3590. // parseMacro = currently parsing macro entry
  3591. // invParms = invocation macro entry
  3592. // Returns: .
  3593. //=====================================================================
  3594. void ReplaceMacroParms(char *srcLine, char *destLine,
  3595. MACROENTRY *srcParms, MACROENTRY *invParms)
  3596. {
  3597. char *findReplace;
  3598. char *invString;
  3599. unsigned int sLen;
  3600. unsigned int dLen;
  3601. unsigned int copyLen;
  3602. unsigned int subLen;
  3603. unsigned int recognizedLen;
  3604. destLine[0]= '\0';
  3605. sLen = strlen(srcLine);
  3606. dLen = 0;
  3607. while (sLen > 0)
  3608. {
  3609. // strtok might work better except it modifies the string, so
  3610. // kind of do my own....
  3611. if (!srcParms->bIsDefine)
  3612. {
  3613. findReplace = strchr(srcLine, '%');
  3614. if (findReplace != NULL)
  3615. {
  3616. // bypass % sign in findReplacement
  3617. findReplace++;
  3618. // figure out length of source before %
  3619. copyLen = (findReplace - srcLine)-1;
  3620. // check if there is a replacement string
  3621. FindReplaceParm(srcParms, invParms, findReplace, &recognizedLen, &invString);
  3622. }
  3623. else
  3624. {
  3625. strcat(destLine, srcLine);
  3626. return;
  3627. }
  3628. }
  3629. else
  3630. {
  3631. findReplace = FindDefineParm(srcParms, invParms, srcLine, &recognizedLen, &invString);
  3632. if (findReplace != NULL)
  3633. {
  3634. // figure out length of source before %
  3635. copyLen = findReplace - srcLine;
  3636. }
  3637. else
  3638. {
  3639. strcat(destLine, srcLine);
  3640. return;
  3641. }
  3642. }
  3643. if (invString != NULL)
  3644. {
  3645. // figure out how much we are going to substitute
  3646. subLen = strlen(invString);
  3647. }
  3648. else
  3649. {
  3650. subLen = 0;
  3651. }
  3652. if ((dLen + copyLen + subLen) > MAXSAVELINE)
  3653. {
  3654. LexError("Macro string overrun.\n");
  3655. CleanUp();
  3656. exit(ERROR_MACRO_OVERRUN);
  3657. }
  3658. if (copyLen > 0)
  3659. {
  3660. strncat(destLine, srcLine, copyLen);
  3661. dLen += copyLen;
  3662. }
  3663. srcLine += copyLen;
  3664. sLen -= copyLen;
  3665. // in macro so skip % part of variable
  3666. if (!srcParms->bIsDefine)
  3667. {
  3668. // skip %, also
  3669. srcLine++;
  3670. sLen--;
  3671. }
  3672. if (invString != NULL)
  3673. {
  3674. strcat(destLine, invString);
  3675. dLen += strlen(invString);
  3676. }
  3677. srcLine += recognizedLen;
  3678. sLen -= recognizedLen;
  3679. }
  3680. }
  3681. //=====================================================================
  3682. // Function: SaveMacroText
  3683. // Description: Adds a string to a linked list of MACROTEXT structures
  3684. // Parameters: srcText = pointer to source text to save
  3685. // lastMacroText = last allocated, or NULL
  3686. // Returns: newly allocated MACROTEXT structure, or NULL
  3687. //=====================================================================
  3688. MACROTEXT *SaveMacroText(char *srcText, MACROTEXT *lastMacroText)
  3689. {
  3690. MACROTEXT *curMacroText;
  3691. curMacroText = (MACROTEXT *)malloc(sizeof(MACROTEXT));
  3692. if (curMacroText == NULL)
  3693. {
  3694. return NULL;
  3695. }
  3696. else
  3697. {
  3698. // no next entry but set up previous with previously alloced macro parameter
  3699. curMacroText->next = NULL;
  3700. curMacroText->prev = lastMacroText;
  3701. // if the macroParm pointer is null then we are the first allocated
  3702. // so if not set the last one allocate next pointer to newly allocated structure
  3703. if (lastMacroText != NULL)
  3704. {
  3705. lastMacroText->next = curMacroText;
  3706. }
  3707. /* %%%%% this should be set up in memory pools. */
  3708. curMacroText->macroText = strdup(srcText);
  3709. if (curMacroText->macroText == NULL)
  3710. {
  3711. SAFEFREE(curMacroText);
  3712. return NULL;
  3713. }
  3714. }
  3715. return curMacroText;
  3716. }
  3717. //=====================================================================
  3718. // Function: ParseBuiltInMacroParms
  3719. // Description: parse parameters of string and fill in MACROENTRY
  3720. // structure.
  3721. // Parameters: parsedMacro = pointer to MACROENTRY structure that gets
  3722. // filled in with parameter pointers and count
  3723. // parmStr = string to parse parameters from
  3724. // Returns: false if error
  3725. //=====================================================================
  3726. bool ParseBuiltInMacroParms(MACROENTRY *parsedMacro, char *parmStr)
  3727. {
  3728. char *endStr;
  3729. char *foundParm;
  3730. MACROTEXT *prevMT;
  3731. MACROTEXT *curMT;
  3732. parsedMacro->numParms = 0;
  3733. parsedMacro->firstMacroParms = NULL;
  3734. foundParm = strdup(parmStr);
  3735. if (foundParm == NULL)
  3736. {
  3737. LexError("Out of memory parsing bultin macro parameters.\n");
  3738. return false;
  3739. }
  3740. // assume a ')' is on the end.
  3741. endStr = strrchr(foundParm, ')');
  3742. if (endStr == NULL)
  3743. {
  3744. LexWarning("Ending parenthesis not found for macro %s.\n", parsedMacro->macroName);
  3745. endStr = foundParm + strlen(foundParm);
  3746. }
  3747. prevMT = NULL;
  3748. // strip out and seperate parameters
  3749. while (foundParm < endStr)
  3750. {
  3751. // allocate a macro text structure
  3752. curMT = (MACROTEXT *)malloc(sizeof(MACROTEXT));
  3753. if (curMT == NULL)
  3754. {
  3755. free(parmStr);
  3756. LexError("Out of memory parsing bultin macro parameters.\n");
  3757. return false;
  3758. }
  3759. curMT->next = NULL;
  3760. curMT->prev = prevMT;
  3761. parsedMacro->numParms++;
  3762. if (prevMT != NULL)
  3763. {
  3764. prevMT->next = curMT;
  3765. }
  3766. else
  3767. {
  3768. parsedMacro->firstMacroParms = curMT;
  3769. }
  3770. curMT->macroText = foundParm;
  3771. // search for next parameters, delimited by comma
  3772. foundParm = strchr(foundParm, ',');
  3773. if (foundParm == NULL)
  3774. {
  3775. foundParm = endStr;
  3776. *foundParm = '\0';
  3777. }
  3778. else
  3779. {
  3780. // skip comma
  3781. *foundParm = '\0';
  3782. foundParm++;
  3783. }
  3784. prevMT = curMT;
  3785. }
  3786. return true;
  3787. }
  3788. //=====================================================================
  3789. // Function: MacroMathFunction
  3790. // Description: Comes here after macro replacement is done to perform
  3791. // some mathematic function on parameter (macro replacement
  3792. // string (ie, register))
  3793. // Parameters: invMacro = macroentry pointer containing macro information
  3794. // recognizedLen = # characters recoginized so far
  3795. // invStr = invoked replacement string so far
  3796. // mathStr = "-", "+", etc for mathematic function
  3797. // Returns: new recognizedLen, invStr, with incremented #
  3798. //=====================================================================
  3799. void MacroMathFunction(MACROENTRY *invMacro, unsigned int *recognizedLen, char **invStr,
  3800. const char *mathStr)
  3801. {
  3802. char *numStartStr;
  3803. unsigned int sLen;
  3804. char numberStr[256];
  3805. unsigned int number = 0;
  3806. char *operand;
  3807. // verify enough paramters to complete operation
  3808. if (invMacro->numParms != 2)
  3809. {
  3810. LexError("Two parameters are required for %s macro\n", invMacro->macroName);
  3811. return;
  3812. }
  3813. // get second macro parm, which is add by amount.
  3814. operand = invMacro->firstMacroParms->next->macroText;
  3815. // first find inner most bracket if any
  3816. numStartStr = strrchr(*invStr, ']');
  3817. if (numStartStr == NULL)
  3818. {
  3819. numStartStr = strrchr(*invStr, ')');
  3820. }
  3821. if (numStartStr != NULL)
  3822. {
  3823. if ((strlen(*invStr)+strlen(operand)+1) > MAXREPLACESTRING)
  3824. {
  3825. LexError("Out of Temporary string replacement memory inside builtin macro %s\n",
  3826. invMacro->macroName);
  3827. }
  3828. else
  3829. {
  3830. sLen = (numStartStr - *invStr);
  3831. gReplaceText[0] = '\0';
  3832. strncat(gReplaceText, *invStr, sLen);
  3833. strcat(gReplaceText, mathStr);
  3834. strcat(gReplaceText, operand);
  3835. strcat(gReplaceText, numStartStr);
  3836. *invStr = gReplaceText;
  3837. }
  3838. }
  3839. else
  3840. {
  3841. numStartStr = strpbrk(*invStr, "0123456789");
  3842. if (numStartStr != NULL)
  3843. {
  3844. // put up to number we found
  3845. sLen = numStartStr - *invStr;
  3846. if (sLen > MAXREPLACESTRING)
  3847. goto ErrOut;
  3848. gReplaceText[0] = '\0';
  3849. strncat(gReplaceText, *invStr, sLen);
  3850. switch (mathStr[0])
  3851. {
  3852. case '-':
  3853. number = atoi(numStartStr)-atoi(operand);
  3854. break;
  3855. case '+':
  3856. number = atoi(numStartStr)+atoi(operand);
  3857. break;
  3858. }
  3859. sprintf(numberStr, "%d", number);
  3860. if ((strlen(gReplaceText) + strlen(numberStr)) > MAXREPLACESTRING)
  3861. goto ErrOut;
  3862. strcat(gReplaceText, numberStr);
  3863. while ((*numStartStr != '\0') && (*numStartStr >= '0' && *numStartStr <= '9'))
  3864. numStartStr++;
  3865. if ((strlen(gReplaceText) + strlen(numStartStr)) > MAXREPLACESTRING)
  3866. goto ErrOut;
  3867. strcat(gReplaceText, numStartStr);
  3868. *invStr = gReplaceText;
  3869. }
  3870. else
  3871. {
  3872. if ((strlen(*invStr)+strlen(operand)+1) > MAXREPLACESTRING)
  3873. {
  3874. LexError("Out of Temporary string replacement memory inside builtin macro %s\n",
  3875. invMacro->macroName);
  3876. }
  3877. else
  3878. {
  3879. sprintf(gReplaceText, "%s%s%s", *invStr, mathStr, operand);
  3880. *invStr = gReplaceText;
  3881. }
  3882. }
  3883. }
  3884. return;
  3885. ErrOut:
  3886. LexError("Out of Temporary string replacement memory inside builtin macro %s\n",
  3887. invMacro->macroName);
  3888. // skip ')'
  3889. (*recognizedLen)++;
  3890. }
  3891. //=====================================================================
  3892. // Function: MacroIncFunction
  3893. // Description: Comes here after macro replacement is done to increment
  3894. // macro replacement string (ie, register)
  3895. // Parameters: lookStr = string after '(', so we can get parameters
  3896. // recognizedLen = # characters recoginized so far
  3897. // invStr = invoked replacement string so far
  3898. // Returns: new recognizedLen, invStr, with incremented #
  3899. //=====================================================================
  3900. void MacroIncFunction(char *lookStr, unsigned int *recognizedLen, char **invStr)
  3901. {
  3902. MACROENTRY tMEntry;
  3903. MACROTEXT parm1;
  3904. MACROTEXT parm2;
  3905. tMEntry.macroName = (char *)"%inc()";
  3906. tMEntry.numParms = 2;
  3907. tMEntry.firstMacroParms = &parm1;
  3908. parm1.prev = NULL;
  3909. parm1.next = &parm2;
  3910. parm1.macroText = *invStr;
  3911. parm2.prev = &parm1;
  3912. parm2.next = NULL;
  3913. parm2.macroText = (char *)"1";
  3914. MacroMathFunction(&tMEntry, recognizedLen, invStr, "+");
  3915. // skip ')'
  3916. (*recognizedLen)++;
  3917. }
  3918. //=====================================================================
  3919. // Function: MacroDecFunction
  3920. // Description: Comes here after macro replacement is done to decrement
  3921. // macro replacement string (ie, register)
  3922. // Parameters: lookStr = string after '(', so we can get parameters
  3923. // recognizedLen = # characters recoginized so far
  3924. // invStr = invoked replacement string so far
  3925. // Returns: new recognizedLen, invStr, with decremented #
  3926. //=====================================================================
  3927. void MacroDecFunction(char *lookStr, unsigned int *recognizedLen, char **invStr)
  3928. {
  3929. MACROENTRY tMEntry;
  3930. MACROTEXT parm1;
  3931. MACROTEXT parm2;
  3932. tMEntry.macroName = (char *)"%dec()";
  3933. tMEntry.numParms = 2;
  3934. tMEntry.firstMacroParms = &parm1;
  3935. parm1.prev = NULL;
  3936. parm1.next = &parm2;
  3937. parm1.macroText = *invStr;
  3938. parm2.prev = &parm1;
  3939. parm2.next = NULL;
  3940. parm2.macroText = (char *)"1";
  3941. MacroMathFunction(&tMEntry, recognizedLen, invStr, "-");
  3942. // skip ')'
  3943. (*recognizedLen)++;
  3944. }
  3945. //=====================================================================
  3946. // Function: MacroAddFunction
  3947. // Description: Comes here after macro replacement is done to add
  3948. // macro replacement string (ie, register)
  3949. // Parameters: lookStr = string after '(', so we can get parameters
  3950. // recognizedLen = # characters recoginized so far
  3951. // invStr = invoked replacement string so far
  3952. // Returns: new recognizedLen, invStr, with incremented #
  3953. //=====================================================================
  3954. void MacroAddFunction(char *lookStr, unsigned int *recognizedLen, char **invStr)
  3955. {
  3956. MACROENTRY tMEntry;
  3957. MACROTEXT *curMT;
  3958. MACROTEXT *nextMT;
  3959. unsigned int i;
  3960. tMEntry.macroName = (char *)"%add()";
  3961. if (strlen(lookStr) > MAXREPLACESTRING)
  3962. {
  3963. LexError("Out of Temporary string replacement memory inside builtin macro %add()\n");
  3964. return;
  3965. }
  3966. if (ParseBuiltInMacroParms(&tMEntry, lookStr))
  3967. {
  3968. MacroMathFunction(&tMEntry, recognizedLen, invStr, "+");
  3969. // skip ',' strlen(parm2)+ ')'
  3970. (*recognizedLen) += strlen(tMEntry.firstMacroParms->next->macroText)+2;
  3971. }
  3972. curMT = tMEntry.firstMacroParms;
  3973. // in this case only one string was allocated
  3974. free(curMT->macroText);
  3975. for (i=0; i<tMEntry.numParms; i++)
  3976. {
  3977. nextMT = curMT->next;
  3978. free(curMT);
  3979. curMT = nextMT;
  3980. }
  3981. }
  3982. //=====================================================================
  3983. // Function: MacroSubFunction
  3984. // Description: Comes here after macro replacement is done to subtract
  3985. // macro replacement string (ie, register)
  3986. // Parameters: invParms, parameters that macro was invoked with
  3987. // recognizedLen = # characters recoginized so far
  3988. // invStr = invoked replacement string so far
  3989. // Returns: new recognizedLen, invStr, with incremented #
  3990. //=====================================================================
  3991. void MacroSubFunction(char *lookStr, unsigned int *recognizedLen, char **invStr)
  3992. {
  3993. MACROENTRY tMEntry;
  3994. MACROTEXT *curMT;
  3995. MACROTEXT *nextMT;
  3996. unsigned int i;
  3997. tMEntry.macroName = (char *)"%sub()";
  3998. if (ParseBuiltInMacroParms(&tMEntry, lookStr))
  3999. {
  4000. MacroMathFunction(&tMEntry, recognizedLen, invStr, "-");
  4001. // skip ',' strlen(parm2)+ ')'
  4002. (*recognizedLen) += strlen(tMEntry.firstMacroParms->next->macroText)+2;
  4003. }
  4004. curMT = tMEntry.firstMacroParms;
  4005. // in this case only one string was allocated
  4006. free(curMT->macroText);
  4007. for (i=0; i<tMEntry.numParms; i++)
  4008. {
  4009. nextMT = curMT->next;
  4010. free(curMT);
  4011. curMT = nextMT;
  4012. }
  4013. }
  4014. //=====================================================================
  4015. // Function: EndMacroParms
  4016. // Description: Does update and cleanup one end of macro parameters
  4017. // is reached
  4018. // Parameters: .
  4019. // Returns: .
  4020. //=====================================================================
  4021. void EndMacroParms()
  4022. {
  4023. char *curFileName;
  4024. char *macroFileName;
  4025. char tempStr[1024];
  4026. char *macroText;
  4027. if (gbTempInsideMacro)
  4028. {
  4029. if (gTempParseMacro->numParms != gTempMacro->numParms)
  4030. {
  4031. LexError("Macro invocation number of parameters do not match macro definition, skipping\n");
  4032. BEGIN(INITIAL);
  4033. SAFEFREE(gTempMacro);
  4034. }
  4035. else
  4036. {
  4037. // we got all the parameters for the MACRO invocation, so start inside
  4038. // the macro now, by saving off current state on stack
  4039. gIncludeStack[gIncludeStackIndex].lineNo = yylineno;
  4040. gIncludeStack[gIncludeStackIndex].fileName = gCurFileName;
  4041. // gIncludeStack[gIncludeStackIndex].fileHandle = yyin;
  4042. //fprintf( stderr, "Chris fix this code with myin stuff\n" );
  4043. gIncludeStack[gIncludeStackIndex].prevString = myin;
  4044. gIncludeStack[gIncludeStackIndex].nextString = NULL;
  4045. gIncludeStack[gIncludeStackIndex].lastInvokeMacro = gInvokeMacro;
  4046. gIncludeStack[gIncludeStackIndex].lastParseMacro = gParseMacro;
  4047. gIncludeStack[gIncludeStackIndex].lastMacroLineParse = gMacroLineParse;
  4048. gIncludeStack[gIncludeStackIndex].lastbInsideMacro = gbInsideMacro;
  4049. gIncludeStack[gIncludeStackIndex].lastbInsideInclude = gbInsideInclude;
  4050. gIncludeStack[gIncludeStackIndex].buffer = YY_CURRENT_BUFFER;
  4051. gIncludeStack[gIncludeStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
  4052. gIncludeStackIndex++;
  4053. gParseMacro = gTempParseMacro;
  4054. gInvokeMacro = gTempMacro;
  4055. gbInsideMacro = gbTempInsideMacro;
  4056. gbTempInsideMacro = false;
  4057. // yyin = NULL;
  4058. myin = NULL;
  4059. curFileName = gCurFileName;
  4060. if (curFileName == NULL)
  4061. curFileName = (char *)"";
  4062. macroFileName = gParseMacro->fileName;
  4063. if (macroFileName == NULL)
  4064. macroFileName = (char *)"";
  4065. sprintf(tempStr, "%s(%d) : References ->\n%s", curFileName, yylineno, macroFileName);
  4066. gCurFileName = strdup(tempStr);
  4067. gMacroLineParse = gParseMacro->firstMacroLines;
  4068. macroText = gMacroLine;
  4069. // if no replacement text, just use source line
  4070. if (gParseMacro->firstMacroParms == NULL)
  4071. {
  4072. macroText = gMacroLineParse->macroText;
  4073. }
  4074. else
  4075. {
  4076. // replace the macro parameters
  4077. ReplaceMacroParms(gMacroLineParse->macroText, gMacroLine, gParseMacro, gInvokeMacro);
  4078. }
  4079. yylineno = gParseMacro->lineNo;
  4080. if (gParseMacro->nLines >= 1)
  4081. {
  4082. strcpy(gSaveLine, macroText);
  4083. }
  4084. // if (gExpandMacros && (gParseMacro->nLines >= 1))
  4085. // {
  4086. // // in case there is anything there dump it out
  4087. // GenDebugLine();
  4088. // GenListString();
  4089. // if (gInvokeMacro->nLines >= 1)
  4090. // GenSwitchFileNames(macroFileName);
  4091. // }
  4092. BEGIN(gInvokeState);
  4093. yy_scan_string(macroText);
  4094. gInvokeState = INITIAL;
  4095. }
  4096. }
  4097. else
  4098. {
  4099. if (gLastMacro != NULL)
  4100. {
  4101. gLastMacro->next = gTempMacro;
  4102. }
  4103. gLastMacro = gTempMacro;
  4104. BEGIN(MACROBODY);
  4105. }
  4106. }
  4107. //=====================================================================
  4108. // Function: FindSwizzleValue
  4109. // Description: see if valid swizzle value and return the bits
  4110. // Parameters: swizzleTex = pointer to characters to analyze
  4111. // Returns: unsigned int = bits for swizzle values, or 0 for error
  4112. //=====================================================================
  4113. unsigned int FindSwizzleValue(char *swizzleText)
  4114. {
  4115. unsigned int swizzleBits;
  4116. unsigned int sLen;
  4117. unsigned int i;
  4118. unsigned int lastMask;
  4119. sLen = strlen(swizzleText);
  4120. swizzleBits = 0;
  4121. lastMask = 0;
  4122. for (i=0; i<sLen; i++)
  4123. {
  4124. switch (swizzleText[i])
  4125. {
  4126. case 'x':
  4127. swizzleBits |= (WRITEMASK_X << (4*(3-i)));
  4128. lastMask = WRITEMASK_X;
  4129. break;
  4130. case 'y':
  4131. swizzleBits |= (WRITEMASK_Y << (4*(3-i)));
  4132. lastMask = WRITEMASK_Y;
  4133. break;
  4134. case 'z':
  4135. swizzleBits |= (WRITEMASK_Z << (4*(3-i)));
  4136. lastMask = WRITEMASK_Z;
  4137. break;
  4138. case 'w':
  4139. swizzleBits |= (WRITEMASK_W << (4*(3-i)));
  4140. lastMask = WRITEMASK_W;
  4141. break;
  4142. }
  4143. }
  4144. for (; i<4; i++)
  4145. {
  4146. swizzleBits |= (lastMask << (4*(3-i)));
  4147. }
  4148. return swizzleBits;
  4149. }
  4150. #if 0
  4151. unsigned int FindSwizzleValue(char *swizzleText)
  4152. {
  4153. DWORD swizzleBits;
  4154. DWORD sLen;
  4155. DWORD i;
  4156. DWORD lastIndex;
  4157. sLen = strlen(swizzleText);
  4158. swizzleBits = 0;
  4159. lastIndex = 0;
  4160. for (i=0; i<sLen; i++)
  4161. {
  4162. switch (swizzleText[i])
  4163. {
  4164. case 'x':
  4165. swizzleBits |= (0 << (D3DVS_SWIZZLE_SHIFT + (i * 2)));
  4166. lastIndex = 0;
  4167. break;
  4168. case 'y':
  4169. swizzleBits |= (1 << (D3DVS_SWIZZLE_SHIFT + (i * 2)));
  4170. lastIndex = 1;
  4171. break;
  4172. case 'z':
  4173. swizzleBits |= (2 << (D3DVS_SWIZZLE_SHIFT + (i * 2)));
  4174. lastIndex = 2;
  4175. break;
  4176. case 'w':
  4177. swizzleBits |= (3 << (D3DVS_SWIZZLE_SHIFT + (i * 2)));
  4178. lastIndex = 3;
  4179. break;
  4180. }
  4181. }
  4182. for (; i<4; i++)
  4183. {
  4184. swizzleBits |= (lastIndex << (D3DVS_SWIZZLE_SHIFT + (i * 2)));
  4185. }
  4186. return swizzleBits;
  4187. }
  4188. #endif
  4189. //=====================================================================
  4190. // Function: FindRegisterMask
  4191. // Description: Look through register mask strings
  4192. // Parameters: findName = name to lookup
  4193. // Returns: unsigned int with token value
  4194. //=====================================================================
  4195. unsigned int MakeRegisterMask(char *findName)
  4196. {
  4197. unsigned int regMask;
  4198. char *findFirst;
  4199. regMask = 0;
  4200. findFirst = strchr(findName, 'x');
  4201. if (findFirst != NULL)
  4202. {
  4203. if (strchr(findFirst+1, 'x') != NULL)
  4204. {
  4205. return 0;
  4206. }
  4207. regMask |= WRITEMASK_X;
  4208. }
  4209. findFirst = strchr(findName, 'y');
  4210. if (findFirst != NULL)
  4211. {
  4212. regMask |= WRITEMASK_Y;
  4213. // invalide write mask, must be swizzle
  4214. if (strchr(findFirst+1, 'x') != NULL)
  4215. {
  4216. return 0;
  4217. }
  4218. if (strchr(findFirst+1, 'y') != NULL)
  4219. {
  4220. return 0;
  4221. }
  4222. }
  4223. findFirst = strchr(findName, 'z');
  4224. if (findFirst != NULL)
  4225. {
  4226. regMask |= WRITEMASK_Z;
  4227. if (strchr(findFirst+1, 'x') != NULL)
  4228. {
  4229. return 0;
  4230. }
  4231. if (strchr(findFirst+1, 'y') != NULL)
  4232. {
  4233. return 0;
  4234. }
  4235. if (strchr(findFirst+1, 'z') != NULL)
  4236. {
  4237. return 0;
  4238. }
  4239. }
  4240. findFirst = strchr(findName, 'w');
  4241. if (findFirst != NULL)
  4242. {
  4243. regMask |= WRITEMASK_W;
  4244. if (strchr(findFirst+1, 'x') != NULL)
  4245. {
  4246. return 0;
  4247. }
  4248. if (strchr(findFirst+1, 'y') != NULL)
  4249. {
  4250. return 0;
  4251. }
  4252. if (strchr(findFirst+1, 'z') != NULL)
  4253. {
  4254. return 0;
  4255. }
  4256. if (strchr(findFirst+1, 'w') != NULL)
  4257. {
  4258. return 0;
  4259. }
  4260. }
  4261. return regMask;
  4262. }
  4263. //=====================================================================
  4264. // Function: LexError
  4265. // Description: output an error to the stdout
  4266. // Parameters: typical printf like format
  4267. // Returns: .
  4268. //=====================================================================
  4269. void LexError(const char *format, ...)
  4270. {
  4271. char errstring[4096];
  4272. va_list marker;
  4273. // fprintf( stderr,"(%d) : Error : ", yylineno);
  4274. if ( gbInsideInclude )
  4275. {
  4276. sprintf( errstring, "%s", gCurFileName );
  4277. sprintf( errstring+strlen(errstring),"(%d) : Error : ", yylineno);
  4278. }
  4279. else
  4280. {
  4281. sprintf( errstring,"(%d) : Error : ", yylineno);
  4282. }
  4283. va_start(marker, format);
  4284. // vprintf(format, marker);
  4285. vsprintf(errstring+strlen(errstring), format, marker);
  4286. va_end(marker);
  4287. errors.set( errstring );
  4288. }
  4289. //=====================================================================
  4290. // Function: LexWarning
  4291. // Description: output a warning to the stdout
  4292. // Parameters: typical printf like format
  4293. // Returns: .
  4294. //=====================================================================
  4295. void LexWarning(const char *format, ...)
  4296. {
  4297. char errstring[4096];
  4298. va_list marker;
  4299. // fprintf( stderr,"(%d) : warning : ", yylineno);
  4300. if ( gbInsideInclude )
  4301. sprintf( errstring, "%s", gCurFileName );
  4302. sprintf( errstring+strlen(errstring),"(%d) : Warning : ", yylineno);
  4303. // sprintf( errstring,"(%d) : Warning : ", yylineno);
  4304. va_start(marker, format);
  4305. // vprintf(format, marker);
  4306. vsprintf(errstring+strlen(errstring), format, marker);
  4307. va_end(marker);
  4308. errors.set( errstring );
  4309. }
  4310. //=====================================================================
  4311. // Function: DebugUnhandledState
  4312. // Description: Come here in debug mode, when a state isn't handled
  4313. // for the Lexer
  4314. // Parameters: .
  4315. // Returns: .
  4316. //=====================================================================
  4317. void DebugUnhandledState()
  4318. {
  4319. fprintf( stderr,"Unhandled state reached, with %s text.\n", yytext);
  4320. }
  4321. //=====================================================================
  4322. // Function: FindOpcode
  4323. // Description: Look through opcodes and see if in the table
  4324. // Parameters: findName = name to lookup
  4325. // Returns: OPCODEMAP * = pointer to opcode map entry, if found
  4326. //=====================================================================
  4327. OPCODEMAP *FindOpcode(char *findName)
  4328. {
  4329. unsigned i;
  4330. // just do linear search for now
  4331. for (i=0; i<NUMOPCODES; i++)
  4332. {
  4333. if (!stricmp(theOpcodes[i].string, findName))
  4334. {
  4335. return &theOpcodes[i];
  4336. }
  4337. }
  4338. return NULL;
  4339. }
  4340. char *ReadTextFile(const char * filename)
  4341. {
  4342. char path[3][32] = { ".\0",
  4343. "../../data/programs\0",
  4344. "../../../data/programs\0" };
  4345. char name[8192];
  4346. int i;
  4347. if (!filename) return 0;
  4348. struct _stat status;
  4349. int found = 0;
  4350. for ( i = 0; i < 3; i++ )
  4351. {
  4352. sprintf( name, "%s/%s", path[i], filename );
  4353. int fh = ::_open(name, _O_RDONLY);
  4354. if(fh != -1)
  4355. {
  4356. int result = _fstat( fh, &status );
  4357. if( result != 0 )
  4358. {
  4359. fprintf( stderr, "An fstat error occurred.\n" );
  4360. break;
  4361. }
  4362. ::_close( fh );
  4363. found = i+1;
  4364. break;
  4365. }
  4366. }
  4367. if ( 0 == found )
  4368. {
  4369. fprintf(stderr,"Cannot open \"%s\" for stat read!\n", filename);
  4370. return NULL;
  4371. }
  4372. long size = status.st_size;
  4373. char * buf = new char[size+1];
  4374. FILE *fp = 0;
  4375. if (!(fp = fopen(name, "r")))
  4376. {
  4377. fprintf(stderr,"Cannot open \"%s\" for read!\n", name);
  4378. return NULL;
  4379. }
  4380. int bytes;
  4381. bytes = fread(buf, 1, size, fp);
  4382. buf[bytes] = 0;
  4383. fclose(fp);
  4384. return buf;
  4385. }
  4386. bool vs10_init_more();
  4387. bool vs10_init(char* inputString)
  4388. {
  4389. BEGIN(SAVELINE);
  4390. myin = inputString;
  4391. line_incr = 0;
  4392. return vs10_init_more();
  4393. }
  4394. #ifndef vs10_wrap
  4395. int vs10_wrap(void)
  4396. {
  4397. return(1);
  4398. }
  4399. #endif