ast_expr2.c 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520
  1. /* A Bison parser, made by GNU Bison 2.3. */
  2. /* Skeleton implementation for Bison's Yacc-like parsers in C
  3. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
  4. Free Software Foundation, Inc.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. /* As a special exception, you may create a larger work that contains
  18. part or all of the Bison parser skeleton and distribute that work
  19. under terms of your choice, so long as that work isn't itself a
  20. parser generator using the skeleton or a modified version thereof
  21. as a parser skeleton. Alternatively, if you modify or redistribute
  22. the parser skeleton itself, you may (at your option) remove this
  23. special exception, which will cause the skeleton and the resulting
  24. Bison output files to be licensed under the GNU General Public
  25. License without this special exception.
  26. This special exception was added by the Free Software Foundation in
  27. version 2.2 of Bison. */
  28. /* C LALR(1) parser skeleton written by Richard Stallman, by
  29. simplifying the original so-called "semantic" parser. */
  30. /* All symbols defined below should begin with yy or YY, to avoid
  31. infringing on user name space. This should be done even for local
  32. variables, as they might otherwise be expanded by user macros.
  33. There are some unavoidable exceptions within include files to
  34. define necessary library symbols; they are noted "INFRINGES ON
  35. USER NAME SPACE" below. */
  36. /* Identify Bison output. */
  37. #define YYBISON 1
  38. /* Bison version. */
  39. #define YYBISON_VERSION "2.3"
  40. /* Skeleton name. */
  41. #define YYSKELETON_NAME "yacc.c"
  42. /* Pure parsers. */
  43. #define YYPURE 1
  44. /* Using locations. */
  45. #define YYLSP_NEEDED 1
  46. /* Substitute the variable and function names. */
  47. #define yyparse ast_yyparse
  48. #define yylex ast_yylex
  49. #define yyerror ast_yyerror
  50. #define yylval ast_yylval
  51. #define yychar ast_yychar
  52. #define yydebug ast_yydebug
  53. #define yynerrs ast_yynerrs
  54. #define yylloc ast_yylloc
  55. /* Tokens. */
  56. #ifndef YYTOKENTYPE
  57. # define YYTOKENTYPE
  58. /* Put the tokens into the symbol table, so that GDB and other debuggers
  59. know about them. */
  60. enum yytokentype {
  61. TOK_COMMA = 258,
  62. TOK_COLONCOLON = 259,
  63. TOK_COND = 260,
  64. TOK_OR = 261,
  65. TOK_AND = 262,
  66. TOK_NE = 263,
  67. TOK_LE = 264,
  68. TOK_GE = 265,
  69. TOK_LT = 266,
  70. TOK_GT = 267,
  71. TOK_EQ = 268,
  72. TOK_MINUS = 269,
  73. TOK_PLUS = 270,
  74. TOK_MOD = 271,
  75. TOK_DIV = 272,
  76. TOK_MULT = 273,
  77. TOK_COMPL = 274,
  78. TOK_TILDETILDE = 275,
  79. TOK_EQTILDE = 276,
  80. TOK_COLON = 277,
  81. TOK_LP = 278,
  82. TOK_RP = 279,
  83. TOKEN = 280
  84. };
  85. #endif
  86. /* Tokens. */
  87. #define TOK_COMMA 258
  88. #define TOK_COLONCOLON 259
  89. #define TOK_COND 260
  90. #define TOK_OR 261
  91. #define TOK_AND 262
  92. #define TOK_NE 263
  93. #define TOK_LE 264
  94. #define TOK_GE 265
  95. #define TOK_LT 266
  96. #define TOK_GT 267
  97. #define TOK_EQ 268
  98. #define TOK_MINUS 269
  99. #define TOK_PLUS 270
  100. #define TOK_MOD 271
  101. #define TOK_DIV 272
  102. #define TOK_MULT 273
  103. #define TOK_COMPL 274
  104. #define TOK_TILDETILDE 275
  105. #define TOK_EQTILDE 276
  106. #define TOK_COLON 277
  107. #define TOK_LP 278
  108. #define TOK_RP 279
  109. #define TOKEN 280
  110. /* Copy the first part of user declarations. */
  111. #line 1 "ast_expr2.y"
  112. /* Written by Pace Willisson (pace@blitz.com)
  113. * and placed in the public domain.
  114. *
  115. * Largely rewritten by J.T. Conklin (jtc@wimsey.com)
  116. *
  117. * And then overhauled twice by Steve Murphy (murf@digium.com)
  118. * to add double-quoted strings, allow mult. spaces, improve
  119. * error messages, and then to fold in a flex scanner for the
  120. * yylex operation.
  121. *
  122. * $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $
  123. */
  124. #include "asterisk.h"
  125. #include <sys/types.h>
  126. #include <stdio.h>
  127. #if !defined(STANDALONE) && !defined(STANDALONE2) \
  128. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  129. #else
  130. #ifndef __USE_ISOC99
  131. #define __USE_ISOC99 1
  132. #endif
  133. #endif
  134. #ifdef __USE_ISOC99
  135. #define FP___PRINTF "%.18Lg"
  136. #define FP___TYPE long double
  137. #else
  138. #define FP___PRINTF "%.16g"
  139. #define FP___TYPE double
  140. #endif
  141. #ifdef HAVE_COSL
  142. #define FUNC_COS cosl
  143. #elif defined(HAVE_COS)
  144. #define FUNC_COS (long double)cos
  145. #endif
  146. #ifdef HAVE_SINL
  147. #define FUNC_SIN sinl
  148. #elif defined(HAVE_SIN)
  149. #define FUNC_SIN (long double)sin
  150. #endif
  151. #ifdef HAVE_TANL
  152. #define FUNC_TAN tanl
  153. #elif defined(HAVE_TAN)
  154. #define FUNC_TAN (long double)tan
  155. #endif
  156. #ifdef HAVE_ACOSL
  157. #define FUNC_ACOS acosl
  158. #elif defined(HAVE_ACOS)
  159. #define FUNC_ACOS (long double)acos
  160. #endif
  161. #ifdef HAVE_ASINL
  162. #define FUNC_ASIN asinl
  163. #elif defined(HAVE_ASIN)
  164. #define FUNC_ASIN (long double)asin
  165. #endif
  166. #ifdef HAVE_ATANL
  167. #define FUNC_ATAN atanl
  168. #elif defined(HAVE_ATAN)
  169. #define FUNC_ATAN (long double)atan
  170. #endif
  171. #ifdef HAVE_ATAN2L
  172. #define FUNC_ATAN2 atan2l
  173. #elif defined(HAVE_ATAN2)
  174. #define FUNC_ATAN2 (long double)atan2
  175. #endif
  176. #ifdef HAVE_POWL
  177. #define FUNC_POW powl
  178. #elif defined(HAVE_POW)
  179. #define FUNC_POW (long double)pow
  180. #endif
  181. #ifdef HAVE_SQRTL
  182. #define FUNC_SQRT sqrtl
  183. #elif defined(HAVE_SQRT)
  184. #define FUNC_SQRT (long double)sqrt
  185. #endif
  186. #ifdef HAVE_RINTL
  187. #define FUNC_RINT rintl
  188. #elif defined(HAVE_RINT)
  189. #define FUNC_RINT (long double)rint
  190. #endif
  191. #ifdef HAVE_EXPL
  192. #define FUNC_EXP expl
  193. #elif defined(HAVE_EXP)
  194. #define FUNC_EXP (long double)exp
  195. #endif
  196. #ifdef HAVE_LOGL
  197. #define FUNC_LOG logl
  198. #elif defined(HAVE_LOG)
  199. #define FUNC_LOG (long double)log
  200. #endif
  201. #ifdef HAVE_REMAINDERL
  202. #define FUNC_REMAINDER remainderl
  203. #elif defined(HAVE_REMAINDER)
  204. #define FUNC_REMAINDER (long double)remainder
  205. #endif
  206. #ifdef HAVE_FMODL
  207. #define FUNC_FMOD fmodl
  208. #elif defined(HAVE_FMOD)
  209. #define FUNC_FMOD (long double)fmod
  210. #endif
  211. #ifdef HAVE_STRTOLD
  212. #define FUNC_STRTOD strtold
  213. #elif defined(HAVE_STRTOD)
  214. #define FUNC_STRTOD (long double)strtod
  215. #endif
  216. #ifdef HAVE_FLOORL
  217. #define FUNC_FLOOR floorl
  218. #elif defined(HAVE_FLOOR)
  219. #define FUNC_FLOOR (long double)floor
  220. #endif
  221. #ifdef HAVE_CEILL
  222. #define FUNC_CEIL ceill
  223. #elif defined(HAVE_CEIL)
  224. #define FUNC_CEIL (long double)ceil
  225. #endif
  226. #ifdef HAVE_ROUNDL
  227. #define FUNC_ROUND roundl
  228. #elif defined(HAVE_ROUND)
  229. #define FUNC_ROUND (long double)round
  230. #endif
  231. #ifdef HAVE_TRUNCL
  232. #define FUNC_TRUNC truncl
  233. #elif defined(HAVE_TRUNC)
  234. #define FUNC_TRUNC (long double)trunc
  235. #endif
  236. /*! \note
  237. * Oddly enough, some platforms have some ISO C99 functions, but not others, so
  238. * we define the missing functions in terms of their mathematical identities.
  239. */
  240. #ifdef HAVE_EXP2L
  241. #define FUNC_EXP2 exp2l
  242. #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
  243. #define FUNC_EXP2(x) expl((x) * logl(2.0))
  244. #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
  245. #define FUNC_EXP2(x) (long double)exp((x) * log(2.0))
  246. #endif
  247. #ifdef HAVE_EXP10L
  248. #define FUNC_EXP10 exp10l
  249. #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
  250. #define FUNC_EXP10(x) expl((x) * logl(10.0))
  251. #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
  252. #define FUNC_EXP10(x) (long double)exp((x) * log(10.0))
  253. #endif
  254. #ifdef HAVE_LOG2L
  255. #define FUNC_LOG2 log2l
  256. #elif defined(HAVE_LOGL)
  257. #define FUNC_LOG2(x) (logl(x) / logl(2.0))
  258. #elif defined(HAVE_LOG10L)
  259. #define FUNC_LOG2(x) (log10l(x) / log10l(2.0))
  260. #elif defined(HAVE_LOG2)
  261. #define FUNC_LOG2 (long double)log2
  262. #elif defined(HAVE_LOG)
  263. #define FUNC_LOG2(x) ((long double)log(x) / log(2.0))
  264. #endif
  265. #ifdef HAVE_LOG10L
  266. #define FUNC_LOG10 log10l
  267. #elif defined(HAVE_LOGL)
  268. #define FUNC_LOG10(x) (logl(x) / logl(10.0))
  269. #elif defined(HAVE_LOG2L)
  270. #define FUNC_LOG10(x) (log2l(x) / log2l(10.0))
  271. #elif defined(HAVE_LOG10)
  272. #define FUNC_LOG10(x) (long double)log10(x)
  273. #elif defined(HAVE_LOG)
  274. #define FUNC_LOG10(x) ((long double)log(x) / log(10.0))
  275. #endif
  276. #include <stdlib.h>
  277. #ifndef _GNU_SOURCE
  278. #define _GNU_SOURCE
  279. #endif
  280. #include <string.h>
  281. #include <math.h>
  282. #include <locale.h>
  283. #include <unistd.h>
  284. #include <ctype.h>
  285. #if !defined(SOLARIS) && !defined(__CYGWIN__)
  286. /* #include <err.h> */
  287. #else
  288. #define quad_t int64_t
  289. #endif
  290. #include <errno.h>
  291. #include <regex.h>
  292. #include <limits.h>
  293. #include "asterisk/ast_expr.h"
  294. #include "asterisk/logger.h"
  295. #if !defined(STANDALONE) && !defined(STANDALONE2)
  296. #include "asterisk/pbx.h"
  297. #endif
  298. #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN)
  299. #define QUAD_MIN LONG_LONG_MIN
  300. #endif
  301. #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX)
  302. #define QUAD_MAX LONG_LONG_MAX
  303. #endif
  304. # if ! defined(QUAD_MIN)
  305. # define QUAD_MIN (-0x7fffffffffffffffLL-1)
  306. # endif
  307. # if ! defined(QUAD_MAX)
  308. # define QUAD_MAX (0x7fffffffffffffffLL)
  309. # endif
  310. #define YYENABLE_NLS 0
  311. #define YYPARSE_PARAM parseio
  312. #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner
  313. #define YYERROR_VERBOSE 1
  314. extern char extra_error_message[4095];
  315. extern int extra_error_message_supplied;
  316. enum valtype {
  317. AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
  318. } ;
  319. #if defined(STANDALONE) || defined(STANDALONE2)
  320. void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
  321. #endif
  322. struct val {
  323. enum valtype type;
  324. union {
  325. char *s;
  326. FP___TYPE i; /* either long double, or just double, on a bad day */
  327. } u;
  328. } ;
  329. enum node_type {
  330. AST_EXPR_NODE_COMMA, AST_EXPR_NODE_STRING, AST_EXPR_NODE_VAL
  331. } ;
  332. struct expr_node
  333. {
  334. enum node_type type;
  335. struct val *val;
  336. struct expr_node *left;
  337. struct expr_node *right;
  338. };
  339. typedef void *yyscan_t;
  340. struct parse_io
  341. {
  342. char *string;
  343. struct val *val;
  344. yyscan_t scanner;
  345. struct ast_channel *chan;
  346. };
  347. static int chk_div __P((FP___TYPE, FP___TYPE));
  348. static int chk_minus __P((FP___TYPE, FP___TYPE, FP___TYPE));
  349. static int chk_plus __P((FP___TYPE, FP___TYPE, FP___TYPE));
  350. static int chk_times __P((FP___TYPE, FP___TYPE, FP___TYPE));
  351. static void free_value __P((struct val *));
  352. static int is_zero_or_null __P((struct val *));
  353. static int isstring __P((struct val *));
  354. static struct val *make_number __P((FP___TYPE));
  355. static struct val *make_str __P((const char *));
  356. static struct val *op_and __P((struct val *, struct val *));
  357. static struct val *op_colon __P((struct val *, struct val *));
  358. static struct val *op_eqtilde __P((struct val *, struct val *));
  359. static struct val *op_tildetilde __P((struct val *, struct val *));
  360. static struct val *op_div __P((struct val *, struct val *));
  361. static struct val *op_eq __P((struct val *, struct val *));
  362. static struct val *op_ge __P((struct val *, struct val *));
  363. static struct val *op_gt __P((struct val *, struct val *));
  364. static struct val *op_le __P((struct val *, struct val *));
  365. static struct val *op_lt __P((struct val *, struct val *));
  366. static struct val *op_cond __P((struct val *, struct val *, struct val *));
  367. static struct val *op_minus __P((struct val *, struct val *));
  368. static struct val *op_negate __P((struct val *));
  369. static struct val *op_compl __P((struct val *));
  370. static struct val *op_ne __P((struct val *, struct val *));
  371. static struct val *op_or __P((struct val *, struct val *));
  372. static struct val *op_plus __P((struct val *, struct val *));
  373. static struct val *op_rem __P((struct val *, struct val *));
  374. static struct val *op_times __P((struct val *, struct val *));
  375. static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan);
  376. static int to_number __P((struct val *));
  377. static void to_string __P((struct val *));
  378. static struct expr_node *alloc_expr_node(enum node_type);
  379. static void destroy_arglist(struct expr_node *arglist);
  380. /* uh, if I want to predeclare yylex with a YYLTYPE, I have to predeclare the yyltype... sigh */
  381. typedef struct yyltype
  382. {
  383. int first_line;
  384. int first_column;
  385. int last_line;
  386. int last_column;
  387. } yyltype;
  388. # define YYLTYPE yyltype
  389. # define YYLTYPE_IS_TRIVIAL 1
  390. /* we will get warning about no prototype for yylex! But we can't
  391. define it here, we have no definition yet for YYSTYPE. */
  392. int ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
  393. /* I wanted to add args to the yyerror routine, so I could print out
  394. some useful info about the error. Not as easy as it looks, but it
  395. is possible. */
  396. #define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
  397. #define DESTROY(x) {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);}
  398. /* Enabling traces. */
  399. #ifndef YYDEBUG
  400. # define YYDEBUG 0
  401. #endif
  402. /* Enabling verbose error messages. */
  403. #ifdef YYERROR_VERBOSE
  404. # undef YYERROR_VERBOSE
  405. # define YYERROR_VERBOSE 1
  406. #else
  407. # define YYERROR_VERBOSE 0
  408. #endif
  409. /* Enabling the token table. */
  410. #ifndef YYTOKEN_TABLE
  411. # define YYTOKEN_TABLE 0
  412. #endif
  413. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  414. typedef union YYSTYPE
  415. #line 345 "ast_expr2.y"
  416. {
  417. struct val *val;
  418. struct expr_node *arglist;
  419. }
  420. /* Line 187 of yacc.c. */
  421. #line 496 "ast_expr2.c"
  422. YYSTYPE;
  423. # define yystype YYSTYPE /* obsolescent; will be withdrawn */
  424. # define YYSTYPE_IS_DECLARED 1
  425. # define YYSTYPE_IS_TRIVIAL 1
  426. #endif
  427. #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
  428. typedef struct YYLTYPE
  429. {
  430. int first_line;
  431. int first_column;
  432. int last_line;
  433. int last_column;
  434. } YYLTYPE;
  435. # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
  436. # define YYLTYPE_IS_DECLARED 1
  437. # define YYLTYPE_IS_TRIVIAL 1
  438. #endif
  439. /* Copy the second part of user declarations. */
  440. #line 350 "ast_expr2.y"
  441. extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
  442. /* Line 216 of yacc.c. */
  443. #line 524 "ast_expr2.c"
  444. #ifdef short
  445. # undef short
  446. #endif
  447. #ifdef YYTYPE_UINT8
  448. typedef YYTYPE_UINT8 yytype_uint8;
  449. #else
  450. typedef unsigned char yytype_uint8;
  451. #endif
  452. #ifdef YYTYPE_INT8
  453. typedef YYTYPE_INT8 yytype_int8;
  454. #elif (defined __STDC__ || defined __C99__FUNC__ \
  455. || defined __cplusplus || defined _MSC_VER)
  456. typedef signed char yytype_int8;
  457. #else
  458. typedef short int yytype_int8;
  459. #endif
  460. #ifdef YYTYPE_UINT16
  461. typedef YYTYPE_UINT16 yytype_uint16;
  462. #else
  463. typedef unsigned short int yytype_uint16;
  464. #endif
  465. #ifdef YYTYPE_INT16
  466. typedef YYTYPE_INT16 yytype_int16;
  467. #else
  468. typedef short int yytype_int16;
  469. #endif
  470. #ifndef YYSIZE_T
  471. # ifdef __SIZE_TYPE__
  472. # define YYSIZE_T __SIZE_TYPE__
  473. # elif defined size_t
  474. # define YYSIZE_T size_t
  475. # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
  476. || defined __cplusplus || defined _MSC_VER)
  477. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  478. # define YYSIZE_T size_t
  479. # else
  480. # define YYSIZE_T unsigned int
  481. # endif
  482. #endif
  483. #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
  484. #ifndef YY_
  485. # if YYENABLE_NLS
  486. # if ENABLE_NLS
  487. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  488. # define YY_(msgid) dgettext ("bison-runtime", msgid)
  489. # endif
  490. # endif
  491. # ifndef YY_
  492. # define YY_(msgid) msgid
  493. # endif
  494. #endif
  495. /* Suppress unused-variable warnings by "using" E. */
  496. #if ! defined lint || defined __GNUC__
  497. # define YYUSE(e) ((void) (e))
  498. #else
  499. # define YYUSE(e) /* empty */
  500. #endif
  501. /* Identity function, used to suppress warnings about constant conditions. */
  502. #ifndef lint
  503. # define YYID(n) (n)
  504. #else
  505. #if (defined __STDC__ || defined __C99__FUNC__ \
  506. || defined __cplusplus || defined _MSC_VER)
  507. static int
  508. YYID (int i)
  509. #else
  510. static int
  511. YYID (i)
  512. int i;
  513. #endif
  514. {
  515. return i;
  516. }
  517. #endif
  518. #if ! defined yyoverflow || YYERROR_VERBOSE
  519. /* The parser invokes alloca or malloc; define the necessary symbols. */
  520. # ifdef YYSTACK_USE_ALLOCA
  521. # if YYSTACK_USE_ALLOCA
  522. # ifdef __GNUC__
  523. # define YYSTACK_ALLOC __builtin_alloca
  524. # elif defined __BUILTIN_VA_ARG_INCR
  525. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  526. # elif defined _AIX
  527. # define YYSTACK_ALLOC __alloca
  528. # elif defined _MSC_VER
  529. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  530. # define alloca _alloca
  531. # else
  532. # define YYSTACK_ALLOC alloca
  533. # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  534. || defined __cplusplus || defined _MSC_VER)
  535. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  536. # ifndef _STDLIB_H
  537. # define _STDLIB_H 1
  538. # endif
  539. # endif
  540. # endif
  541. # endif
  542. # endif
  543. # ifdef YYSTACK_ALLOC
  544. /* Pacify GCC's `empty if-body' warning. */
  545. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
  546. # ifndef YYSTACK_ALLOC_MAXIMUM
  547. /* The OS might guarantee only one guard page at the bottom of the stack,
  548. and a page size can be as small as 4096 bytes. So we cannot safely
  549. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  550. to allow for a few compiler-allocated temporary stack slots. */
  551. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  552. # endif
  553. # else
  554. # define YYSTACK_ALLOC YYMALLOC
  555. # define YYSTACK_FREE YYFREE
  556. # ifndef YYSTACK_ALLOC_MAXIMUM
  557. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  558. # endif
  559. # if (defined __cplusplus && ! defined _STDLIB_H \
  560. && ! ((defined YYMALLOC || defined malloc) \
  561. && (defined YYFREE || defined free)))
  562. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  563. # ifndef _STDLIB_H
  564. # define _STDLIB_H 1
  565. # endif
  566. # endif
  567. # ifndef YYMALLOC
  568. # define YYMALLOC malloc
  569. # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  570. || defined __cplusplus || defined _MSC_VER)
  571. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  572. # endif
  573. # endif
  574. # ifndef YYFREE
  575. # define YYFREE free
  576. # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
  577. || defined __cplusplus || defined _MSC_VER)
  578. void free (void *); /* INFRINGES ON USER NAME SPACE */
  579. # endif
  580. # endif
  581. # endif
  582. #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
  583. #if (! defined yyoverflow \
  584. && (! defined __cplusplus \
  585. || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
  586. && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  587. /* A type that is properly aligned for any stack member. */
  588. union yyalloc
  589. {
  590. yytype_int16 yyss;
  591. YYSTYPE yyvs;
  592. YYLTYPE yyls;
  593. };
  594. /* The size of the maximum gap between one aligned stack and the next. */
  595. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  596. /* The size of an array large to enough to hold all stacks, each with
  597. N elements. */
  598. # define YYSTACK_BYTES(N) \
  599. ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
  600. + 2 * YYSTACK_GAP_MAXIMUM)
  601. /* Copy COUNT objects from FROM to TO. The source and destination do
  602. not overlap. */
  603. # ifndef YYCOPY
  604. # if defined __GNUC__ && 1 < __GNUC__
  605. # define YYCOPY(To, From, Count) \
  606. __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  607. # else
  608. # define YYCOPY(To, From, Count) \
  609. do \
  610. { \
  611. YYSIZE_T yyi; \
  612. for (yyi = 0; yyi < (Count); yyi++) \
  613. (To)[yyi] = (From)[yyi]; \
  614. } \
  615. while (YYID (0))
  616. # endif
  617. # endif
  618. /* Relocate STACK from its old location to the new one. The
  619. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  620. elements in the stack, and YYPTR gives the new location of the
  621. stack. Advance YYPTR to a properly aligned location for the next
  622. stack. */
  623. # define YYSTACK_RELOCATE(Stack) \
  624. do \
  625. { \
  626. YYSIZE_T yynewbytes; \
  627. YYCOPY (&yyptr->Stack, Stack, yysize); \
  628. Stack = &yyptr->Stack; \
  629. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  630. yyptr += yynewbytes / sizeof (*yyptr); \
  631. } \
  632. while (YYID (0))
  633. #endif
  634. /* YYFINAL -- State number of the termination state. */
  635. #define YYFINAL 11
  636. /* YYLAST -- Last index in YYTABLE. */
  637. #define YYLAST 159
  638. /* YYNTOKENS -- Number of terminals. */
  639. #define YYNTOKENS 26
  640. /* YYNNTS -- Number of nonterminals. */
  641. #define YYNNTS 4
  642. /* YYNRULES -- Number of rules. */
  643. #define YYNRULES 28
  644. /* YYNRULES -- Number of states. */
  645. #define YYNSTATES 54
  646. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  647. #define YYUNDEFTOK 2
  648. #define YYMAXUTOK 280
  649. #define YYTRANSLATE(YYX) \
  650. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  651. /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
  652. static const yytype_uint8 yytranslate[] =
  653. {
  654. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  655. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  656. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  657. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  658. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  659. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  660. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  661. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  662. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  663. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  664. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  665. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  666. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  667. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  668. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  669. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  670. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  671. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  672. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  673. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  674. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  675. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  676. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  677. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  678. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  679. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  680. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  681. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  682. 25
  683. };
  684. #if YYDEBUG
  685. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  686. YYRHS. */
  687. static const yytype_uint8 yyprhs[] =
  688. {
  689. 0, 0, 3, 5, 6, 8, 12, 15, 20, 22,
  690. 26, 30, 34, 38, 42, 46, 50, 54, 58, 62,
  691. 66, 69, 72, 76, 80, 84, 88, 92, 98
  692. };
  693. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  694. static const yytype_int8 yyrhs[] =
  695. {
  696. 27, 0, -1, 29, -1, -1, 29, -1, 28, 3,
  697. 29, -1, 28, 3, -1, 25, 23, 28, 24, -1,
  698. 25, -1, 23, 29, 24, -1, 29, 6, 29, -1,
  699. 29, 7, 29, -1, 29, 13, 29, -1, 29, 12,
  700. 29, -1, 29, 11, 29, -1, 29, 10, 29, -1,
  701. 29, 9, 29, -1, 29, 8, 29, -1, 29, 15,
  702. 29, -1, 29, 14, 29, -1, 14, 29, -1, 19,
  703. 29, -1, 29, 18, 29, -1, 29, 17, 29, -1,
  704. 29, 16, 29, -1, 29, 22, 29, -1, 29, 21,
  705. 29, -1, 29, 5, 29, 4, 29, -1, 29, 20,
  706. 29, -1
  707. };
  708. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  709. static const yytype_uint16 yyrline[] =
  710. {
  711. 0, 374, 374, 382, 389, 390, 396, 405, 411, 412,
  712. 416, 420, 424, 428, 432, 436, 440, 444, 448, 452,
  713. 456, 460, 464, 468, 472, 476, 480, 484, 489
  714. };
  715. #endif
  716. #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
  717. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  718. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  719. static const char *const yytname[] =
  720. {
  721. "$end", "error", "$undefined", "TOK_COMMA", "TOK_COLONCOLON",
  722. "TOK_COND", "TOK_OR", "TOK_AND", "TOK_NE", "TOK_LE", "TOK_GE", "TOK_LT",
  723. "TOK_GT", "TOK_EQ", "TOK_MINUS", "TOK_PLUS", "TOK_MOD", "TOK_DIV",
  724. "TOK_MULT", "TOK_COMPL", "TOK_TILDETILDE", "TOK_EQTILDE", "TOK_COLON",
  725. "TOK_LP", "TOK_RP", "TOKEN", "$accept", "start", "arglist", "expr", 0
  726. };
  727. #endif
  728. # ifdef YYPRINT
  729. /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
  730. token YYLEX-NUM. */
  731. static const yytype_uint16 yytoknum[] =
  732. {
  733. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  734. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  735. 275, 276, 277, 278, 279, 280
  736. };
  737. # endif
  738. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  739. static const yytype_uint8 yyr1[] =
  740. {
  741. 0, 26, 27, 27, 28, 28, 28, 29, 29, 29,
  742. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  743. 29, 29, 29, 29, 29, 29, 29, 29, 29
  744. };
  745. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  746. static const yytype_uint8 yyr2[] =
  747. {
  748. 0, 2, 1, 0, 1, 3, 2, 4, 1, 3,
  749. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  750. 2, 2, 3, 3, 3, 3, 3, 5, 3
  751. };
  752. /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
  753. STATE-NUM when YYTABLE doesn't specify something else to do. Zero
  754. means the default is an error. */
  755. static const yytype_uint8 yydefact[] =
  756. {
  757. 3, 0, 0, 0, 8, 0, 2, 20, 21, 0,
  758. 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
  759. 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
  760. 0, 4, 0, 10, 11, 17, 16, 15, 14, 13,
  761. 12, 19, 18, 24, 23, 22, 28, 26, 25, 6,
  762. 7, 0, 5, 27
  763. };
  764. /* YYDEFGOTO[NTERM-NUM]. */
  765. static const yytype_int8 yydefgoto[] =
  766. {
  767. -1, 5, 30, 6
  768. };
  769. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  770. STATE-NUM. */
  771. #define YYPACT_NINF -18
  772. static const yytype_int16 yypact[] =
  773. {
  774. 118, 118, 118, 118, -15, 6, 65, -17, -17, 25,
  775. 118, -18, 118, 118, 118, 118, 118, 118, 118, 118,
  776. 118, 118, 118, 118, 118, 118, 118, 118, 118, -18,
  777. 4, 65, 47, 98, 113, 130, 130, 130, 130, 130,
  778. 130, 137, 137, -17, -17, -17, -18, -18, -18, 118,
  779. -18, 118, 65, 82
  780. };
  781. /* YYPGOTO[NTERM-NUM]. */
  782. static const yytype_int8 yypgoto[] =
  783. {
  784. -18, -18, -18, -1
  785. };
  786. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  787. positive, shift that token. If negative, reduce the rule which
  788. number is the opposite. If zero, do what YYDEFACT says.
  789. If YYTABLE_NINF, syntax error. */
  790. #define YYTABLE_NINF -1
  791. static const yytype_uint8 yytable[] =
  792. {
  793. 7, 8, 9, 26, 27, 28, 11, 49, 10, 31,
  794. 0, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  795. 41, 42, 43, 44, 45, 46, 47, 48, 50, 0,
  796. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  797. 22, 23, 24, 25, 0, 26, 27, 28, 52, 29,
  798. 53, 51, 12, 13, 14, 15, 16, 17, 18, 19,
  799. 20, 21, 22, 23, 24, 25, 0, 26, 27, 28,
  800. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  801. 22, 23, 24, 25, 0, 26, 27, 28, 13, 14,
  802. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  803. 25, 0, 26, 27, 28, 14, 15, 16, 17, 18,
  804. 19, 20, 21, 22, 23, 24, 25, 0, 26, 27,
  805. 28, 15, 16, 17, 18, 19, 20, 21, 22, 23,
  806. 24, 25, 1, 26, 27, 28, 0, 2, 0, 0,
  807. 0, 3, 0, 4, 21, 22, 23, 24, 25, 0,
  808. 26, 27, 28, 23, 24, 25, 0, 26, 27, 28
  809. };
  810. static const yytype_int8 yycheck[] =
  811. {
  812. 1, 2, 3, 20, 21, 22, 0, 3, 23, 10,
  813. -1, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  814. 21, 22, 23, 24, 25, 26, 27, 28, 24, -1,
  815. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  816. 15, 16, 17, 18, -1, 20, 21, 22, 49, 24,
  817. 51, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  818. 13, 14, 15, 16, 17, 18, -1, 20, 21, 22,
  819. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  820. 15, 16, 17, 18, -1, 20, 21, 22, 6, 7,
  821. 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
  822. 18, -1, 20, 21, 22, 7, 8, 9, 10, 11,
  823. 12, 13, 14, 15, 16, 17, 18, -1, 20, 21,
  824. 22, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  825. 17, 18, 14, 20, 21, 22, -1, 19, -1, -1,
  826. -1, 23, -1, 25, 14, 15, 16, 17, 18, -1,
  827. 20, 21, 22, 16, 17, 18, -1, 20, 21, 22
  828. };
  829. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  830. symbol of state STATE-NUM. */
  831. static const yytype_uint8 yystos[] =
  832. {
  833. 0, 14, 19, 23, 25, 27, 29, 29, 29, 29,
  834. 23, 0, 5, 6, 7, 8, 9, 10, 11, 12,
  835. 13, 14, 15, 16, 17, 18, 20, 21, 22, 24,
  836. 28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  837. 29, 29, 29, 29, 29, 29, 29, 29, 29, 3,
  838. 24, 4, 29, 29
  839. };
  840. #define yyerrok (yyerrstatus = 0)
  841. #define yyclearin (yychar = YYEMPTY)
  842. #define YYEMPTY (-2)
  843. #define YYEOF 0
  844. #define YYACCEPT goto yyacceptlab
  845. #define YYABORT goto yyabortlab
  846. #define YYERROR goto yyerrorlab
  847. /* Like YYERROR except do call yyerror. This remains here temporarily
  848. to ease the transition to the new meaning of YYERROR, for GCC.
  849. Once GCC version 2 has supplanted version 1, this can go. */
  850. #define YYFAIL goto yyerrlab
  851. #define YYRECOVERING() (!!yyerrstatus)
  852. #define YYBACKUP(Token, Value) \
  853. do \
  854. if (yychar == YYEMPTY && yylen == 1) \
  855. { \
  856. yychar = (Token); \
  857. yylval = (Value); \
  858. yytoken = YYTRANSLATE (yychar); \
  859. YYPOPSTACK (1); \
  860. goto yybackup; \
  861. } \
  862. else \
  863. { \
  864. yyerror (YY_("syntax error: cannot back up")); \
  865. YYERROR; \
  866. } \
  867. while (YYID (0))
  868. #define YYTERROR 1
  869. #define YYERRCODE 256
  870. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  871. If N is 0, then set CURRENT to the empty location which ends
  872. the previous symbol: RHS[0] (always defined). */
  873. #define YYRHSLOC(Rhs, K) ((Rhs)[K])
  874. #ifndef YYLLOC_DEFAULT
  875. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  876. do \
  877. if (YYID (N)) \
  878. { \
  879. (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
  880. (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
  881. (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
  882. (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
  883. } \
  884. else \
  885. { \
  886. (Current).first_line = (Current).last_line = \
  887. YYRHSLOC (Rhs, 0).last_line; \
  888. (Current).first_column = (Current).last_column = \
  889. YYRHSLOC (Rhs, 0).last_column; \
  890. } \
  891. while (YYID (0))
  892. #endif
  893. /* YY_LOCATION_PRINT -- Print the location on the stream.
  894. This macro was not mandated originally: define only if we know
  895. we won't break user code: when these are the locations we know. */
  896. #ifndef YY_LOCATION_PRINT
  897. # if YYLTYPE_IS_TRIVIAL
  898. # define YY_LOCATION_PRINT(File, Loc) \
  899. fprintf (File, "%d.%d-%d.%d", \
  900. (Loc).first_line, (Loc).first_column, \
  901. (Loc).last_line, (Loc).last_column)
  902. # else
  903. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  904. # endif
  905. #endif
  906. /* YYLEX -- calling `yylex' with the right arguments. */
  907. #ifdef YYLEX_PARAM
  908. # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
  909. #else
  910. # define YYLEX yylex (&yylval, &yylloc)
  911. #endif
  912. /* Enable debugging if requested. */
  913. #if YYDEBUG
  914. # ifndef YYFPRINTF
  915. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  916. # define YYFPRINTF fprintf
  917. # endif
  918. # define YYDPRINTF(Args) \
  919. do { \
  920. if (yydebug) \
  921. YYFPRINTF Args; \
  922. } while (YYID (0))
  923. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  924. do { \
  925. if (yydebug) \
  926. { \
  927. YYFPRINTF (stderr, "%s ", Title); \
  928. yy_symbol_print (stderr, \
  929. Type, Value, Location); \
  930. YYFPRINTF (stderr, "\n"); \
  931. } \
  932. } while (YYID (0))
  933. /*--------------------------------.
  934. | Print this symbol on YYOUTPUT. |
  935. `--------------------------------*/
  936. /*ARGSUSED*/
  937. #if (defined __STDC__ || defined __C99__FUNC__ \
  938. || defined __cplusplus || defined _MSC_VER)
  939. static void
  940. yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
  941. #else
  942. static void
  943. yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
  944. FILE *yyoutput;
  945. int yytype;
  946. YYSTYPE const * const yyvaluep;
  947. YYLTYPE const * const yylocationp;
  948. #endif
  949. {
  950. if (!yyvaluep)
  951. return;
  952. YYUSE (yylocationp);
  953. # ifdef YYPRINT
  954. if (yytype < YYNTOKENS)
  955. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  956. # else
  957. YYUSE (yyoutput);
  958. # endif
  959. switch (yytype)
  960. {
  961. default:
  962. break;
  963. }
  964. }
  965. /*--------------------------------.
  966. | Print this symbol on YYOUTPUT. |
  967. `--------------------------------*/
  968. #if (defined __STDC__ || defined __C99__FUNC__ \
  969. || defined __cplusplus || defined _MSC_VER)
  970. static void
  971. yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
  972. #else
  973. static void
  974. yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
  975. FILE *yyoutput;
  976. int yytype;
  977. YYSTYPE const * const yyvaluep;
  978. YYLTYPE const * const yylocationp;
  979. #endif
  980. {
  981. if (yytype < YYNTOKENS)
  982. YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  983. else
  984. YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
  985. YY_LOCATION_PRINT (yyoutput, *yylocationp);
  986. YYFPRINTF (yyoutput, ": ");
  987. yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
  988. YYFPRINTF (yyoutput, ")");
  989. }
  990. /*------------------------------------------------------------------.
  991. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  992. | TOP (included). |
  993. `------------------------------------------------------------------*/
  994. #if (defined __STDC__ || defined __C99__FUNC__ \
  995. || defined __cplusplus || defined _MSC_VER)
  996. static void
  997. yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
  998. #else
  999. static void
  1000. yy_stack_print (bottom, top)
  1001. yytype_int16 *bottom;
  1002. yytype_int16 *top;
  1003. #endif
  1004. {
  1005. YYFPRINTF (stderr, "Stack now");
  1006. for (; bottom <= top; ++bottom)
  1007. YYFPRINTF (stderr, " %d", *bottom);
  1008. YYFPRINTF (stderr, "\n");
  1009. }
  1010. # define YY_STACK_PRINT(Bottom, Top) \
  1011. do { \
  1012. if (yydebug) \
  1013. yy_stack_print ((Bottom), (Top)); \
  1014. } while (YYID (0))
  1015. /*------------------------------------------------.
  1016. | Report that the YYRULE is going to be reduced. |
  1017. `------------------------------------------------*/
  1018. #if (defined __STDC__ || defined __C99__FUNC__ \
  1019. || defined __cplusplus || defined _MSC_VER)
  1020. static void
  1021. yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
  1022. #else
  1023. static void
  1024. yy_reduce_print (yyvsp, yylsp, yyrule)
  1025. YYSTYPE *yyvsp;
  1026. YYLTYPE *yylsp;
  1027. int yyrule;
  1028. #endif
  1029. {
  1030. int yynrhs = yyr2[yyrule];
  1031. int yyi;
  1032. unsigned long int yylno = yyrline[yyrule];
  1033. YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
  1034. yyrule - 1, yylno);
  1035. /* The symbols being reduced. */
  1036. for (yyi = 0; yyi < yynrhs; yyi++)
  1037. {
  1038. fprintf (stderr, " $%d = ", yyi + 1);
  1039. yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
  1040. &(yyvsp[(yyi + 1) - (yynrhs)])
  1041. , &(yylsp[(yyi + 1) - (yynrhs)]) );
  1042. fprintf (stderr, "\n");
  1043. }
  1044. }
  1045. # define YY_REDUCE_PRINT(Rule) \
  1046. do { \
  1047. if (yydebug) \
  1048. yy_reduce_print (yyvsp, yylsp, Rule); \
  1049. } while (YYID (0))
  1050. /* Nonzero means print parse trace. It is left uninitialized so that
  1051. multiple parsers can coexist. */
  1052. int yydebug;
  1053. #else /* !YYDEBUG */
  1054. # define YYDPRINTF(Args)
  1055. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  1056. # define YY_STACK_PRINT(Bottom, Top)
  1057. # define YY_REDUCE_PRINT(Rule)
  1058. #endif /* !YYDEBUG */
  1059. /* YYINITDEPTH -- initial size of the parser's stacks. */
  1060. #ifndef YYINITDEPTH
  1061. # define YYINITDEPTH 200
  1062. #endif
  1063. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  1064. if the built-in stack extension method is used).
  1065. Do not make this value too large; the results are undefined if
  1066. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  1067. evaluated with infinite-precision integer arithmetic. */
  1068. #ifndef YYMAXDEPTH
  1069. # define YYMAXDEPTH 10000
  1070. #endif
  1071. #if YYERROR_VERBOSE
  1072. # ifndef yystrlen
  1073. # if defined __GLIBC__ && defined _STRING_H
  1074. # define yystrlen strlen
  1075. # else
  1076. /* Return the length of YYSTR. */
  1077. #if (defined __STDC__ || defined __C99__FUNC__ \
  1078. || defined __cplusplus || defined _MSC_VER)
  1079. static YYSIZE_T
  1080. yystrlen (const char *yystr)
  1081. #else
  1082. static YYSIZE_T
  1083. yystrlen (yystr)
  1084. const char *yystr;
  1085. #endif
  1086. {
  1087. YYSIZE_T yylen;
  1088. for (yylen = 0; yystr[yylen]; yylen++)
  1089. continue;
  1090. return yylen;
  1091. }
  1092. # endif
  1093. # endif
  1094. # ifndef yystpcpy
  1095. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  1096. # define yystpcpy stpcpy
  1097. # else
  1098. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  1099. YYDEST. */
  1100. #if (defined __STDC__ || defined __C99__FUNC__ \
  1101. || defined __cplusplus || defined _MSC_VER)
  1102. static char *
  1103. yystpcpy (char *yydest, const char *yysrc)
  1104. #else
  1105. static char *
  1106. yystpcpy (yydest, yysrc)
  1107. char *yydest;
  1108. const char *yysrc;
  1109. #endif
  1110. {
  1111. char *yyd = yydest;
  1112. const char *yys = yysrc;
  1113. while ((*yyd++ = *yys++) != '\0')
  1114. continue;
  1115. return yyd - 1;
  1116. }
  1117. # endif
  1118. # endif
  1119. # ifndef yytnamerr
  1120. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  1121. quotes and backslashes, so that it's suitable for yyerror. The
  1122. heuristic is that double-quoting is unnecessary unless the string
  1123. contains an apostrophe, a comma, or backslash (other than
  1124. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  1125. null, do not copy; instead, return the length of what the result
  1126. would have been. */
  1127. static YYSIZE_T
  1128. yytnamerr (char *yyres, const char *yystr)
  1129. {
  1130. if (*yystr == '"')
  1131. {
  1132. YYSIZE_T yyn = 0;
  1133. char const *yyp = yystr;
  1134. for (;;)
  1135. switch (*++yyp)
  1136. {
  1137. case '\'':
  1138. case ',':
  1139. goto do_not_strip_quotes;
  1140. case '\\':
  1141. if (*++yyp != '\\')
  1142. goto do_not_strip_quotes;
  1143. /* Fall through. */
  1144. default:
  1145. if (yyres)
  1146. yyres[yyn] = *yyp;
  1147. yyn++;
  1148. break;
  1149. case '"':
  1150. if (yyres)
  1151. yyres[yyn] = '\0';
  1152. return yyn;
  1153. }
  1154. do_not_strip_quotes: ;
  1155. }
  1156. if (! yyres)
  1157. return yystrlen (yystr);
  1158. return yystpcpy (yyres, yystr) - yyres;
  1159. }
  1160. # endif
  1161. /* Copy into YYRESULT an error message about the unexpected token
  1162. YYCHAR while in state YYSTATE. Return the number of bytes copied,
  1163. including the terminating null byte. If YYRESULT is null, do not
  1164. copy anything; just return the number of bytes that would be
  1165. copied. As a special case, return 0 if an ordinary "syntax error"
  1166. message will do. Return YYSIZE_MAXIMUM if overflow occurs during
  1167. size calculation. */
  1168. static YYSIZE_T
  1169. yysyntax_error (char *yyresult, int yystate, int yychar)
  1170. {
  1171. int yyn = yypact[yystate];
  1172. if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
  1173. return 0;
  1174. else
  1175. {
  1176. int yytype = YYTRANSLATE (yychar);
  1177. YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
  1178. YYSIZE_T yysize = yysize0;
  1179. YYSIZE_T yysize1;
  1180. int yysize_overflow = 0;
  1181. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  1182. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  1183. int yyx;
  1184. # if 0
  1185. /* This is so xgettext sees the translatable formats that are
  1186. constructed on the fly. */
  1187. YY_("syntax error, unexpected %s");
  1188. YY_("syntax error, unexpected %s, expecting %s");
  1189. YY_("syntax error, unexpected %s, expecting %s or %s");
  1190. YY_("syntax error, unexpected %s, expecting %s or %s or %s");
  1191. YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
  1192. # endif
  1193. char *yyfmt;
  1194. char const *yyf;
  1195. static char const yyunexpected[] = "syntax error, unexpected %s";
  1196. static char const yyexpecting[] = ", expecting %s";
  1197. static char const yyor[] = " or %s";
  1198. char yyformat[sizeof yyunexpected
  1199. + sizeof yyexpecting - 1
  1200. + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
  1201. * (sizeof yyor - 1))];
  1202. char const *yyprefix = yyexpecting;
  1203. /* Start YYX at -YYN if negative to avoid negative indexes in
  1204. YYCHECK. */
  1205. int yyxbegin = yyn < 0 ? -yyn : 0;
  1206. /* Stay within bounds of both yycheck and yytname. */
  1207. int yychecklim = YYLAST - yyn + 1;
  1208. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  1209. int yycount = 1;
  1210. yyarg[0] = yytname[yytype];
  1211. yyfmt = yystpcpy (yyformat, yyunexpected);
  1212. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  1213. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  1214. {
  1215. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  1216. {
  1217. yycount = 1;
  1218. yysize = yysize0;
  1219. yyformat[sizeof yyunexpected - 1] = '\0';
  1220. break;
  1221. }
  1222. yyarg[yycount++] = yytname[yyx];
  1223. yysize1 = yysize + yytnamerr (0, yytname[yyx]);
  1224. yysize_overflow |= (yysize1 < yysize);
  1225. yysize = yysize1;
  1226. yyfmt = yystpcpy (yyfmt, yyprefix);
  1227. yyprefix = yyor;
  1228. }
  1229. yyf = YY_(yyformat);
  1230. yysize1 = yysize + yystrlen (yyf);
  1231. yysize_overflow |= (yysize1 < yysize);
  1232. yysize = yysize1;
  1233. if (yysize_overflow)
  1234. return YYSIZE_MAXIMUM;
  1235. if (yyresult)
  1236. {
  1237. /* Avoid sprintf, as that infringes on the user's name space.
  1238. Don't have undefined behavior even if the translation
  1239. produced a string with the wrong number of "%s"s. */
  1240. char *yyp = yyresult;
  1241. int yyi = 0;
  1242. while ((*yyp = *yyf) != '\0')
  1243. {
  1244. if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
  1245. {
  1246. yyp += yytnamerr (yyp, yyarg[yyi++]);
  1247. yyf += 2;
  1248. }
  1249. else
  1250. {
  1251. yyp++;
  1252. yyf++;
  1253. }
  1254. }
  1255. }
  1256. return yysize;
  1257. }
  1258. }
  1259. #endif /* YYERROR_VERBOSE */
  1260. /*-----------------------------------------------.
  1261. | Release the memory associated to this symbol. |
  1262. `-----------------------------------------------*/
  1263. /*ARGSUSED*/
  1264. #if (defined __STDC__ || defined __C99__FUNC__ \
  1265. || defined __cplusplus || defined _MSC_VER)
  1266. static void
  1267. yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
  1268. #else
  1269. static void
  1270. yydestruct (yymsg, yytype, yyvaluep, yylocationp)
  1271. const char *yymsg;
  1272. int yytype;
  1273. YYSTYPE *yyvaluep;
  1274. YYLTYPE *yylocationp;
  1275. #endif
  1276. {
  1277. YYUSE (yyvaluep);
  1278. YYUSE (yylocationp);
  1279. if (!yymsg)
  1280. yymsg = "Deleting";
  1281. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  1282. switch (yytype)
  1283. {
  1284. case 4: /* "TOK_COLONCOLON" */
  1285. #line 368 "ast_expr2.y"
  1286. { free_value((yyvaluep->val)); };
  1287. #line 1479 "ast_expr2.c"
  1288. break;
  1289. case 5: /* "TOK_COND" */
  1290. #line 368 "ast_expr2.y"
  1291. { free_value((yyvaluep->val)); };
  1292. #line 1484 "ast_expr2.c"
  1293. break;
  1294. case 6: /* "TOK_OR" */
  1295. #line 368 "ast_expr2.y"
  1296. { free_value((yyvaluep->val)); };
  1297. #line 1489 "ast_expr2.c"
  1298. break;
  1299. case 7: /* "TOK_AND" */
  1300. #line 368 "ast_expr2.y"
  1301. { free_value((yyvaluep->val)); };
  1302. #line 1494 "ast_expr2.c"
  1303. break;
  1304. case 8: /* "TOK_NE" */
  1305. #line 368 "ast_expr2.y"
  1306. { free_value((yyvaluep->val)); };
  1307. #line 1499 "ast_expr2.c"
  1308. break;
  1309. case 9: /* "TOK_LE" */
  1310. #line 368 "ast_expr2.y"
  1311. { free_value((yyvaluep->val)); };
  1312. #line 1504 "ast_expr2.c"
  1313. break;
  1314. case 10: /* "TOK_GE" */
  1315. #line 368 "ast_expr2.y"
  1316. { free_value((yyvaluep->val)); };
  1317. #line 1509 "ast_expr2.c"
  1318. break;
  1319. case 11: /* "TOK_LT" */
  1320. #line 368 "ast_expr2.y"
  1321. { free_value((yyvaluep->val)); };
  1322. #line 1514 "ast_expr2.c"
  1323. break;
  1324. case 12: /* "TOK_GT" */
  1325. #line 368 "ast_expr2.y"
  1326. { free_value((yyvaluep->val)); };
  1327. #line 1519 "ast_expr2.c"
  1328. break;
  1329. case 13: /* "TOK_EQ" */
  1330. #line 368 "ast_expr2.y"
  1331. { free_value((yyvaluep->val)); };
  1332. #line 1524 "ast_expr2.c"
  1333. break;
  1334. case 14: /* "TOK_MINUS" */
  1335. #line 368 "ast_expr2.y"
  1336. { free_value((yyvaluep->val)); };
  1337. #line 1529 "ast_expr2.c"
  1338. break;
  1339. case 15: /* "TOK_PLUS" */
  1340. #line 368 "ast_expr2.y"
  1341. { free_value((yyvaluep->val)); };
  1342. #line 1534 "ast_expr2.c"
  1343. break;
  1344. case 16: /* "TOK_MOD" */
  1345. #line 368 "ast_expr2.y"
  1346. { free_value((yyvaluep->val)); };
  1347. #line 1539 "ast_expr2.c"
  1348. break;
  1349. case 17: /* "TOK_DIV" */
  1350. #line 368 "ast_expr2.y"
  1351. { free_value((yyvaluep->val)); };
  1352. #line 1544 "ast_expr2.c"
  1353. break;
  1354. case 18: /* "TOK_MULT" */
  1355. #line 368 "ast_expr2.y"
  1356. { free_value((yyvaluep->val)); };
  1357. #line 1549 "ast_expr2.c"
  1358. break;
  1359. case 19: /* "TOK_COMPL" */
  1360. #line 368 "ast_expr2.y"
  1361. { free_value((yyvaluep->val)); };
  1362. #line 1554 "ast_expr2.c"
  1363. break;
  1364. case 20: /* "TOK_TILDETILDE" */
  1365. #line 368 "ast_expr2.y"
  1366. { free_value((yyvaluep->val)); };
  1367. #line 1559 "ast_expr2.c"
  1368. break;
  1369. case 21: /* "TOK_EQTILDE" */
  1370. #line 368 "ast_expr2.y"
  1371. { free_value((yyvaluep->val)); };
  1372. #line 1564 "ast_expr2.c"
  1373. break;
  1374. case 22: /* "TOK_COLON" */
  1375. #line 368 "ast_expr2.y"
  1376. { free_value((yyvaluep->val)); };
  1377. #line 1569 "ast_expr2.c"
  1378. break;
  1379. case 23: /* "TOK_LP" */
  1380. #line 368 "ast_expr2.y"
  1381. { free_value((yyvaluep->val)); };
  1382. #line 1574 "ast_expr2.c"
  1383. break;
  1384. case 24: /* "TOK_RP" */
  1385. #line 368 "ast_expr2.y"
  1386. { free_value((yyvaluep->val)); };
  1387. #line 1579 "ast_expr2.c"
  1388. break;
  1389. case 25: /* "TOKEN" */
  1390. #line 368 "ast_expr2.y"
  1391. { free_value((yyvaluep->val)); };
  1392. #line 1584 "ast_expr2.c"
  1393. break;
  1394. case 29: /* "expr" */
  1395. #line 368 "ast_expr2.y"
  1396. { free_value((yyvaluep->val)); };
  1397. #line 1589 "ast_expr2.c"
  1398. break;
  1399. default:
  1400. break;
  1401. }
  1402. }
  1403. /* Prevent warnings from -Wmissing-prototypes. */
  1404. #ifdef YYPARSE_PARAM
  1405. #if defined __STDC__ || defined __cplusplus
  1406. int yyparse (void *YYPARSE_PARAM);
  1407. #else
  1408. int yyparse ();
  1409. #endif
  1410. #else /* ! YYPARSE_PARAM */
  1411. #if defined __STDC__ || defined __cplusplus
  1412. int yyparse (void);
  1413. #else
  1414. int yyparse ();
  1415. #endif
  1416. #endif /* ! YYPARSE_PARAM */
  1417. /*----------.
  1418. | yyparse. |
  1419. `----------*/
  1420. #ifdef YYPARSE_PARAM
  1421. #if (defined __STDC__ || defined __C99__FUNC__ \
  1422. || defined __cplusplus || defined _MSC_VER)
  1423. int
  1424. yyparse (void *YYPARSE_PARAM)
  1425. #else
  1426. int
  1427. yyparse (YYPARSE_PARAM)
  1428. void *YYPARSE_PARAM;
  1429. #endif
  1430. #else /* ! YYPARSE_PARAM */
  1431. #if (defined __STDC__ || defined __C99__FUNC__ \
  1432. || defined __cplusplus || defined _MSC_VER)
  1433. int
  1434. yyparse (void)
  1435. #else
  1436. int
  1437. yyparse ()
  1438. #endif
  1439. #endif
  1440. {
  1441. /* The look-ahead symbol. */
  1442. int yychar;
  1443. /* The semantic value of the look-ahead symbol. */
  1444. YYSTYPE yylval;
  1445. /* Number of syntax errors so far. */
  1446. int yynerrs;
  1447. /* Location data for the look-ahead symbol. */
  1448. YYLTYPE yylloc;
  1449. int yystate;
  1450. int yyn;
  1451. int yyresult;
  1452. /* Number of tokens to shift before error messages enabled. */
  1453. int yyerrstatus;
  1454. /* Look-ahead token as an internal (translated) token number. */
  1455. int yytoken = 0;
  1456. #if YYERROR_VERBOSE
  1457. /* Buffer for error messages, and its allocated size. */
  1458. char yymsgbuf[128];
  1459. char *yymsg = yymsgbuf;
  1460. YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  1461. #endif
  1462. /* Three stacks and their tools:
  1463. `yyss': related to states,
  1464. `yyvs': related to semantic values,
  1465. `yyls': related to locations.
  1466. Refer to the stacks thru separate pointers, to allow yyoverflow
  1467. to reallocate them elsewhere. */
  1468. /* The state stack. */
  1469. yytype_int16 yyssa[YYINITDEPTH];
  1470. yytype_int16 *yyss = yyssa;
  1471. yytype_int16 *yyssp;
  1472. /* The semantic value stack. */
  1473. YYSTYPE yyvsa[YYINITDEPTH];
  1474. YYSTYPE *yyvs = yyvsa;
  1475. YYSTYPE *yyvsp;
  1476. /* The location stack. */
  1477. YYLTYPE yylsa[YYINITDEPTH];
  1478. YYLTYPE *yyls = yylsa;
  1479. YYLTYPE *yylsp;
  1480. /* The locations where the error started and ended. */
  1481. YYLTYPE yyerror_range[2];
  1482. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
  1483. YYSIZE_T yystacksize = YYINITDEPTH;
  1484. /* The variables used to return semantic value and location from the
  1485. action routines. */
  1486. YYSTYPE yyval;
  1487. YYLTYPE yyloc;
  1488. /* The number of symbols on the RHS of the reduced rule.
  1489. Keep to zero when no symbol should be popped. */
  1490. int yylen = 0;
  1491. YYDPRINTF ((stderr, "Starting parse\n"));
  1492. yystate = 0;
  1493. yyerrstatus = 0;
  1494. yynerrs = 0;
  1495. yychar = YYEMPTY; /* Cause a token to be read. */
  1496. /* Initialize stack pointers.
  1497. Waste one element of value and location stack
  1498. so that they stay on the same level as the state stack.
  1499. The wasted elements are never initialized. */
  1500. yyssp = yyss;
  1501. yyvsp = yyvs;
  1502. yylsp = yyls;
  1503. #if YYLTYPE_IS_TRIVIAL
  1504. /* Initialize the default location before parsing starts. */
  1505. yylloc.first_line = yylloc.last_line = 1;
  1506. yylloc.first_column = yylloc.last_column = 0;
  1507. #endif
  1508. goto yysetstate;
  1509. /*------------------------------------------------------------.
  1510. | yynewstate -- Push a new state, which is found in yystate. |
  1511. `------------------------------------------------------------*/
  1512. yynewstate:
  1513. /* In all cases, when you get here, the value and location stacks
  1514. have just been pushed. So pushing a state here evens the stacks. */
  1515. yyssp++;
  1516. yysetstate:
  1517. *yyssp = yystate;
  1518. if (yyss + yystacksize - 1 <= yyssp)
  1519. {
  1520. /* Get the current used size of the three stacks, in elements. */
  1521. YYSIZE_T yysize = yyssp - yyss + 1;
  1522. #ifdef yyoverflow
  1523. {
  1524. /* Give user a chance to reallocate the stack. Use copies of
  1525. these so that the &'s don't force the real ones into
  1526. memory. */
  1527. YYSTYPE *yyvs1 = yyvs;
  1528. yytype_int16 *yyss1 = yyss;
  1529. YYLTYPE *yyls1 = yyls;
  1530. /* Each stack pointer address is followed by the size of the
  1531. data in use in that stack, in bytes. This used to be a
  1532. conditional around just the two extra args, but that might
  1533. be undefined if yyoverflow is a macro. */
  1534. yyoverflow (YY_("memory exhausted"),
  1535. &yyss1, yysize * sizeof (*yyssp),
  1536. &yyvs1, yysize * sizeof (*yyvsp),
  1537. &yyls1, yysize * sizeof (*yylsp),
  1538. &yystacksize);
  1539. yyls = yyls1;
  1540. yyss = yyss1;
  1541. yyvs = yyvs1;
  1542. }
  1543. #else /* no yyoverflow */
  1544. # ifndef YYSTACK_RELOCATE
  1545. goto yyexhaustedlab;
  1546. # else
  1547. /* Extend the stack our own way. */
  1548. if (YYMAXDEPTH <= yystacksize)
  1549. goto yyexhaustedlab;
  1550. yystacksize *= 2;
  1551. if (YYMAXDEPTH < yystacksize)
  1552. yystacksize = YYMAXDEPTH;
  1553. {
  1554. yytype_int16 *yyss1 = yyss;
  1555. union yyalloc *yyptr =
  1556. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  1557. if (! yyptr)
  1558. goto yyexhaustedlab;
  1559. YYSTACK_RELOCATE (yyss);
  1560. YYSTACK_RELOCATE (yyvs);
  1561. YYSTACK_RELOCATE (yyls);
  1562. # undef YYSTACK_RELOCATE
  1563. if (yyss1 != yyssa)
  1564. YYSTACK_FREE (yyss1);
  1565. }
  1566. # endif
  1567. #endif /* no yyoverflow */
  1568. yyssp = yyss + yysize - 1;
  1569. yyvsp = yyvs + yysize - 1;
  1570. yylsp = yyls + yysize - 1;
  1571. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1572. (unsigned long int) yystacksize));
  1573. if (yyss + yystacksize - 1 <= yyssp)
  1574. YYABORT;
  1575. }
  1576. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1577. goto yybackup;
  1578. /*-----------.
  1579. | yybackup. |
  1580. `-----------*/
  1581. yybackup:
  1582. /* Do appropriate processing given the current state. Read a
  1583. look-ahead token if we need one and don't already have one. */
  1584. /* First try to decide what to do without reference to look-ahead token. */
  1585. yyn = yypact[yystate];
  1586. if (yyn == YYPACT_NINF)
  1587. goto yydefault;
  1588. /* Not known => get a look-ahead token if don't already have one. */
  1589. /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
  1590. if (yychar == YYEMPTY)
  1591. {
  1592. YYDPRINTF ((stderr, "Reading a token: "));
  1593. yychar = YYLEX;
  1594. }
  1595. if (yychar <= YYEOF)
  1596. {
  1597. yychar = yytoken = YYEOF;
  1598. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1599. }
  1600. else
  1601. {
  1602. yytoken = YYTRANSLATE (yychar);
  1603. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1604. }
  1605. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1606. detect an error, take that action. */
  1607. yyn += yytoken;
  1608. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1609. goto yydefault;
  1610. yyn = yytable[yyn];
  1611. if (yyn <= 0)
  1612. {
  1613. if (yyn == 0 || yyn == YYTABLE_NINF)
  1614. goto yyerrlab;
  1615. yyn = -yyn;
  1616. goto yyreduce;
  1617. }
  1618. if (yyn == YYFINAL)
  1619. YYACCEPT;
  1620. /* Count tokens shifted since error; after three, turn off error
  1621. status. */
  1622. if (yyerrstatus)
  1623. yyerrstatus--;
  1624. /* Shift the look-ahead token. */
  1625. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1626. /* Discard the shifted token unless it is eof. */
  1627. if (yychar != YYEOF)
  1628. yychar = YYEMPTY;
  1629. yystate = yyn;
  1630. *++yyvsp = yylval;
  1631. *++yylsp = yylloc;
  1632. goto yynewstate;
  1633. /*-----------------------------------------------------------.
  1634. | yydefault -- do the default action for the current state. |
  1635. `-----------------------------------------------------------*/
  1636. yydefault:
  1637. yyn = yydefact[yystate];
  1638. if (yyn == 0)
  1639. goto yyerrlab;
  1640. goto yyreduce;
  1641. /*-----------------------------.
  1642. | yyreduce -- Do a reduction. |
  1643. `-----------------------------*/
  1644. yyreduce:
  1645. /* yyn is the number of a rule to reduce with. */
  1646. yylen = yyr2[yyn];
  1647. /* If YYLEN is nonzero, implement the default value of the action:
  1648. `$$ = $1'.
  1649. Otherwise, the following line sets YYVAL to garbage.
  1650. This behavior is undocumented and Bison
  1651. users should not rely upon it. Assigning to YYVAL
  1652. unconditionally makes the parser a bit smaller, and it avoids a
  1653. GCC warning that YYVAL may be used uninitialized. */
  1654. yyval = yyvsp[1-yylen];
  1655. /* Default location. */
  1656. YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  1657. YY_REDUCE_PRINT (yyn);
  1658. switch (yyn)
  1659. {
  1660. case 2:
  1661. #line 374 "ast_expr2.y"
  1662. { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
  1663. ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
  1664. if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
  1665. ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i;
  1666. else
  1667. ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s;
  1668. free((yyvsp[(1) - (1)].val));
  1669. ;}
  1670. break;
  1671. case 3:
  1672. #line 382 "ast_expr2.y"
  1673. {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
  1674. ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
  1675. ((struct parse_io *)parseio)->val->u.s = strdup("");
  1676. ;}
  1677. break;
  1678. case 4:
  1679. #line 389 "ast_expr2.y"
  1680. { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
  1681. break;
  1682. case 5:
  1683. #line 390 "ast_expr2.y"
  1684. {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
  1685. struct expr_node *t;
  1686. DESTROY((yyvsp[(2) - (3)].val));
  1687. for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right)
  1688. ;
  1689. (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;}
  1690. break;
  1691. case 6:
  1692. #line 396 "ast_expr2.y"
  1693. {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
  1694. struct expr_node *t; /* NULL args should OK */
  1695. DESTROY((yyvsp[(2) - (2)].val));
  1696. for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right)
  1697. ;
  1698. (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;}
  1699. break;
  1700. case 7:
  1701. #line 405 "ast_expr2.y"
  1702. { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
  1703. DESTROY((yyvsp[(2) - (4)].val));
  1704. DESTROY((yyvsp[(4) - (4)].val));
  1705. DESTROY((yyvsp[(1) - (4)].val));
  1706. destroy_arglist((yyvsp[(3) - (4)].arglist));
  1707. ;}
  1708. break;
  1709. case 8:
  1710. #line 411 "ast_expr2.y"
  1711. {(yyval.val) = (yyvsp[(1) - (1)].val);;}
  1712. break;
  1713. case 9:
  1714. #line 412 "ast_expr2.y"
  1715. { (yyval.val) = (yyvsp[(2) - (3)].val);
  1716. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1717. (yyloc).first_line=0; (yyloc).last_line=0;
  1718. DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;}
  1719. break;
  1720. case 10:
  1721. #line 416 "ast_expr2.y"
  1722. { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1723. DESTROY((yyvsp[(2) - (3)].val));
  1724. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1725. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1726. break;
  1727. case 11:
  1728. #line 420 "ast_expr2.y"
  1729. { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1730. DESTROY((yyvsp[(2) - (3)].val));
  1731. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1732. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1733. break;
  1734. case 12:
  1735. #line 424 "ast_expr2.y"
  1736. { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1737. DESTROY((yyvsp[(2) - (3)].val));
  1738. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1739. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1740. break;
  1741. case 13:
  1742. #line 428 "ast_expr2.y"
  1743. { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1744. DESTROY((yyvsp[(2) - (3)].val));
  1745. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1746. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1747. break;
  1748. case 14:
  1749. #line 432 "ast_expr2.y"
  1750. { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1751. DESTROY((yyvsp[(2) - (3)].val));
  1752. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1753. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1754. break;
  1755. case 15:
  1756. #line 436 "ast_expr2.y"
  1757. { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1758. DESTROY((yyvsp[(2) - (3)].val));
  1759. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1760. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1761. break;
  1762. case 16:
  1763. #line 440 "ast_expr2.y"
  1764. { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1765. DESTROY((yyvsp[(2) - (3)].val));
  1766. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1767. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1768. break;
  1769. case 17:
  1770. #line 444 "ast_expr2.y"
  1771. { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1772. DESTROY((yyvsp[(2) - (3)].val));
  1773. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1774. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1775. break;
  1776. case 18:
  1777. #line 448 "ast_expr2.y"
  1778. { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1779. DESTROY((yyvsp[(2) - (3)].val));
  1780. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1781. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1782. break;
  1783. case 19:
  1784. #line 452 "ast_expr2.y"
  1785. { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1786. DESTROY((yyvsp[(2) - (3)].val));
  1787. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1788. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1789. break;
  1790. case 20:
  1791. #line 456 "ast_expr2.y"
  1792. { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val));
  1793. DESTROY((yyvsp[(1) - (2)].val));
  1794. (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
  1795. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1796. break;
  1797. case 21:
  1798. #line 460 "ast_expr2.y"
  1799. { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val));
  1800. DESTROY((yyvsp[(1) - (2)].val));
  1801. (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
  1802. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1803. break;
  1804. case 22:
  1805. #line 464 "ast_expr2.y"
  1806. { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1807. DESTROY((yyvsp[(2) - (3)].val));
  1808. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1809. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1810. break;
  1811. case 23:
  1812. #line 468 "ast_expr2.y"
  1813. { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1814. DESTROY((yyvsp[(2) - (3)].val));
  1815. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1816. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1817. break;
  1818. case 24:
  1819. #line 472 "ast_expr2.y"
  1820. { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1821. DESTROY((yyvsp[(2) - (3)].val));
  1822. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1823. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1824. break;
  1825. case 25:
  1826. #line 476 "ast_expr2.y"
  1827. { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1828. DESTROY((yyvsp[(2) - (3)].val));
  1829. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1830. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1831. break;
  1832. case 26:
  1833. #line 480 "ast_expr2.y"
  1834. { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1835. DESTROY((yyvsp[(2) - (3)].val));
  1836. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1837. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1838. break;
  1839. case 27:
  1840. #line 484 "ast_expr2.y"
  1841. { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val));
  1842. DESTROY((yyvsp[(2) - (5)].val));
  1843. DESTROY((yyvsp[(4) - (5)].val));
  1844. (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column;
  1845. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1846. break;
  1847. case 28:
  1848. #line 489 "ast_expr2.y"
  1849. { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
  1850. DESTROY((yyvsp[(2) - (3)].val));
  1851. (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
  1852. (yyloc).first_line=0; (yyloc).last_line=0;;}
  1853. break;
  1854. /* Line 1267 of yacc.c. */
  1855. #line 2134 "ast_expr2.c"
  1856. default: break;
  1857. }
  1858. YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  1859. YYPOPSTACK (yylen);
  1860. yylen = 0;
  1861. YY_STACK_PRINT (yyss, yyssp);
  1862. *++yyvsp = yyval;
  1863. *++yylsp = yyloc;
  1864. /* Now `shift' the result of the reduction. Determine what state
  1865. that goes to, based on the state we popped back to and the rule
  1866. number reduced by. */
  1867. yyn = yyr1[yyn];
  1868. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  1869. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1870. yystate = yytable[yystate];
  1871. else
  1872. yystate = yydefgoto[yyn - YYNTOKENS];
  1873. goto yynewstate;
  1874. /*------------------------------------.
  1875. | yyerrlab -- here on detecting error |
  1876. `------------------------------------*/
  1877. yyerrlab:
  1878. /* If not already recovering from an error, report this error. */
  1879. if (!yyerrstatus)
  1880. {
  1881. ++yynerrs;
  1882. #if ! YYERROR_VERBOSE
  1883. yyerror (YY_("syntax error"));
  1884. #else
  1885. {
  1886. YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
  1887. if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
  1888. {
  1889. YYSIZE_T yyalloc = 2 * yysize;
  1890. if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
  1891. yyalloc = YYSTACK_ALLOC_MAXIMUM;
  1892. if (yymsg != yymsgbuf)
  1893. YYSTACK_FREE (yymsg);
  1894. yymsg = (char *) YYSTACK_ALLOC (yyalloc);
  1895. if (yymsg)
  1896. yymsg_alloc = yyalloc;
  1897. else
  1898. {
  1899. yymsg = yymsgbuf;
  1900. yymsg_alloc = sizeof yymsgbuf;
  1901. }
  1902. }
  1903. if (0 < yysize && yysize <= yymsg_alloc)
  1904. {
  1905. (void) yysyntax_error (yymsg, yystate, yychar);
  1906. yyerror (yymsg);
  1907. }
  1908. else
  1909. {
  1910. yyerror (YY_("syntax error"));
  1911. if (yysize != 0)
  1912. goto yyexhaustedlab;
  1913. }
  1914. }
  1915. #endif
  1916. }
  1917. yyerror_range[0] = yylloc;
  1918. if (yyerrstatus == 3)
  1919. {
  1920. /* If just tried and failed to reuse look-ahead token after an
  1921. error, discard it. */
  1922. if (yychar <= YYEOF)
  1923. {
  1924. /* Return failure if at end of input. */
  1925. if (yychar == YYEOF)
  1926. YYABORT;
  1927. }
  1928. else
  1929. {
  1930. yydestruct ("Error: discarding",
  1931. yytoken, &yylval, &yylloc);
  1932. yychar = YYEMPTY;
  1933. }
  1934. }
  1935. /* Else will try to reuse look-ahead token after shifting the error
  1936. token. */
  1937. goto yyerrlab1;
  1938. /*---------------------------------------------------.
  1939. | yyerrorlab -- error raised explicitly by YYERROR. |
  1940. `---------------------------------------------------*/
  1941. yyerrorlab:
  1942. /* Pacify compilers like GCC when the user code never invokes
  1943. YYERROR and the label yyerrorlab therefore never appears in user
  1944. code. */
  1945. if (/*CONSTCOND*/ 0)
  1946. goto yyerrorlab;
  1947. yyerror_range[0] = yylsp[1-yylen];
  1948. /* Do not reclaim the symbols of the rule which action triggered
  1949. this YYERROR. */
  1950. YYPOPSTACK (yylen);
  1951. yylen = 0;
  1952. YY_STACK_PRINT (yyss, yyssp);
  1953. yystate = *yyssp;
  1954. goto yyerrlab1;
  1955. /*-------------------------------------------------------------.
  1956. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1957. `-------------------------------------------------------------*/
  1958. yyerrlab1:
  1959. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1960. for (;;)
  1961. {
  1962. yyn = yypact[yystate];
  1963. if (yyn != YYPACT_NINF)
  1964. {
  1965. yyn += YYTERROR;
  1966. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1967. {
  1968. yyn = yytable[yyn];
  1969. if (0 < yyn)
  1970. break;
  1971. }
  1972. }
  1973. /* Pop the current state because it cannot handle the error token. */
  1974. if (yyssp == yyss)
  1975. YYABORT;
  1976. yyerror_range[0] = *yylsp;
  1977. yydestruct ("Error: popping",
  1978. yystos[yystate], yyvsp, yylsp);
  1979. YYPOPSTACK (1);
  1980. yystate = *yyssp;
  1981. YY_STACK_PRINT (yyss, yyssp);
  1982. }
  1983. if (yyn == YYFINAL)
  1984. YYACCEPT;
  1985. *++yyvsp = yylval;
  1986. yyerror_range[1] = yylloc;
  1987. /* Using YYLLOC is tempting, but would change the location of
  1988. the look-ahead. YYLOC is available though. */
  1989. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
  1990. *++yylsp = yyloc;
  1991. /* Shift the error token. */
  1992. YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  1993. yystate = yyn;
  1994. goto yynewstate;
  1995. /*-------------------------------------.
  1996. | yyacceptlab -- YYACCEPT comes here. |
  1997. `-------------------------------------*/
  1998. yyacceptlab:
  1999. yyresult = 0;
  2000. goto yyreturn;
  2001. /*-----------------------------------.
  2002. | yyabortlab -- YYABORT comes here. |
  2003. `-----------------------------------*/
  2004. yyabortlab:
  2005. yyresult = 1;
  2006. goto yyreturn;
  2007. #ifndef yyoverflow
  2008. /*-------------------------------------------------.
  2009. | yyexhaustedlab -- memory exhaustion comes here. |
  2010. `-------------------------------------------------*/
  2011. yyexhaustedlab:
  2012. yyerror (YY_("memory exhausted"));
  2013. yyresult = 2;
  2014. /* Fall through. */
  2015. #endif
  2016. yyreturn:
  2017. if (yychar != YYEOF && yychar != YYEMPTY)
  2018. yydestruct ("Cleanup: discarding lookahead",
  2019. yytoken, &yylval, &yylloc);
  2020. /* Do not reclaim the symbols of the rule which action triggered
  2021. this YYABORT or YYACCEPT. */
  2022. YYPOPSTACK (yylen);
  2023. YY_STACK_PRINT (yyss, yyssp);
  2024. while (yyssp != yyss)
  2025. {
  2026. yydestruct ("Cleanup: popping",
  2027. yystos[*yyssp], yyvsp, yylsp);
  2028. YYPOPSTACK (1);
  2029. }
  2030. #ifndef yyoverflow
  2031. if (yyss != yyssa)
  2032. YYSTACK_FREE (yyss);
  2033. #endif
  2034. #if YYERROR_VERBOSE
  2035. if (yymsg != yymsgbuf)
  2036. YYSTACK_FREE (yymsg);
  2037. #endif
  2038. /* Make sure YYID is used. */
  2039. return YYID (yyresult);
  2040. }
  2041. #line 495 "ast_expr2.y"
  2042. static struct expr_node *alloc_expr_node(enum node_type nt)
  2043. {
  2044. struct expr_node *x = calloc(1,sizeof(struct expr_node));
  2045. if (!x) {
  2046. ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n");
  2047. return 0;
  2048. }
  2049. x->type = nt;
  2050. return x;
  2051. }
  2052. static struct val *
  2053. make_number (FP___TYPE i)
  2054. {
  2055. struct val *vp;
  2056. vp = (struct val *) malloc (sizeof (*vp));
  2057. if (vp == NULL) {
  2058. ast_log(LOG_WARNING, "malloc() failed\n");
  2059. return(NULL);
  2060. }
  2061. vp->type = AST_EXPR_number;
  2062. vp->u.i = i;
  2063. return vp;
  2064. }
  2065. static struct val *
  2066. make_str (const char *s)
  2067. {
  2068. struct val *vp;
  2069. size_t i;
  2070. int isint; /* this started out being a test for an integer, but then ended up being a test for a float */
  2071. vp = (struct val *) malloc (sizeof (*vp));
  2072. if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
  2073. ast_log(LOG_WARNING,"malloc() failed\n");
  2074. return(NULL);
  2075. }
  2076. for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
  2077. {
  2078. if (!isdigit(s[i]) && s[i] != '.') {
  2079. isint = 0;
  2080. break;
  2081. }
  2082. }
  2083. if (isint)
  2084. vp->type = AST_EXPR_numeric_string;
  2085. else
  2086. vp->type = AST_EXPR_string;
  2087. return vp;
  2088. }
  2089. static void
  2090. free_value (struct val *vp)
  2091. {
  2092. if (vp==NULL) {
  2093. return;
  2094. }
  2095. if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
  2096. free (vp->u.s);
  2097. free(vp);
  2098. }
  2099. static int
  2100. to_number (struct val *vp)
  2101. {
  2102. FP___TYPE i;
  2103. if (vp == NULL) {
  2104. ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
  2105. return(0);
  2106. }
  2107. if (vp->type == AST_EXPR_number)
  2108. return 1;
  2109. if (vp->type == AST_EXPR_string)
  2110. return 0;
  2111. /* vp->type == AST_EXPR_numeric_string, make it numeric */
  2112. errno = 0;
  2113. i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
  2114. if (errno != 0) {
  2115. ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
  2116. free(vp->u.s);
  2117. vp->u.s = 0;
  2118. return(0);
  2119. }
  2120. free (vp->u.s);
  2121. vp->u.i = i;
  2122. vp->type = AST_EXPR_number;
  2123. return 1;
  2124. }
  2125. static void
  2126. strip_quotes(struct val *vp)
  2127. {
  2128. if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
  2129. return;
  2130. if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
  2131. {
  2132. char *f, *t;
  2133. f = vp->u.s;
  2134. t = vp->u.s;
  2135. while( *f )
  2136. {
  2137. if( *f && *f != '"' )
  2138. *t++ = *f++;
  2139. else
  2140. f++;
  2141. }
  2142. *t = *f;
  2143. }
  2144. }
  2145. static void
  2146. to_string (struct val *vp)
  2147. {
  2148. char *tmp;
  2149. if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
  2150. return;
  2151. tmp = malloc ((size_t)25);
  2152. if (tmp == NULL) {
  2153. ast_log(LOG_WARNING,"malloc() failed\n");
  2154. return;
  2155. }
  2156. sprintf(tmp, FP___PRINTF, vp->u.i);
  2157. vp->type = AST_EXPR_string;
  2158. vp->u.s = tmp;
  2159. }
  2160. static int
  2161. isstring (struct val *vp)
  2162. {
  2163. /* only TRUE if this string is not a valid number */
  2164. return (vp->type == AST_EXPR_string);
  2165. }
  2166. static int
  2167. is_zero_or_null (struct val *vp)
  2168. {
  2169. if (vp->type == AST_EXPR_number) {
  2170. return (vp->u.i == 0);
  2171. } else {
  2172. return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
  2173. }
  2174. /* NOTREACHED */
  2175. }
  2176. #ifdef STANDALONE2
  2177. void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
  2178. {
  2179. va_list vars;
  2180. va_start(vars,fmt);
  2181. printf("LOG: lev:%d file:%s line:%d func: %s ",
  2182. level, file, line, function);
  2183. vprintf(fmt, vars);
  2184. fflush(stdout);
  2185. va_end(vars);
  2186. }
  2187. int main(int argc,char **argv) {
  2188. char s[4096];
  2189. char out[4096];
  2190. FILE *infile;
  2191. if( !argv[1] )
  2192. exit(20);
  2193. if( access(argv[1],F_OK)== 0 )
  2194. {
  2195. int ret;
  2196. infile = fopen(argv[1],"r");
  2197. if( !infile )
  2198. {
  2199. printf("Sorry, couldn't open %s for reading!\n", argv[1]);
  2200. exit(10);
  2201. }
  2202. while( fgets(s,sizeof(s),infile) )
  2203. {
  2204. if( s[strlen(s)-1] == '\n' )
  2205. s[strlen(s)-1] = 0;
  2206. ret = ast_expr(s, out, sizeof(out), NULL);
  2207. printf("Expression: %s Result: [%d] '%s'\n",
  2208. s, ret, out);
  2209. }
  2210. fclose(infile);
  2211. }
  2212. else
  2213. {
  2214. if (ast_expr(argv[1], s, sizeof(s), NULL))
  2215. printf("=====%s======\n",s);
  2216. else
  2217. printf("No result\n");
  2218. }
  2219. return 0;
  2220. }
  2221. #endif
  2222. #undef ast_yyerror
  2223. #define ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
  2224. /* I put the ast_yyerror func in the flex input file,
  2225. because it refers to the buffer state. Best to
  2226. let it access the BUFFER stuff there and not trying
  2227. define all the structs, macros etc. in this file! */
  2228. static void destroy_arglist(struct expr_node *arglist)
  2229. {
  2230. struct expr_node *arglist_next;
  2231. while (arglist)
  2232. {
  2233. arglist_next = arglist->right;
  2234. if (arglist->val)
  2235. free_value(arglist->val);
  2236. arglist->val = 0;
  2237. arglist->right = 0;
  2238. free(arglist);
  2239. arglist = arglist_next;
  2240. }
  2241. }
  2242. #if !defined(STANDALONE) && !defined(STANDALONE2)
  2243. static char *compose_func_args(struct expr_node *arglist)
  2244. {
  2245. struct expr_node *t = arglist;
  2246. char *argbuf;
  2247. int total_len = 0;
  2248. while (t) {
  2249. if (t != arglist)
  2250. total_len += 1; /* for the sep */
  2251. if (t->val) {
  2252. if (t->val->type == AST_EXPR_number)
  2253. total_len += 25; /* worst case */
  2254. else
  2255. total_len += strlen(t->val->u.s);
  2256. }
  2257. t = t->right;
  2258. }
  2259. total_len++; /* for the null */
  2260. ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
  2261. argbuf = malloc(total_len);
  2262. argbuf[0] = 0;
  2263. t = arglist;
  2264. while (t) {
  2265. char numbuf[30];
  2266. if (t != arglist)
  2267. strcat(argbuf,",");
  2268. if (t->val) {
  2269. if (t->val->type == AST_EXPR_number) {
  2270. sprintf(numbuf,FP___PRINTF,t->val->u.i);
  2271. strcat(argbuf,numbuf);
  2272. } else
  2273. strcat(argbuf,t->val->u.s);
  2274. }
  2275. t = t->right;
  2276. }
  2277. ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
  2278. return argbuf;
  2279. }
  2280. static int is_really_num(char *str)
  2281. {
  2282. if ( strspn(str,"-0123456789. ") == strlen(str))
  2283. return 1;
  2284. else
  2285. return 0;
  2286. }
  2287. #endif
  2288. static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
  2289. {
  2290. if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
  2291. {
  2292. struct val *result;
  2293. if (0) {
  2294. #ifdef FUNC_COS
  2295. } else if (strcmp(funcname->u.s,"COS") == 0) {
  2296. if (arglist && !arglist->right && arglist->val){
  2297. to_number(arglist->val);
  2298. result = make_number(FUNC_COS(arglist->val->u.i));
  2299. return result;
  2300. } else {
  2301. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2302. return make_number(0.0);
  2303. }
  2304. #endif
  2305. #ifdef FUNC_SIN
  2306. } else if (strcmp(funcname->u.s,"SIN") == 0) {
  2307. if (arglist && !arglist->right && arglist->val){
  2308. to_number(arglist->val);
  2309. result = make_number(FUNC_SIN(arglist->val->u.i));
  2310. return result;
  2311. } else {
  2312. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2313. return make_number(0.0);
  2314. }
  2315. #endif
  2316. #ifdef FUNC_TAN
  2317. } else if (strcmp(funcname->u.s,"TAN") == 0) {
  2318. if (arglist && !arglist->right && arglist->val){
  2319. to_number(arglist->val);
  2320. result = make_number(FUNC_TAN(arglist->val->u.i));
  2321. return result;
  2322. } else {
  2323. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2324. return make_number(0.0);
  2325. }
  2326. #endif
  2327. #ifdef FUNC_ACOS
  2328. } else if (strcmp(funcname->u.s,"ACOS") == 0) {
  2329. if (arglist && !arglist->right && arglist->val){
  2330. to_number(arglist->val);
  2331. result = make_number(FUNC_ACOS(arglist->val->u.i));
  2332. return result;
  2333. } else {
  2334. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2335. return make_number(0.0);
  2336. }
  2337. #endif
  2338. #ifdef FUNC_ASIN
  2339. } else if (strcmp(funcname->u.s,"ASIN") == 0) {
  2340. if (arglist && !arglist->right && arglist->val){
  2341. to_number(arglist->val);
  2342. result = make_number(FUNC_ASIN(arglist->val->u.i));
  2343. return result;
  2344. } else {
  2345. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2346. return make_number(0.0);
  2347. }
  2348. #endif
  2349. #ifdef FUNC_ATAN
  2350. } else if (strcmp(funcname->u.s,"ATAN") == 0) {
  2351. if (arglist && !arglist->right && arglist->val){
  2352. to_number(arglist->val);
  2353. result = make_number(FUNC_ATAN(arglist->val->u.i));
  2354. return result;
  2355. } else {
  2356. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2357. return make_number(0.0);
  2358. }
  2359. #endif
  2360. #ifdef FUNC_ATAN2
  2361. } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
  2362. if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
  2363. to_number(arglist->val);
  2364. to_number(arglist->right->val);
  2365. result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
  2366. return result;
  2367. } else {
  2368. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2369. return make_number(0.0);
  2370. }
  2371. #endif
  2372. #ifdef FUNC_POW
  2373. } else if (strcmp(funcname->u.s,"POW") == 0) {
  2374. if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
  2375. to_number(arglist->val);
  2376. to_number(arglist->right->val);
  2377. result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
  2378. return result;
  2379. } else {
  2380. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2381. return make_number(0.0);
  2382. }
  2383. #endif
  2384. #ifdef FUNC_SQRT
  2385. } else if (strcmp(funcname->u.s,"SQRT") == 0) {
  2386. if (arglist && !arglist->right && arglist->val){
  2387. to_number(arglist->val);
  2388. result = make_number(FUNC_SQRT(arglist->val->u.i));
  2389. return result;
  2390. } else {
  2391. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2392. return make_number(0.0);
  2393. }
  2394. #endif
  2395. #ifdef FUNC_FLOOR
  2396. } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
  2397. if (arglist && !arglist->right && arglist->val){
  2398. to_number(arglist->val);
  2399. result = make_number(FUNC_FLOOR(arglist->val->u.i));
  2400. return result;
  2401. } else {
  2402. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2403. return make_number(0.0);
  2404. }
  2405. #endif
  2406. #ifdef FUNC_CEIL
  2407. } else if (strcmp(funcname->u.s,"CEIL") == 0) {
  2408. if (arglist && !arglist->right && arglist->val){
  2409. to_number(arglist->val);
  2410. result = make_number(FUNC_CEIL(arglist->val->u.i));
  2411. return result;
  2412. } else {
  2413. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2414. return make_number(0.0);
  2415. }
  2416. #endif
  2417. #ifdef FUNC_ROUND
  2418. } else if (strcmp(funcname->u.s,"ROUND") == 0) {
  2419. if (arglist && !arglist->right && arglist->val){
  2420. to_number(arglist->val);
  2421. result = make_number(FUNC_ROUND(arglist->val->u.i));
  2422. return result;
  2423. } else {
  2424. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2425. return make_number(0.0);
  2426. }
  2427. #endif /* defined(FUNC_ROUND) */
  2428. #ifdef FUNC_RINT
  2429. } else if (strcmp(funcname->u.s,"RINT") == 0) {
  2430. if (arglist && !arglist->right && arglist->val){
  2431. to_number(arglist->val);
  2432. result = make_number(FUNC_RINT(arglist->val->u.i));
  2433. return result;
  2434. } else {
  2435. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2436. return make_number(0.0);
  2437. }
  2438. #endif
  2439. #ifdef FUNC_TRUNC
  2440. } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
  2441. if (arglist && !arglist->right && arglist->val){
  2442. to_number(arglist->val);
  2443. result = make_number(FUNC_TRUNC(arglist->val->u.i));
  2444. return result;
  2445. } else {
  2446. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2447. return make_number(0.0);
  2448. }
  2449. #endif /* defined(FUNC_TRUNC) */
  2450. #ifdef FUNC_EXP
  2451. } else if (strcmp(funcname->u.s,"EXP") == 0) {
  2452. if (arglist && !arglist->right && arglist->val){
  2453. to_number(arglist->val);
  2454. result = make_number(FUNC_EXP(arglist->val->u.i));
  2455. return result;
  2456. } else {
  2457. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2458. return make_number(0.0);
  2459. }
  2460. #endif
  2461. #ifdef FUNC_EXP2
  2462. } else if (strcmp(funcname->u.s,"EXP2") == 0) {
  2463. if (arglist && !arglist->right && arglist->val){
  2464. to_number(arglist->val);
  2465. result = make_number(FUNC_EXP2(arglist->val->u.i));
  2466. return result;
  2467. } else {
  2468. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2469. return make_number(0.0);
  2470. }
  2471. #endif
  2472. #ifdef FUNC_EXP10
  2473. } else if (strcmp(funcname->u.s,"EXP10") == 0) {
  2474. if (arglist && !arglist->right && arglist->val){
  2475. to_number(arglist->val);
  2476. result = make_number(FUNC_EXP10(arglist->val->u.i));
  2477. return result;
  2478. } else {
  2479. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2480. return make_number(0.0);
  2481. }
  2482. #endif
  2483. #ifdef FUNC_LOG
  2484. } else if (strcmp(funcname->u.s,"LOG") == 0) {
  2485. if (arglist && !arglist->right && arglist->val){
  2486. to_number(arglist->val);
  2487. result = make_number(FUNC_LOG(arglist->val->u.i));
  2488. return result;
  2489. } else {
  2490. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2491. return make_number(0.0);
  2492. }
  2493. #endif
  2494. #ifdef FUNC_LOG2
  2495. } else if (strcmp(funcname->u.s,"LOG2") == 0) {
  2496. if (arglist && !arglist->right && arglist->val){
  2497. to_number(arglist->val);
  2498. result = make_number(FUNC_LOG2(arglist->val->u.i));
  2499. return result;
  2500. } else {
  2501. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2502. return make_number(0.0);
  2503. }
  2504. #endif
  2505. #ifdef FUNC_LOG10
  2506. } else if (strcmp(funcname->u.s,"LOG10") == 0) {
  2507. if (arglist && !arglist->right && arglist->val){
  2508. to_number(arglist->val);
  2509. result = make_number(FUNC_LOG10(arglist->val->u.i));
  2510. return result;
  2511. } else {
  2512. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2513. return make_number(0.0);
  2514. }
  2515. #endif
  2516. #ifdef FUNC_REMAINDER
  2517. } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
  2518. if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
  2519. to_number(arglist->val);
  2520. to_number(arglist->right->val);
  2521. result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
  2522. return result;
  2523. } else {
  2524. ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
  2525. return make_number(0.0);
  2526. }
  2527. #endif
  2528. } else {
  2529. /* is this a custom function we should execute and collect the results of? */
  2530. #if !defined(STANDALONE) && !defined(STANDALONE2)
  2531. struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
  2532. if (!chan)
  2533. ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
  2534. if (!f)
  2535. ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
  2536. if (f && chan) {
  2537. if (f->read) {
  2538. char workspace[512];
  2539. char *argbuf = compose_func_args(arglist);
  2540. f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
  2541. free(argbuf);
  2542. if (is_really_num(workspace))
  2543. return make_number(FUNC_STRTOD(workspace,(char **)NULL));
  2544. else
  2545. return make_str(workspace);
  2546. } else {
  2547. ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
  2548. return (make_number ((FP___TYPE)0.0));
  2549. }
  2550. } else {
  2551. ast_log(LOG_ERROR,"Error! '%s' doesn't appear to be an available function!", funcname->u.s);
  2552. return (make_number ((FP___TYPE)0.0));
  2553. }
  2554. #else
  2555. ast_log(LOG_ERROR,"Error! '%s' is not available in the standalone version!", funcname->u.s);
  2556. return (make_number ((FP___TYPE)0.0));
  2557. #endif
  2558. }
  2559. }
  2560. else
  2561. {
  2562. ast_log(LOG_ERROR,"Error! '%s' is not possibly a function name!", funcname->u.s);
  2563. return (make_number ((FP___TYPE)0.0));
  2564. }
  2565. return (make_number ((FP___TYPE)0.0));
  2566. }
  2567. static struct val *
  2568. op_or (struct val *a, struct val *b)
  2569. {
  2570. if (is_zero_or_null (a)) {
  2571. free_value (a);
  2572. return (b);
  2573. } else {
  2574. free_value (b);
  2575. return (a);
  2576. }
  2577. }
  2578. static struct val *
  2579. op_and (struct val *a, struct val *b)
  2580. {
  2581. if (is_zero_or_null (a) || is_zero_or_null (b)) {
  2582. free_value (a);
  2583. free_value (b);
  2584. return (make_number ((FP___TYPE)0.0));
  2585. } else {
  2586. free_value (b);
  2587. return (a);
  2588. }
  2589. }
  2590. static struct val *
  2591. op_eq (struct val *a, struct val *b)
  2592. {
  2593. struct val *r;
  2594. if (isstring (a) || isstring (b)) {
  2595. to_string (a);
  2596. to_string (b);
  2597. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
  2598. } else {
  2599. #ifdef DEBUG_FOR_CONVERSIONS
  2600. char buffer[2000];
  2601. sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
  2602. #endif
  2603. (void)to_number(a);
  2604. (void)to_number(b);
  2605. #ifdef DEBUG_FOR_CONVERSIONS
  2606. ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
  2607. #endif
  2608. r = make_number ((FP___TYPE)(a->u.i == b->u.i));
  2609. }
  2610. free_value (a);
  2611. free_value (b);
  2612. return r;
  2613. }
  2614. static struct val *
  2615. op_gt (struct val *a, struct val *b)
  2616. {
  2617. struct val *r;
  2618. if (isstring (a) || isstring (b)) {
  2619. to_string (a);
  2620. to_string (b);
  2621. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
  2622. } else {
  2623. (void)to_number(a);
  2624. (void)to_number(b);
  2625. r = make_number ((FP___TYPE)(a->u.i > b->u.i));
  2626. }
  2627. free_value (a);
  2628. free_value (b);
  2629. return r;
  2630. }
  2631. static struct val *
  2632. op_lt (struct val *a, struct val *b)
  2633. {
  2634. struct val *r;
  2635. if (isstring (a) || isstring (b)) {
  2636. to_string (a);
  2637. to_string (b);
  2638. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
  2639. } else {
  2640. (void)to_number(a);
  2641. (void)to_number(b);
  2642. r = make_number ((FP___TYPE)(a->u.i < b->u.i));
  2643. }
  2644. free_value (a);
  2645. free_value (b);
  2646. return r;
  2647. }
  2648. static struct val *
  2649. op_ge (struct val *a, struct val *b)
  2650. {
  2651. struct val *r;
  2652. if (isstring (a) || isstring (b)) {
  2653. to_string (a);
  2654. to_string (b);
  2655. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
  2656. } else {
  2657. (void)to_number(a);
  2658. (void)to_number(b);
  2659. r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
  2660. }
  2661. free_value (a);
  2662. free_value (b);
  2663. return r;
  2664. }
  2665. static struct val *
  2666. op_le (struct val *a, struct val *b)
  2667. {
  2668. struct val *r;
  2669. if (isstring (a) || isstring (b)) {
  2670. to_string (a);
  2671. to_string (b);
  2672. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
  2673. } else {
  2674. (void)to_number(a);
  2675. (void)to_number(b);
  2676. r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
  2677. }
  2678. free_value (a);
  2679. free_value (b);
  2680. return r;
  2681. }
  2682. static struct val *
  2683. op_cond (struct val *a, struct val *b, struct val *c)
  2684. {
  2685. struct val *r;
  2686. if( isstring(a) )
  2687. {
  2688. if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
  2689. {
  2690. free_value(a);
  2691. free_value(c);
  2692. r = b;
  2693. }
  2694. else
  2695. {
  2696. free_value(a);
  2697. free_value(b);
  2698. r = c;
  2699. }
  2700. }
  2701. else
  2702. {
  2703. (void)to_number(a);
  2704. if( a->u.i )
  2705. {
  2706. free_value(a);
  2707. free_value(c);
  2708. r = b;
  2709. }
  2710. else
  2711. {
  2712. free_value(a);
  2713. free_value(b);
  2714. r = c;
  2715. }
  2716. }
  2717. return r;
  2718. }
  2719. static struct val *
  2720. op_ne (struct val *a, struct val *b)
  2721. {
  2722. struct val *r;
  2723. if (isstring (a) || isstring (b)) {
  2724. to_string (a);
  2725. to_string (b);
  2726. r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
  2727. } else {
  2728. (void)to_number(a);
  2729. (void)to_number(b);
  2730. r = make_number ((FP___TYPE)(a->u.i != b->u.i));
  2731. }
  2732. free_value (a);
  2733. free_value (b);
  2734. return r;
  2735. }
  2736. static int
  2737. chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
  2738. {
  2739. /* sum of two positive numbers must be positive */
  2740. if (a > 0 && b > 0 && r <= 0)
  2741. return 1;
  2742. /* sum of two negative numbers must be negative */
  2743. if (a < 0 && b < 0 && r >= 0)
  2744. return 1;
  2745. /* all other cases are OK */
  2746. return 0;
  2747. }
  2748. static struct val *
  2749. op_plus (struct val *a, struct val *b)
  2750. {
  2751. struct val *r;
  2752. if (!to_number (a)) {
  2753. if( !extra_error_message_supplied )
  2754. ast_log(LOG_WARNING,"non-numeric argument\n");
  2755. if (!to_number (b)) {
  2756. free_value(a);
  2757. free_value(b);
  2758. return make_number(0);
  2759. } else {
  2760. free_value(a);
  2761. return (b);
  2762. }
  2763. } else if (!to_number(b)) {
  2764. free_value(b);
  2765. return (a);
  2766. }
  2767. r = make_number (a->u.i + b->u.i);
  2768. if (chk_plus (a->u.i, b->u.i, r->u.i)) {
  2769. ast_log(LOG_WARNING,"overflow\n");
  2770. }
  2771. free_value (a);
  2772. free_value (b);
  2773. return r;
  2774. }
  2775. static int
  2776. chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
  2777. {
  2778. /* special case subtraction of QUAD_MIN */
  2779. if (b == QUAD_MIN) {
  2780. if (a >= 0)
  2781. return 1;
  2782. else
  2783. return 0;
  2784. }
  2785. /* this is allowed for b != QUAD_MIN */
  2786. return chk_plus (a, -b, r);
  2787. }
  2788. static struct val *
  2789. op_minus (struct val *a, struct val *b)
  2790. {
  2791. struct val *r;
  2792. if (!to_number (a)) {
  2793. if( !extra_error_message_supplied )
  2794. ast_log(LOG_WARNING, "non-numeric argument\n");
  2795. if (!to_number (b)) {
  2796. free_value(a);
  2797. free_value(b);
  2798. return make_number(0);
  2799. } else {
  2800. r = make_number(0 - b->u.i);
  2801. free_value(a);
  2802. free_value(b);
  2803. return (r);
  2804. }
  2805. } else if (!to_number(b)) {
  2806. if( !extra_error_message_supplied )
  2807. ast_log(LOG_WARNING, "non-numeric argument\n");
  2808. free_value(b);
  2809. return (a);
  2810. }
  2811. r = make_number (a->u.i - b->u.i);
  2812. if (chk_minus (a->u.i, b->u.i, r->u.i)) {
  2813. ast_log(LOG_WARNING, "overflow\n");
  2814. }
  2815. free_value (a);
  2816. free_value (b);
  2817. return r;
  2818. }
  2819. static struct val *
  2820. op_negate (struct val *a)
  2821. {
  2822. struct val *r;
  2823. if (!to_number (a) ) {
  2824. free_value(a);
  2825. if( !extra_error_message_supplied )
  2826. ast_log(LOG_WARNING, "non-numeric argument\n");
  2827. return make_number(0);
  2828. }
  2829. r = make_number (- a->u.i);
  2830. if (chk_minus (0, a->u.i, r->u.i)) {
  2831. ast_log(LOG_WARNING, "overflow\n");
  2832. }
  2833. free_value (a);
  2834. return r;
  2835. }
  2836. static struct val *
  2837. op_compl (struct val *a)
  2838. {
  2839. int v1 = 1;
  2840. struct val *r;
  2841. if( !a )
  2842. {
  2843. v1 = 0;
  2844. }
  2845. else
  2846. {
  2847. switch( a->type )
  2848. {
  2849. case AST_EXPR_number:
  2850. if( a->u.i == 0 )
  2851. v1 = 0;
  2852. break;
  2853. case AST_EXPR_string:
  2854. if( a->u.s == 0 )
  2855. v1 = 0;
  2856. else
  2857. {
  2858. if( a->u.s[0] == 0 )
  2859. v1 = 0;
  2860. else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
  2861. v1 = 0;
  2862. }
  2863. break;
  2864. case AST_EXPR_numeric_string:
  2865. if( a->u.s == 0 )
  2866. v1 = 0;
  2867. else
  2868. {
  2869. if( a->u.s[0] == 0 )
  2870. v1 = 0;
  2871. else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
  2872. v1 = 0;
  2873. }
  2874. break;
  2875. }
  2876. }
  2877. r = make_number (!v1);
  2878. free_value (a);
  2879. return r;
  2880. }
  2881. static int
  2882. chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r)
  2883. {
  2884. /* special case: first operand is 0, no overflow possible */
  2885. if (a == 0)
  2886. return 0;
  2887. /* cerify that result of division matches second operand */
  2888. if (r / a != b)
  2889. return 1;
  2890. return 0;
  2891. }
  2892. static struct val *
  2893. op_times (struct val *a, struct val *b)
  2894. {
  2895. struct val *r;
  2896. if (!to_number (a) || !to_number (b)) {
  2897. free_value(a);
  2898. free_value(b);
  2899. if( !extra_error_message_supplied )
  2900. ast_log(LOG_WARNING, "non-numeric argument\n");
  2901. return(make_number(0));
  2902. }
  2903. r = make_number (a->u.i * b->u.i);
  2904. if (chk_times (a->u.i, b->u.i, r->u.i)) {
  2905. ast_log(LOG_WARNING, "overflow\n");
  2906. }
  2907. free_value (a);
  2908. free_value (b);
  2909. return (r);
  2910. }
  2911. static int
  2912. chk_div (FP___TYPE a, FP___TYPE b)
  2913. {
  2914. /* div by zero has been taken care of before */
  2915. /* only QUAD_MIN / -1 causes overflow */
  2916. if (a == QUAD_MIN && b == -1)
  2917. return 1;
  2918. /* everything else is OK */
  2919. return 0;
  2920. }
  2921. static struct val *
  2922. op_div (struct val *a, struct val *b)
  2923. {
  2924. struct val *r;
  2925. if (!to_number (a)) {
  2926. free_value(a);
  2927. free_value(b);
  2928. if( !extra_error_message_supplied )
  2929. ast_log(LOG_WARNING, "non-numeric argument\n");
  2930. return make_number(0);
  2931. } else if (!to_number (b)) {
  2932. free_value(a);
  2933. free_value(b);
  2934. if( !extra_error_message_supplied )
  2935. ast_log(LOG_WARNING, "non-numeric argument\n");
  2936. return make_number(INT_MAX);
  2937. }
  2938. if (b->u.i == 0) {
  2939. ast_log(LOG_WARNING, "division by zero\n");
  2940. free_value(a);
  2941. free_value(b);
  2942. return make_number(INT_MAX);
  2943. }
  2944. r = make_number (a->u.i / b->u.i);
  2945. if (chk_div (a->u.i, b->u.i)) {
  2946. ast_log(LOG_WARNING, "overflow\n");
  2947. }
  2948. free_value (a);
  2949. free_value (b);
  2950. return r;
  2951. }
  2952. static struct val *
  2953. op_rem (struct val *a, struct val *b)
  2954. {
  2955. struct val *r;
  2956. if (!to_number (a) || !to_number (b)) {
  2957. if( !extra_error_message_supplied )
  2958. ast_log(LOG_WARNING, "non-numeric argument\n");
  2959. free_value(a);
  2960. free_value(b);
  2961. return make_number(0);
  2962. }
  2963. if (b->u.i == 0) {
  2964. ast_log(LOG_WARNING, "div by zero\n");
  2965. free_value(a);
  2966. return(b);
  2967. }
  2968. r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
  2969. /* chk_rem necessary ??? */
  2970. free_value (a);
  2971. free_value (b);
  2972. return r;
  2973. }
  2974. static struct val *
  2975. op_colon (struct val *a, struct val *b)
  2976. {
  2977. regex_t rp;
  2978. regmatch_t rm[2];
  2979. char errbuf[256];
  2980. int eval;
  2981. struct val *v;
  2982. /* coerce to both arguments to strings */
  2983. to_string(a);
  2984. to_string(b);
  2985. /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
  2986. strip_quotes(a);
  2987. strip_quotes(b);
  2988. /* compile regular expression */
  2989. if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
  2990. regerror (eval, &rp, errbuf, sizeof(errbuf));
  2991. ast_log(LOG_WARNING,"regcomp() error : %s",errbuf);
  2992. free_value(a);
  2993. free_value(b);
  2994. return make_str("");
  2995. }
  2996. /* compare string against pattern */
  2997. /* remember that patterns are anchored to the beginning of the line */
  2998. if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
  2999. if (rm[1].rm_so >= 0) {
  3000. *(a->u.s + rm[1].rm_eo) = '\0';
  3001. v = make_str (a->u.s + rm[1].rm_so);
  3002. } else {
  3003. v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
  3004. }
  3005. } else {
  3006. if (rp.re_nsub == 0) {
  3007. v = make_number ((FP___TYPE)0);
  3008. } else {
  3009. v = make_str ("");
  3010. }
  3011. }
  3012. /* free arguments and pattern buffer */
  3013. free_value (a);
  3014. free_value (b);
  3015. regfree (&rp);
  3016. return v;
  3017. }
  3018. static struct val *
  3019. op_eqtilde (struct val *a, struct val *b)
  3020. {
  3021. regex_t rp;
  3022. regmatch_t rm[2];
  3023. char errbuf[256];
  3024. int eval;
  3025. struct val *v;
  3026. /* coerce to both arguments to strings */
  3027. to_string(a);
  3028. to_string(b);
  3029. /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
  3030. strip_quotes(a);
  3031. strip_quotes(b);
  3032. /* compile regular expression */
  3033. if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
  3034. regerror (eval, &rp, errbuf, sizeof(errbuf));
  3035. ast_log(LOG_WARNING,"regcomp() error : %s",errbuf);
  3036. free_value(a);
  3037. free_value(b);
  3038. return make_str("");
  3039. }
  3040. /* compare string against pattern */
  3041. /* remember that patterns are anchored to the beginning of the line */
  3042. if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
  3043. if (rm[1].rm_so >= 0) {
  3044. *(a->u.s + rm[1].rm_eo) = '\0';
  3045. v = make_str (a->u.s + rm[1].rm_so);
  3046. } else {
  3047. v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
  3048. }
  3049. } else {
  3050. if (rp.re_nsub == 0) {
  3051. v = make_number ((FP___TYPE)0.0);
  3052. } else {
  3053. v = make_str ("");
  3054. }
  3055. }
  3056. /* free arguments and pattern buffer */
  3057. free_value (a);
  3058. free_value (b);
  3059. regfree (&rp);
  3060. return v;
  3061. }
  3062. static struct val * /* this is a string concat operator */
  3063. op_tildetilde (struct val *a, struct val *b)
  3064. {
  3065. struct val *v;
  3066. char *vs;
  3067. /* coerce to both arguments to strings */
  3068. to_string(a);
  3069. to_string(b);
  3070. /* strip double quotes from both -- */
  3071. strip_quotes(a);
  3072. strip_quotes(b);
  3073. vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
  3074. strcpy(vs,a->u.s);
  3075. strcat(vs,b->u.s);
  3076. v = make_str(vs);
  3077. /* free arguments */
  3078. free_value(a);
  3079. free_value(b);
  3080. return v;
  3081. }