No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

analyse_syntaxique.tab.c 66KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017
  1. /* A Bison parser, made by GNU Bison 3.0.4. */
  2. /* Bison implementation for Yacc-like parsers in C
  3. Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. /* As a special exception, you may create a larger work that contains
  15. part or all of the Bison parser skeleton and distribute that work
  16. under terms of your choice, so long as that work isn't itself a
  17. parser generator using the skeleton or a modified version thereof
  18. as a parser skeleton. Alternatively, if you modify or redistribute
  19. the parser skeleton itself, you may (at your option) remove this
  20. special exception, which will cause the skeleton and the resulting
  21. Bison output files to be licensed under the GNU General Public
  22. License without this special exception.
  23. This special exception was added by the Free Software Foundation in
  24. version 2.2 of Bison. */
  25. /* C LALR(1) parser skeleton written by Richard Stallman, by
  26. simplifying the original so-called "semantic" parser. */
  27. /* All symbols defined below should begin with yy or YY, to avoid
  28. infringing on user name space. This should be done even for local
  29. variables, as they might otherwise be expanded by user macros.
  30. There are some unavoidable exceptions within include files to
  31. define necessary library symbols; they are noted "INFRINGES ON
  32. USER NAME SPACE" below. */
  33. /* Identify Bison output. */
  34. #define YYBISON 1
  35. /* Bison version. */
  36. #define YYBISON_VERSION "3.0.4"
  37. /* Skeleton name. */
  38. #define YYSKELETON_NAME "yacc.c"
  39. /* Pure parsers. */
  40. #define YYPURE 0
  41. /* Push parsers. */
  42. #define YYPUSH 0
  43. /* Pull parsers. */
  44. #define YYPULL 1
  45. /* Copy the first part of user declarations. */
  46. #line 67 "analyse_syntaxique.tab.c" /* yacc.c:339 */
  47. # ifndef YY_NULLPTR
  48. # if defined __cplusplus && 201103L <= __cplusplus
  49. # define YY_NULLPTR nullptr
  50. # else
  51. # define YY_NULLPTR 0
  52. # endif
  53. # endif
  54. /* Enabling verbose error messages. */
  55. #ifdef YYERROR_VERBOSE
  56. # undef YYERROR_VERBOSE
  57. # define YYERROR_VERBOSE 1
  58. #else
  59. # define YYERROR_VERBOSE 0
  60. #endif
  61. /* In a future release of Bison, this section will be replaced
  62. by #include "analyse_syntaxique.tab.h". */
  63. #ifndef YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED
  64. # define YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED
  65. /* Debug traces. */
  66. #ifndef YYDEBUG
  67. # define YYDEBUG 1
  68. #endif
  69. #if YYDEBUG
  70. extern int yydebug;
  71. #endif
  72. /* Token type. */
  73. #ifndef YYTOKENTYPE
  74. # define YYTOKENTYPE
  75. enum yytokentype
  76. {
  77. tENTIER = 258,
  78. tENTIEREXP = 259,
  79. tADD = 260,
  80. tSUB = 261,
  81. tMUL = 262,
  82. tDIV = 263,
  83. tPO = 264,
  84. tPF = 265,
  85. tAO = 266,
  86. tAF = 267,
  87. tERROR = 268,
  88. tAPPERSAND = 269,
  89. tPV = 270,
  90. tVIRGULE = 271,
  91. tAFFECTATION = 272,
  92. tEGAL = 273,
  93. tDIFF = 274,
  94. tLT = 275,
  95. tGT = 276,
  96. tGTE = 277,
  97. tLTE = 278,
  98. tMAIN = 279,
  99. tINT = 280,
  100. tPRINT = 281,
  101. tRETURN = 282,
  102. tOR = 283,
  103. tAND = 284,
  104. tIF = 285,
  105. tELSE = 286,
  106. tWHILE = 287,
  107. tCONST = 288,
  108. tVAR = 289,
  109. tNOT = 290
  110. };
  111. #endif
  112. /* Value type. */
  113. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  114. union YYSTYPE
  115. {
  116. #line 1 "analyse_syntaxique.y" /* yacc.c:355 */
  117. int nombre;
  118. char id[30];
  119. #line 148 "analyse_syntaxique.tab.c" /* yacc.c:355 */
  120. };
  121. typedef union YYSTYPE YYSTYPE;
  122. # define YYSTYPE_IS_TRIVIAL 1
  123. # define YYSTYPE_IS_DECLARED 1
  124. #endif
  125. extern YYSTYPE yylval;
  126. int yyparse (void);
  127. #endif /* !YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED */
  128. /* Copy the second part of user declarations. */
  129. #line 6 "analyse_syntaxique.y" /* yacc.c:358 */
  130. #include <stdio.h>
  131. #include "table_symboles.h"
  132. #include "table_fonctions.h"
  133. #include "gen_assembleur.h"
  134. enum Initialised_Variable init;
  135. enum Symbole_Type type;
  136. enum Return_Type return_type;
  137. Table_Symboles table;
  138. Table_Fonctions table_fonctions;
  139. instructions_array array;
  140. int whileCondition;
  141. int return_value;
  142. #line 180 "analyse_syntaxique.tab.c" /* yacc.c:358 */
  143. #ifdef short
  144. # undef short
  145. #endif
  146. #ifdef YYTYPE_UINT8
  147. typedef YYTYPE_UINT8 yytype_uint8;
  148. #else
  149. typedef unsigned char yytype_uint8;
  150. #endif
  151. #ifdef YYTYPE_INT8
  152. typedef YYTYPE_INT8 yytype_int8;
  153. #else
  154. typedef signed char yytype_int8;
  155. #endif
  156. #ifdef YYTYPE_UINT16
  157. typedef YYTYPE_UINT16 yytype_uint16;
  158. #else
  159. typedef unsigned short int yytype_uint16;
  160. #endif
  161. #ifdef YYTYPE_INT16
  162. typedef YYTYPE_INT16 yytype_int16;
  163. #else
  164. typedef short int yytype_int16;
  165. #endif
  166. #ifndef YYSIZE_T
  167. # ifdef __SIZE_TYPE__
  168. # define YYSIZE_T __SIZE_TYPE__
  169. # elif defined size_t
  170. # define YYSIZE_T size_t
  171. # elif ! defined YYSIZE_T
  172. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  173. # define YYSIZE_T size_t
  174. # else
  175. # define YYSIZE_T unsigned int
  176. # endif
  177. #endif
  178. #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
  179. #ifndef YY_
  180. # if defined YYENABLE_NLS && YYENABLE_NLS
  181. # if ENABLE_NLS
  182. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  183. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  184. # endif
  185. # endif
  186. # ifndef YY_
  187. # define YY_(Msgid) Msgid
  188. # endif
  189. #endif
  190. #ifndef YY_ATTRIBUTE
  191. # if (defined __GNUC__ \
  192. && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
  193. || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
  194. # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
  195. # else
  196. # define YY_ATTRIBUTE(Spec) /* empty */
  197. # endif
  198. #endif
  199. #ifndef YY_ATTRIBUTE_PURE
  200. # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
  201. #endif
  202. #ifndef YY_ATTRIBUTE_UNUSED
  203. # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
  204. #endif
  205. #if !defined _Noreturn \
  206. && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
  207. # if defined _MSC_VER && 1200 <= _MSC_VER
  208. # define _Noreturn __declspec (noreturn)
  209. # else
  210. # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
  211. # endif
  212. #endif
  213. /* Suppress unused-variable warnings by "using" E. */
  214. #if ! defined lint || defined __GNUC__
  215. # define YYUSE(E) ((void) (E))
  216. #else
  217. # define YYUSE(E) /* empty */
  218. #endif
  219. #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  220. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  221. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  222. _Pragma ("GCC diagnostic push") \
  223. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
  224. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  225. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  226. _Pragma ("GCC diagnostic pop")
  227. #else
  228. # define YY_INITIAL_VALUE(Value) Value
  229. #endif
  230. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  231. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  232. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  233. #endif
  234. #ifndef YY_INITIAL_VALUE
  235. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  236. #endif
  237. #if ! defined yyoverflow || YYERROR_VERBOSE
  238. /* The parser invokes alloca or malloc; define the necessary symbols. */
  239. # ifdef YYSTACK_USE_ALLOCA
  240. # if YYSTACK_USE_ALLOCA
  241. # ifdef __GNUC__
  242. # define YYSTACK_ALLOC __builtin_alloca
  243. # elif defined __BUILTIN_VA_ARG_INCR
  244. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  245. # elif defined _AIX
  246. # define YYSTACK_ALLOC __alloca
  247. # elif defined _MSC_VER
  248. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  249. # define alloca _alloca
  250. # else
  251. # define YYSTACK_ALLOC alloca
  252. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  253. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  254. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  255. # ifndef EXIT_SUCCESS
  256. # define EXIT_SUCCESS 0
  257. # endif
  258. # endif
  259. # endif
  260. # endif
  261. # endif
  262. # ifdef YYSTACK_ALLOC
  263. /* Pacify GCC's 'empty if-body' warning. */
  264. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  265. # ifndef YYSTACK_ALLOC_MAXIMUM
  266. /* The OS might guarantee only one guard page at the bottom of the stack,
  267. and a page size can be as small as 4096 bytes. So we cannot safely
  268. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  269. to allow for a few compiler-allocated temporary stack slots. */
  270. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  271. # endif
  272. # else
  273. # define YYSTACK_ALLOC YYMALLOC
  274. # define YYSTACK_FREE YYFREE
  275. # ifndef YYSTACK_ALLOC_MAXIMUM
  276. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  277. # endif
  278. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  279. && ! ((defined YYMALLOC || defined malloc) \
  280. && (defined YYFREE || defined free)))
  281. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  282. # ifndef EXIT_SUCCESS
  283. # define EXIT_SUCCESS 0
  284. # endif
  285. # endif
  286. # ifndef YYMALLOC
  287. # define YYMALLOC malloc
  288. # if ! defined malloc && ! defined EXIT_SUCCESS
  289. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  290. # endif
  291. # endif
  292. # ifndef YYFREE
  293. # define YYFREE free
  294. # if ! defined free && ! defined EXIT_SUCCESS
  295. void free (void *); /* INFRINGES ON USER NAME SPACE */
  296. # endif
  297. # endif
  298. # endif
  299. #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
  300. #if (! defined yyoverflow \
  301. && (! defined __cplusplus \
  302. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  303. /* A type that is properly aligned for any stack member. */
  304. union yyalloc
  305. {
  306. yytype_int16 yyss_alloc;
  307. YYSTYPE yyvs_alloc;
  308. };
  309. /* The size of the maximum gap between one aligned stack and the next. */
  310. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  311. /* The size of an array large to enough to hold all stacks, each with
  312. N elements. */
  313. # define YYSTACK_BYTES(N) \
  314. ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
  315. + YYSTACK_GAP_MAXIMUM)
  316. # define YYCOPY_NEEDED 1
  317. /* Relocate STACK from its old location to the new one. The
  318. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  319. elements in the stack, and YYPTR gives the new location of the
  320. stack. Advance YYPTR to a properly aligned location for the next
  321. stack. */
  322. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  323. do \
  324. { \
  325. YYSIZE_T yynewbytes; \
  326. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  327. Stack = &yyptr->Stack_alloc; \
  328. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  329. yyptr += yynewbytes / sizeof (*yyptr); \
  330. } \
  331. while (0)
  332. #endif
  333. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  334. /* Copy COUNT objects from SRC to DST. The source and destination do
  335. not overlap. */
  336. # ifndef YYCOPY
  337. # if defined __GNUC__ && 1 < __GNUC__
  338. # define YYCOPY(Dst, Src, Count) \
  339. __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
  340. # else
  341. # define YYCOPY(Dst, Src, Count) \
  342. do \
  343. { \
  344. YYSIZE_T yyi; \
  345. for (yyi = 0; yyi < (Count); yyi++) \
  346. (Dst)[yyi] = (Src)[yyi]; \
  347. } \
  348. while (0)
  349. # endif
  350. # endif
  351. #endif /* !YYCOPY_NEEDED */
  352. /* YYFINAL -- State number of the termination state. */
  353. #define YYFINAL 9
  354. /* YYLAST -- Last index in YYTABLE. */
  355. #define YYLAST 156
  356. /* YYNTOKENS -- Number of terminals. */
  357. #define YYNTOKENS 36
  358. /* YYNNTS -- Number of nonterminals. */
  359. #define YYNNTS 44
  360. /* YYNRULES -- Number of rules. */
  361. #define YYNRULES 83
  362. /* YYNSTATES -- Number of states. */
  363. #define YYNSTATES 156
  364. /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
  365. by yylex, with out-of-bounds checking. */
  366. #define YYUNDEFTOK 2
  367. #define YYMAXUTOK 290
  368. #define YYTRANSLATE(YYX) \
  369. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  370. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  371. as returned by yylex, without out-of-bounds checking. */
  372. static const yytype_uint8 yytranslate[] =
  373. {
  374. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  375. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  376. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  377. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  378. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  379. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  380. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  381. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  382. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  383. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  384. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  385. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  386. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  387. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  388. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  389. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  390. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  391. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  392. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  393. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  394. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  395. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  396. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  397. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  398. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  399. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  400. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  401. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  402. 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
  403. 35
  404. };
  405. #if YYDEBUG
  406. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  407. static const yytype_uint8 yyrline[] =
  408. {
  409. 0, 83, 83, 85, 86, 89, 89, 90, 90, 92,
  410. 93, 95, 96, 98, 100, 101, 103, 104, 107, 109,
  411. 110, 112, 113, 114, 115, 116, 117, 119, 121, 122,
  412. 124, 125, 126, 128, 128, 129, 132, 133, 136, 137,
  413. 138, 139, 140, 141, 142, 143, 149, 150, 151, 154,
  414. 160, 160, 160, 161, 154, 167, 167, 167, 168, 169,
  415. 171, 173, 179, 179, 171, 186, 187, 188, 189, 190,
  416. 191, 192, 193, 194, 195, 197, 197, 204, 205, 206,
  417. 207, 208, 210, 212
  418. };
  419. #endif
  420. #if YYDEBUG || YYERROR_VERBOSE || 0
  421. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  422. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  423. static const char *const yytname[] =
  424. {
  425. "$end", "error", "$undefined", "tENTIER", "tENTIEREXP", "tADD", "tSUB",
  426. "tMUL", "tDIV", "tPO", "tPF", "tAO", "tAF", "tERROR", "tAPPERSAND",
  427. "tPV", "tVIRGULE", "tAFFECTATION", "tEGAL", "tDIFF", "tLT", "tGT",
  428. "tGTE", "tLTE", "tMAIN", "tINT", "tPRINT", "tRETURN", "tOR", "tAND",
  429. "tIF", "tELSE", "tWHILE", "tCONST", "tVAR", "tNOT", "$accept", "C",
  430. "Fonctions", "Main", "$@1", "Fonction", "$@2", "Function_type", "Params",
  431. "Param", "Param_type", "SuiteParams", "Body", "Instructions",
  432. "Instruction", "Decl", "SuiteDecl", "Type", "Valeur", "$@3", "Aff", "E",
  433. "If", "$@4", "$@5", "$@6", "$@7", "$@8", "Else", "$@9", "$@10", "While",
  434. "$@11", "$@12", "$@13", "$@14", "Cond", "Invocation", "$@15", "Args",
  435. "Arg", "SuiteArgs", "Print", "Return", YY_NULLPTR
  436. };
  437. #endif
  438. # ifdef YYPRINT
  439. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  440. (internal) symbol number NUM (which must be that of a token). */
  441. static const yytype_uint16 yytoknum[] =
  442. {
  443. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  444. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  445. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  446. 285, 286, 287, 288, 289, 290
  447. };
  448. # endif
  449. #define YYPACT_NINF -62
  450. #define yypact_value_is_default(Yystate) \
  451. (!!((Yystate) == (-62)))
  452. #define YYTABLE_NINF -34
  453. #define yytable_value_is_error(Yytable_value) \
  454. 0
  455. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  456. STATE-NUM. */
  457. static const yytype_int16 yypact[] =
  458. {
  459. -14, -4, 15, -62, -62, -14, -15, -62, -62, -62,
  460. -62, -62, 12, 25, -1, -1, 30, 34, 39, 22,
  461. 48, -62, 51, -1, -62, -62, 51, 50, -62, 39,
  462. -62, 27, 52, 64, 68, 70, 47, 0, 66, 50,
  463. -62, 62, -62, -62, -62, 82, -62, -62, 83, -62,
  464. 29, 19, -62, -62, -62, 29, 29, 87, -62, 90,
  465. 85, -62, 29, -62, 29, 74, 29, 76, 102, 84,
  466. -62, 19, 98, 105, 19, 29, 59, 63, -62, 95,
  467. 62, 107, 80, -2, -62, 123, -62, 29, 29, 29,
  468. 29, 108, -62, 29, 29, 29, 29, 29, 29, 29,
  469. 29, -62, 114, 129, 122, 124, -62, -62, 29, 85,
  470. -62, -62, -62, 23, -2, 130, -62, -62, 129, 129,
  471. 129, 129, 129, 129, 129, 129, 128, -62, -62, 29,
  472. -62, 129, -62, -62, 131, 124, 50, -62, -62, -62,
  473. 50, 132, 133, -62, -62, -62, -62, 110, -7, -62,
  474. -62, -62, 50, 134, -62, -62
  475. };
  476. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  477. Performed when YYTABLE does not specify something else to do. Zero
  478. means the default is an error. */
  479. static const yytype_uint8 yydefact[] =
  480. {
  481. 0, 9, 0, 2, 3, 0, 0, 10, 5, 1,
  482. 4, 7, 0, 0, 11, 11, 14, 0, 17, 0,
  483. 0, 15, 0, 0, 12, 13, 0, 20, 6, 17,
  484. 8, 0, 30, 0, 0, 0, 0, 0, 0, 20,
  485. 25, 0, 21, 22, 23, 0, 24, 16, 0, 32,
  486. 0, 0, 60, 31, 75, 0, 0, 0, 19, 35,
  487. 29, 26, 0, 38, 0, 0, 0, 0, 39, 0,
  488. 45, 0, 74, 0, 0, 78, 0, 0, 18, 0,
  489. 0, 0, 0, 44, 48, 0, 47, 0, 0, 0,
  490. 0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
  491. 0, 49, 0, 79, 0, 81, 36, 83, 0, 29,
  492. 27, 37, 46, 40, 42, 41, 43, 82, 65, 66,
  493. 67, 68, 70, 69, 72, 71, 0, 61, 76, 0,
  494. 77, 34, 28, 50, 0, 81, 20, 62, 80, 51,
  495. 20, 0, 0, 52, 63, 53, 64, 58, 0, 54,
  496. 55, 59, 20, 0, 56, 57
  497. };
  498. /* YYPGOTO[NTERM-NUM]. */
  499. static const yytype_int16 yypgoto[] =
  500. {
  501. -62, -62, 138, -62, -62, -62, -62, -62, 135, 125,
  502. -62, 118, 126, -38, -62, -62, 40, -62, 71, -62,
  503. -62, -48, 5, -62, -62, -62, -62, -62, -62, -62,
  504. -62, -62, -62, -62, -62, -62, -61, -27, -62, -62,
  505. 26, 21, -62, -62
  506. };
  507. /* YYDEFGOTO[NTERM-NUM]. */
  508. static const yytype_int16 yydefgoto[] =
  509. {
  510. -1, 2, 3, 4, 12, 5, 13, 6, 17, 18,
  511. 19, 24, 28, 38, 39, 40, 81, 41, 60, 79,
  512. 42, 72, 43, 126, 136, 141, 145, 147, 149, 152,
  513. 155, 44, 74, 134, 140, 146, 73, 70, 75, 104,
  514. 105, 130, 46, 57
  515. };
  516. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  517. positive, shift that token. If negative, reduce the rule whose
  518. number is the opposite. If YYTABLE_NINF, syntax error. */
  519. static const yytype_int16 yytable[] =
  520. {
  521. 45, 58, 69, 7, 150, 89, 90, 76, 77, 54,
  522. 92, 1, 45, 102, 82, 9, 83, 55, 85, 11,
  523. 8, 14, 63, 34, 16, 64, 65, 103, 66, 88,
  524. 89, 90, 63, 67, 15, 64, 65, 21, 66, 113,
  525. 114, 115, 116, 67, 22, 118, 119, 120, 121, 122,
  526. 123, 124, 125, 68, 71, 23, 25, 31, 26, 49,
  527. 131, 48, 27, 68, 87, 88, 89, 90, 87, 88,
  528. 89, 90, 53, 50, 106, 32, 33, 51, 107, 52,
  529. 34, 103, 35, 36, 37, 87, 88, 89, 90, 87,
  530. 88, 89, 90, 56, 91, 111, 59, 61, 139, 78,
  531. 62, 80, 142, 87, 88, 89, 90, -33, 84, 45,
  532. 86, 54, 108, 45, 153, 101, 93, 94, 95, 96,
  533. 97, 98, 110, 117, 127, 45, 99, 100, 87, 88,
  534. 89, 90, 128, 112, 87, 88, 89, 90, 90, 133,
  535. 129, 148, 137, 10, 143, 144, 154, 47, 29, 132,
  536. 20, 109, 30, 151, 0, 135, 138
  537. };
  538. static const yytype_int16 yycheck[] =
  539. {
  540. 27, 39, 50, 7, 11, 7, 8, 55, 56, 9,
  541. 71, 25, 39, 74, 62, 0, 64, 17, 66, 34,
  542. 24, 9, 3, 30, 25, 6, 7, 75, 9, 6,
  543. 7, 8, 3, 14, 9, 6, 7, 7, 9, 87,
  544. 88, 89, 90, 14, 10, 93, 94, 95, 96, 97,
  545. 98, 99, 100, 34, 35, 16, 34, 7, 10, 7,
  546. 108, 34, 11, 34, 5, 6, 7, 8, 5, 6,
  547. 7, 8, 25, 9, 15, 25, 26, 9, 15, 9,
  548. 30, 129, 32, 33, 34, 5, 6, 7, 8, 5,
  549. 6, 7, 8, 27, 10, 15, 34, 15, 136, 12,
  550. 17, 16, 140, 5, 6, 7, 8, 17, 34, 136,
  551. 34, 9, 17, 140, 152, 10, 18, 19, 20, 21,
  552. 22, 23, 15, 15, 10, 152, 28, 29, 5, 6,
  553. 7, 8, 10, 10, 5, 6, 7, 8, 8, 11,
  554. 16, 31, 11, 5, 12, 12, 12, 29, 23, 109,
  555. 15, 80, 26, 148, -1, 129, 135
  556. };
  557. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  558. symbol of state STATE-NUM. */
  559. static const yytype_uint8 yystos[] =
  560. {
  561. 0, 25, 37, 38, 39, 41, 43, 7, 24, 0,
  562. 38, 34, 40, 42, 9, 9, 25, 44, 45, 46,
  563. 44, 7, 10, 16, 47, 34, 10, 11, 48, 45,
  564. 48, 7, 25, 26, 30, 32, 33, 34, 49, 50,
  565. 51, 53, 56, 58, 67, 73, 78, 47, 34, 7,
  566. 9, 9, 9, 25, 9, 17, 27, 79, 49, 34,
  567. 54, 15, 17, 3, 6, 7, 9, 14, 34, 57,
  568. 73, 35, 57, 72, 68, 74, 57, 57, 12, 55,
  569. 16, 52, 57, 57, 34, 57, 34, 5, 6, 7,
  570. 8, 10, 72, 18, 19, 20, 21, 22, 23, 28,
  571. 29, 10, 72, 57, 75, 76, 15, 15, 17, 54,
  572. 15, 15, 10, 57, 57, 57, 57, 15, 57, 57,
  573. 57, 57, 57, 57, 57, 57, 59, 10, 10, 16,
  574. 77, 57, 52, 11, 69, 76, 60, 11, 77, 49,
  575. 70, 61, 49, 12, 12, 62, 71, 63, 31, 64,
  576. 11, 58, 65, 49, 12, 66
  577. };
  578. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  579. static const yytype_uint8 yyr1[] =
  580. {
  581. 0, 36, 37, 38, 38, 40, 39, 42, 41, 43,
  582. 43, 44, 44, 45, 46, 46, 47, 47, 48, 49,
  583. 49, 50, 50, 50, 50, 50, 50, 51, 52, 52,
  584. 53, 53, 53, 55, 54, 54, 56, 56, 57, 57,
  585. 57, 57, 57, 57, 57, 57, 57, 57, 57, 59,
  586. 60, 61, 62, 63, 58, 65, 66, 64, 64, 64,
  587. 68, 69, 70, 71, 67, 72, 72, 72, 72, 72,
  588. 72, 72, 72, 72, 72, 74, 73, 75, 75, 76,
  589. 77, 77, 78, 79
  590. };
  591. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  592. static const yytype_uint8 yyr2[] =
  593. {
  594. 0, 2, 1, 1, 2, 0, 7, 0, 7, 1,
  595. 2, 0, 2, 2, 1, 2, 3, 0, 4, 2,
  596. 0, 1, 1, 1, 1, 1, 2, 4, 3, 0,
  597. 1, 2, 2, 0, 4, 1, 4, 5, 1, 1,
  598. 3, 3, 3, 3, 2, 1, 3, 2, 2, 0,
  599. 0, 0, 0, 0, 13, 0, 0, 6, 0, 2,
  600. 0, 0, 0, 0, 11, 3, 3, 3, 3, 3,
  601. 3, 3, 3, 2, 1, 0, 5, 2, 0, 1,
  602. 3, 0, 5, 3
  603. };
  604. #define yyerrok (yyerrstatus = 0)
  605. #define yyclearin (yychar = YYEMPTY)
  606. #define YYEMPTY (-2)
  607. #define YYEOF 0
  608. #define YYACCEPT goto yyacceptlab
  609. #define YYABORT goto yyabortlab
  610. #define YYERROR goto yyerrorlab
  611. #define YYRECOVERING() (!!yyerrstatus)
  612. #define YYBACKUP(Token, Value) \
  613. do \
  614. if (yychar == YYEMPTY) \
  615. { \
  616. yychar = (Token); \
  617. yylval = (Value); \
  618. YYPOPSTACK (yylen); \
  619. yystate = *yyssp; \
  620. goto yybackup; \
  621. } \
  622. else \
  623. { \
  624. yyerror (YY_("syntax error: cannot back up")); \
  625. YYERROR; \
  626. } \
  627. while (0)
  628. /* Error token number */
  629. #define YYTERROR 1
  630. #define YYERRCODE 256
  631. /* Enable debugging if requested. */
  632. #if YYDEBUG
  633. # ifndef YYFPRINTF
  634. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  635. # define YYFPRINTF fprintf
  636. # endif
  637. # define YYDPRINTF(Args) \
  638. do { \
  639. if (yydebug) \
  640. YYFPRINTF Args; \
  641. } while (0)
  642. /* This macro is provided for backward compatibility. */
  643. #ifndef YY_LOCATION_PRINT
  644. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  645. #endif
  646. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  647. do { \
  648. if (yydebug) \
  649. { \
  650. YYFPRINTF (stderr, "%s ", Title); \
  651. yy_symbol_print (stderr, \
  652. Type, Value); \
  653. YYFPRINTF (stderr, "\n"); \
  654. } \
  655. } while (0)
  656. /*----------------------------------------.
  657. | Print this symbol's value on YYOUTPUT. |
  658. `----------------------------------------*/
  659. static void
  660. yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  661. {
  662. FILE *yyo = yyoutput;
  663. YYUSE (yyo);
  664. if (!yyvaluep)
  665. return;
  666. # ifdef YYPRINT
  667. if (yytype < YYNTOKENS)
  668. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  669. # endif
  670. YYUSE (yytype);
  671. }
  672. /*--------------------------------.
  673. | Print this symbol on YYOUTPUT. |
  674. `--------------------------------*/
  675. static void
  676. yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  677. {
  678. YYFPRINTF (yyoutput, "%s %s (",
  679. yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
  680. yy_symbol_value_print (yyoutput, yytype, yyvaluep);
  681. YYFPRINTF (yyoutput, ")");
  682. }
  683. /*------------------------------------------------------------------.
  684. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  685. | TOP (included). |
  686. `------------------------------------------------------------------*/
  687. static void
  688. yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
  689. {
  690. YYFPRINTF (stderr, "Stack now");
  691. for (; yybottom <= yytop; yybottom++)
  692. {
  693. int yybot = *yybottom;
  694. YYFPRINTF (stderr, " %d", yybot);
  695. }
  696. YYFPRINTF (stderr, "\n");
  697. }
  698. # define YY_STACK_PRINT(Bottom, Top) \
  699. do { \
  700. if (yydebug) \
  701. yy_stack_print ((Bottom), (Top)); \
  702. } while (0)
  703. /*------------------------------------------------.
  704. | Report that the YYRULE is going to be reduced. |
  705. `------------------------------------------------*/
  706. static void
  707. yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
  708. {
  709. unsigned long int yylno = yyrline[yyrule];
  710. int yynrhs = yyr2[yyrule];
  711. int yyi;
  712. YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
  713. yyrule - 1, yylno);
  714. /* The symbols being reduced. */
  715. for (yyi = 0; yyi < yynrhs; yyi++)
  716. {
  717. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  718. yy_symbol_print (stderr,
  719. yystos[yyssp[yyi + 1 - yynrhs]],
  720. &(yyvsp[(yyi + 1) - (yynrhs)])
  721. );
  722. YYFPRINTF (stderr, "\n");
  723. }
  724. }
  725. # define YY_REDUCE_PRINT(Rule) \
  726. do { \
  727. if (yydebug) \
  728. yy_reduce_print (yyssp, yyvsp, Rule); \
  729. } while (0)
  730. /* Nonzero means print parse trace. It is left uninitialized so that
  731. multiple parsers can coexist. */
  732. int yydebug;
  733. #else /* !YYDEBUG */
  734. # define YYDPRINTF(Args)
  735. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  736. # define YY_STACK_PRINT(Bottom, Top)
  737. # define YY_REDUCE_PRINT(Rule)
  738. #endif /* !YYDEBUG */
  739. /* YYINITDEPTH -- initial size of the parser's stacks. */
  740. #ifndef YYINITDEPTH
  741. # define YYINITDEPTH 200
  742. #endif
  743. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  744. if the built-in stack extension method is used).
  745. Do not make this value too large; the results are undefined if
  746. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  747. evaluated with infinite-precision integer arithmetic. */
  748. #ifndef YYMAXDEPTH
  749. # define YYMAXDEPTH 10000
  750. #endif
  751. #if YYERROR_VERBOSE
  752. # ifndef yystrlen
  753. # if defined __GLIBC__ && defined _STRING_H
  754. # define yystrlen strlen
  755. # else
  756. /* Return the length of YYSTR. */
  757. static YYSIZE_T
  758. yystrlen (const char *yystr)
  759. {
  760. YYSIZE_T yylen;
  761. for (yylen = 0; yystr[yylen]; yylen++)
  762. continue;
  763. return yylen;
  764. }
  765. # endif
  766. # endif
  767. # ifndef yystpcpy
  768. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  769. # define yystpcpy stpcpy
  770. # else
  771. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  772. YYDEST. */
  773. static char *
  774. yystpcpy (char *yydest, const char *yysrc)
  775. {
  776. char *yyd = yydest;
  777. const char *yys = yysrc;
  778. while ((*yyd++ = *yys++) != '\0')
  779. continue;
  780. return yyd - 1;
  781. }
  782. # endif
  783. # endif
  784. # ifndef yytnamerr
  785. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  786. quotes and backslashes, so that it's suitable for yyerror. The
  787. heuristic is that double-quoting is unnecessary unless the string
  788. contains an apostrophe, a comma, or backslash (other than
  789. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  790. null, do not copy; instead, return the length of what the result
  791. would have been. */
  792. static YYSIZE_T
  793. yytnamerr (char *yyres, const char *yystr)
  794. {
  795. if (*yystr == '"')
  796. {
  797. YYSIZE_T yyn = 0;
  798. char const *yyp = yystr;
  799. for (;;)
  800. switch (*++yyp)
  801. {
  802. case '\'':
  803. case ',':
  804. goto do_not_strip_quotes;
  805. case '\\':
  806. if (*++yyp != '\\')
  807. goto do_not_strip_quotes;
  808. /* Fall through. */
  809. default:
  810. if (yyres)
  811. yyres[yyn] = *yyp;
  812. yyn++;
  813. break;
  814. case '"':
  815. if (yyres)
  816. yyres[yyn] = '\0';
  817. return yyn;
  818. }
  819. do_not_strip_quotes: ;
  820. }
  821. if (! yyres)
  822. return yystrlen (yystr);
  823. return yystpcpy (yyres, yystr) - yyres;
  824. }
  825. # endif
  826. /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
  827. about the unexpected token YYTOKEN for the state stack whose top is
  828. YYSSP.
  829. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
  830. not large enough to hold the message. In that case, also set
  831. *YYMSG_ALLOC to the required number of bytes. Return 2 if the
  832. required number of bytes is too large to store. */
  833. static int
  834. yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
  835. yytype_int16 *yyssp, int yytoken)
  836. {
  837. YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
  838. YYSIZE_T yysize = yysize0;
  839. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  840. /* Internationalized format string. */
  841. const char *yyformat = YY_NULLPTR;
  842. /* Arguments of yyformat. */
  843. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  844. /* Number of reported tokens (one for the "unexpected", one per
  845. "expected"). */
  846. int yycount = 0;
  847. /* There are many possibilities here to consider:
  848. - If this state is a consistent state with a default action, then
  849. the only way this function was invoked is if the default action
  850. is an error action. In that case, don't check for expected
  851. tokens because there are none.
  852. - The only way there can be no lookahead present (in yychar) is if
  853. this state is a consistent state with a default action. Thus,
  854. detecting the absence of a lookahead is sufficient to determine
  855. that there is no unexpected or expected token to report. In that
  856. case, just report a simple "syntax error".
  857. - Don't assume there isn't a lookahead just because this state is a
  858. consistent state with a default action. There might have been a
  859. previous inconsistent state, consistent state with a non-default
  860. action, or user semantic action that manipulated yychar.
  861. - Of course, the expected token list depends on states to have
  862. correct lookahead information, and it depends on the parser not
  863. to perform extra reductions after fetching a lookahead from the
  864. scanner and before detecting a syntax error. Thus, state merging
  865. (from LALR or IELR) and default reductions corrupt the expected
  866. token list. However, the list is correct for canonical LR with
  867. one exception: it will still contain any token that will not be
  868. accepted due to an error action in a later state.
  869. */
  870. if (yytoken != YYEMPTY)
  871. {
  872. int yyn = yypact[*yyssp];
  873. yyarg[yycount++] = yytname[yytoken];
  874. if (!yypact_value_is_default (yyn))
  875. {
  876. /* Start YYX at -YYN if negative to avoid negative indexes in
  877. YYCHECK. In other words, skip the first -YYN actions for
  878. this state because they are default actions. */
  879. int yyxbegin = yyn < 0 ? -yyn : 0;
  880. /* Stay within bounds of both yycheck and yytname. */
  881. int yychecklim = YYLAST - yyn + 1;
  882. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  883. int yyx;
  884. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  885. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
  886. && !yytable_value_is_error (yytable[yyx + yyn]))
  887. {
  888. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  889. {
  890. yycount = 1;
  891. yysize = yysize0;
  892. break;
  893. }
  894. yyarg[yycount++] = yytname[yyx];
  895. {
  896. YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
  897. if (! (yysize <= yysize1
  898. && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  899. return 2;
  900. yysize = yysize1;
  901. }
  902. }
  903. }
  904. }
  905. switch (yycount)
  906. {
  907. # define YYCASE_(N, S) \
  908. case N: \
  909. yyformat = S; \
  910. break
  911. YYCASE_(0, YY_("syntax error"));
  912. YYCASE_(1, YY_("syntax error, unexpected %s"));
  913. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  914. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  915. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  916. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  917. # undef YYCASE_
  918. }
  919. {
  920. YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
  921. if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  922. return 2;
  923. yysize = yysize1;
  924. }
  925. if (*yymsg_alloc < yysize)
  926. {
  927. *yymsg_alloc = 2 * yysize;
  928. if (! (yysize <= *yymsg_alloc
  929. && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
  930. *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
  931. return 1;
  932. }
  933. /* Avoid sprintf, as that infringes on the user's name space.
  934. Don't have undefined behavior even if the translation
  935. produced a string with the wrong number of "%s"s. */
  936. {
  937. char *yyp = *yymsg;
  938. int yyi = 0;
  939. while ((*yyp = *yyformat) != '\0')
  940. if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
  941. {
  942. yyp += yytnamerr (yyp, yyarg[yyi++]);
  943. yyformat += 2;
  944. }
  945. else
  946. {
  947. yyp++;
  948. yyformat++;
  949. }
  950. }
  951. return 0;
  952. }
  953. #endif /* YYERROR_VERBOSE */
  954. /*-----------------------------------------------.
  955. | Release the memory associated to this symbol. |
  956. `-----------------------------------------------*/
  957. static void
  958. yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
  959. {
  960. YYUSE (yyvaluep);
  961. if (!yymsg)
  962. yymsg = "Deleting";
  963. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  964. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  965. YYUSE (yytype);
  966. YY_IGNORE_MAYBE_UNINITIALIZED_END
  967. }
  968. /* The lookahead symbol. */
  969. int yychar;
  970. /* The semantic value of the lookahead symbol. */
  971. YYSTYPE yylval;
  972. /* Number of syntax errors so far. */
  973. int yynerrs;
  974. /*----------.
  975. | yyparse. |
  976. `----------*/
  977. int
  978. yyparse (void)
  979. {
  980. int yystate;
  981. /* Number of tokens to shift before error messages enabled. */
  982. int yyerrstatus;
  983. /* The stacks and their tools:
  984. 'yyss': related to states.
  985. 'yyvs': related to semantic values.
  986. Refer to the stacks through separate pointers, to allow yyoverflow
  987. to reallocate them elsewhere. */
  988. /* The state stack. */
  989. yytype_int16 yyssa[YYINITDEPTH];
  990. yytype_int16 *yyss;
  991. yytype_int16 *yyssp;
  992. /* The semantic value stack. */
  993. YYSTYPE yyvsa[YYINITDEPTH];
  994. YYSTYPE *yyvs;
  995. YYSTYPE *yyvsp;
  996. YYSIZE_T yystacksize;
  997. int yyn;
  998. int yyresult;
  999. /* Lookahead token as an internal (translated) token number. */
  1000. int yytoken = 0;
  1001. /* The variables used to return semantic value and location from the
  1002. action routines. */
  1003. YYSTYPE yyval;
  1004. #if YYERROR_VERBOSE
  1005. /* Buffer for error messages, and its allocated size. */
  1006. char yymsgbuf[128];
  1007. char *yymsg = yymsgbuf;
  1008. YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  1009. #endif
  1010. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  1011. /* The number of symbols on the RHS of the reduced rule.
  1012. Keep to zero when no symbol should be popped. */
  1013. int yylen = 0;
  1014. yyssp = yyss = yyssa;
  1015. yyvsp = yyvs = yyvsa;
  1016. yystacksize = YYINITDEPTH;
  1017. YYDPRINTF ((stderr, "Starting parse\n"));
  1018. yystate = 0;
  1019. yyerrstatus = 0;
  1020. yynerrs = 0;
  1021. yychar = YYEMPTY; /* Cause a token to be read. */
  1022. goto yysetstate;
  1023. /*------------------------------------------------------------.
  1024. | yynewstate -- Push a new state, which is found in yystate. |
  1025. `------------------------------------------------------------*/
  1026. yynewstate:
  1027. /* In all cases, when you get here, the value and location stacks
  1028. have just been pushed. So pushing a state here evens the stacks. */
  1029. yyssp++;
  1030. yysetstate:
  1031. *yyssp = yystate;
  1032. if (yyss + yystacksize - 1 <= yyssp)
  1033. {
  1034. /* Get the current used size of the three stacks, in elements. */
  1035. YYSIZE_T yysize = yyssp - yyss + 1;
  1036. #ifdef yyoverflow
  1037. {
  1038. /* Give user a chance to reallocate the stack. Use copies of
  1039. these so that the &'s don't force the real ones into
  1040. memory. */
  1041. YYSTYPE *yyvs1 = yyvs;
  1042. yytype_int16 *yyss1 = yyss;
  1043. /* Each stack pointer address is followed by the size of the
  1044. data in use in that stack, in bytes. This used to be a
  1045. conditional around just the two extra args, but that might
  1046. be undefined if yyoverflow is a macro. */
  1047. yyoverflow (YY_("memory exhausted"),
  1048. &yyss1, yysize * sizeof (*yyssp),
  1049. &yyvs1, yysize * sizeof (*yyvsp),
  1050. &yystacksize);
  1051. yyss = yyss1;
  1052. yyvs = yyvs1;
  1053. }
  1054. #else /* no yyoverflow */
  1055. # ifndef YYSTACK_RELOCATE
  1056. goto yyexhaustedlab;
  1057. # else
  1058. /* Extend the stack our own way. */
  1059. if (YYMAXDEPTH <= yystacksize)
  1060. goto yyexhaustedlab;
  1061. yystacksize *= 2;
  1062. if (YYMAXDEPTH < yystacksize)
  1063. yystacksize = YYMAXDEPTH;
  1064. {
  1065. yytype_int16 *yyss1 = yyss;
  1066. union yyalloc *yyptr =
  1067. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  1068. if (! yyptr)
  1069. goto yyexhaustedlab;
  1070. YYSTACK_RELOCATE (yyss_alloc, yyss);
  1071. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  1072. # undef YYSTACK_RELOCATE
  1073. if (yyss1 != yyssa)
  1074. YYSTACK_FREE (yyss1);
  1075. }
  1076. # endif
  1077. #endif /* no yyoverflow */
  1078. yyssp = yyss + yysize - 1;
  1079. yyvsp = yyvs + yysize - 1;
  1080. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1081. (unsigned long int) yystacksize));
  1082. if (yyss + yystacksize - 1 <= yyssp)
  1083. YYABORT;
  1084. }
  1085. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1086. if (yystate == YYFINAL)
  1087. YYACCEPT;
  1088. goto yybackup;
  1089. /*-----------.
  1090. | yybackup. |
  1091. `-----------*/
  1092. yybackup:
  1093. /* Do appropriate processing given the current state. Read a
  1094. lookahead token if we need one and don't already have one. */
  1095. /* First try to decide what to do without reference to lookahead token. */
  1096. yyn = yypact[yystate];
  1097. if (yypact_value_is_default (yyn))
  1098. goto yydefault;
  1099. /* Not known => get a lookahead token if don't already have one. */
  1100. /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
  1101. if (yychar == YYEMPTY)
  1102. {
  1103. YYDPRINTF ((stderr, "Reading a token: "));
  1104. yychar = yylex ();
  1105. }
  1106. if (yychar <= YYEOF)
  1107. {
  1108. yychar = yytoken = YYEOF;
  1109. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1110. }
  1111. else
  1112. {
  1113. yytoken = YYTRANSLATE (yychar);
  1114. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1115. }
  1116. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1117. detect an error, take that action. */
  1118. yyn += yytoken;
  1119. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1120. goto yydefault;
  1121. yyn = yytable[yyn];
  1122. if (yyn <= 0)
  1123. {
  1124. if (yytable_value_is_error (yyn))
  1125. goto yyerrlab;
  1126. yyn = -yyn;
  1127. goto yyreduce;
  1128. }
  1129. /* Count tokens shifted since error; after three, turn off error
  1130. status. */
  1131. if (yyerrstatus)
  1132. yyerrstatus--;
  1133. /* Shift the lookahead token. */
  1134. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1135. /* Discard the shifted token. */
  1136. yychar = YYEMPTY;
  1137. yystate = yyn;
  1138. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1139. *++yyvsp = yylval;
  1140. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1141. goto yynewstate;
  1142. /*-----------------------------------------------------------.
  1143. | yydefault -- do the default action for the current state. |
  1144. `-----------------------------------------------------------*/
  1145. yydefault:
  1146. yyn = yydefact[yystate];
  1147. if (yyn == 0)
  1148. goto yyerrlab;
  1149. goto yyreduce;
  1150. /*-----------------------------.
  1151. | yyreduce -- Do a reduction. |
  1152. `-----------------------------*/
  1153. yyreduce:
  1154. /* yyn is the number of a rule to reduce with. */
  1155. yylen = yyr2[yyn];
  1156. /* If YYLEN is nonzero, implement the default value of the action:
  1157. '$$ = $1'.
  1158. Otherwise, the following line sets YYVAL to garbage.
  1159. This behavior is undocumented and Bison
  1160. users should not rely upon it. Assigning to YYVAL
  1161. unconditionally makes the parser a bit smaller, and it avoids a
  1162. GCC warning that YYVAL may be used uninitialized. */
  1163. yyval = yyvsp[1-yylen];
  1164. YY_REDUCE_PRINT (yyn);
  1165. switch (yyn)
  1166. {
  1167. case 5:
  1168. #line 89 "analyse_syntaxique.y" /* yacc.c:1646 */
  1169. {add_function(&table_fonctions, "Main", RET_INT, array.index); table.depth++;}
  1170. #line 1368 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1171. break;
  1172. case 6:
  1173. #line 89 "analyse_syntaxique.y" /* yacc.c:1646 */
  1174. {print_table(&table);remove_symboles(&table); table.depth--;}
  1175. #line 1374 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1176. break;
  1177. case 7:
  1178. #line 90 "analyse_syntaxique.y" /* yacc.c:1646 */
  1179. {{add_function(&table_fonctions, (yyvsp[0].id), return_type, array.index); table.depth++;}}
  1180. #line 1380 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1181. break;
  1182. case 8:
  1183. #line 90 "analyse_syntaxique.y" /* yacc.c:1646 */
  1184. {generate_instruction_0(&array, RET_FUN); print_table(&table);remove_symboles(&table); table.depth--;}
  1185. #line 1386 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1186. break;
  1187. case 9:
  1188. #line 92 "analyse_syntaxique.y" /* yacc.c:1646 */
  1189. {type = TYPE_INT;}
  1190. #line 1392 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1191. break;
  1192. case 10:
  1193. #line 93 "analyse_syntaxique.y" /* yacc.c:1646 */
  1194. {type = TYPE_INT_PTR;}
  1195. #line 1398 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1196. break;
  1197. case 11:
  1198. #line 95 "analyse_syntaxique.y" /* yacc.c:1646 */
  1199. {}
  1200. #line 1404 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1201. break;
  1202. case 13:
  1203. #line 98 "analyse_syntaxique.y" /* yacc.c:1646 */
  1204. {add_symbole_top(&table, (yyvsp[0].id), type, INITIALISED, table.depth);}
  1205. #line 1410 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1206. break;
  1207. case 14:
  1208. #line 100 "analyse_syntaxique.y" /* yacc.c:1646 */
  1209. {type = TYPE_INT;}
  1210. #line 1416 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1211. break;
  1212. case 15:
  1213. #line 101 "analyse_syntaxique.y" /* yacc.c:1646 */
  1214. {type = TYPE_INT_PTR;}
  1215. #line 1422 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1216. break;
  1217. case 18:
  1218. #line 107 "analyse_syntaxique.y" /* yacc.c:1646 */
  1219. {}
  1220. #line 1428 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1221. break;
  1222. case 19:
  1223. #line 109 "analyse_syntaxique.y" /* yacc.c:1646 */
  1224. {(yyval.nombre) = array.index;}
  1225. #line 1434 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1226. break;
  1227. case 20:
  1228. #line 110 "analyse_syntaxique.y" /* yacc.c:1646 */
  1229. {(yyval.nombre) = array.index;}
  1230. #line 1440 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1231. break;
  1232. case 30:
  1233. #line 124 "analyse_syntaxique.y" /* yacc.c:1646 */
  1234. {type = TYPE_INT;}
  1235. #line 1446 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1236. break;
  1237. case 31:
  1238. #line 125 "analyse_syntaxique.y" /* yacc.c:1646 */
  1239. {type = TYPE_CONST_INT;}
  1240. #line 1452 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1241. break;
  1242. case 32:
  1243. #line 126 "analyse_syntaxique.y" /* yacc.c:1646 */
  1244. {type = TYPE_INT_PTR;}
  1245. #line 1458 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1246. break;
  1247. case 33:
  1248. #line 128 "analyse_syntaxique.y" /* yacc.c:1646 */
  1249. {add_symbole_top(&table, (yyvsp[0].id), type, INITIALISED, table.depth);}
  1250. #line 1464 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1251. break;
  1252. case 34:
  1253. #line 128 "analyse_syntaxique.y" /* yacc.c:1646 */
  1254. {int varAddr = variable_exists(&table, (yyvsp[-3].id)); generate_instruction_2(&array, COP, varAddr, (yyvsp[0].nombre)); free_temp(&table);}
  1255. #line 1470 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1256. break;
  1257. case 35:
  1258. #line 129 "analyse_syntaxique.y" /* yacc.c:1646 */
  1259. {add_symbole_top(&table, (yyvsp[0].id), type, NOT_INITIALISED, table.depth);}
  1260. #line 1476 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1261. break;
  1262. case 36:
  1263. #line 132 "analyse_syntaxique.y" /* yacc.c:1646 */
  1264. {int varAddr = variable_exists(&table, (yyvsp[-3].id)); generate_instruction_2(&array, COP, varAddr, (yyvsp[-1].nombre)); free_temp(&table);}
  1265. #line 1482 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1266. break;
  1267. case 37:
  1268. #line 133 "analyse_syntaxique.y" /* yacc.c:1646 */
  1269. {int varAddr = variable_exists(&table, (yyvsp[-3].id)); generate_instruction_2(&array, COP_STR, varAddr, (yyvsp[-1].nombre)); free_temp(&table);}
  1270. #line 1488 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1271. break;
  1272. case 38:
  1273. #line 136 "analyse_syntaxique.y" /* yacc.c:1646 */
  1274. {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, (yyvsp[0].nombre)); (yyval.nombre) = vt;}
  1275. #line 1494 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1276. break;
  1277. case 39:
  1278. #line 137 "analyse_syntaxique.y" /* yacc.c:1646 */
  1279. {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[0].id)); generate_instruction_2(&array, COP, vt, varAddr); (yyval.nombre) = vt;}
  1280. #line 1500 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1281. break;
  1282. case 40:
  1283. #line 138 "analyse_syntaxique.y" /* yacc.c:1646 */
  1284. {generate_instruction_3(&array, ADD, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);}
  1285. #line 1506 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1286. break;
  1287. case 41:
  1288. #line 139 "analyse_syntaxique.y" /* yacc.c:1646 */
  1289. {generate_instruction_3(&array, MUL, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);}
  1290. #line 1512 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1291. break;
  1292. case 42:
  1293. #line 140 "analyse_syntaxique.y" /* yacc.c:1646 */
  1294. {generate_instruction_3(&array, SOU, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);}
  1295. #line 1518 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1296. break;
  1297. case 43:
  1298. #line 141 "analyse_syntaxique.y" /* yacc.c:1646 */
  1299. {generate_instruction_3(&array, DIV, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);}
  1300. #line 1524 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1301. break;
  1302. case 44:
  1303. #line 142 "analyse_syntaxique.y" /* yacc.c:1646 */
  1304. {printf("Variable negative\n");}
  1305. #line 1530 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1306. break;
  1307. case 45:
  1308. #line 143 "analyse_syntaxique.y" /* yacc.c:1646 */
  1309. {
  1310. int vt = new_temp(&table);
  1311. generate_instruction_2(&array, COP, vt, (yyvsp[0].nombre));
  1312. remove_symboles(&table);
  1313. table.depth--;
  1314. (yyval.nombre) = vt;}
  1315. #line 1541 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1316. break;
  1317. case 46:
  1318. #line 149 "analyse_syntaxique.y" /* yacc.c:1646 */
  1319. {printf("Parenthèse\n"); (yyval.nombre) = (yyvsp[-1].nombre); }
  1320. #line 1547 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1321. break;
  1322. case 47:
  1323. #line 150 "analyse_syntaxique.y" /* yacc.c:1646 */
  1324. {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[0].id)); generate_instruction_2(&array, LEA, vt, varAddr); (yyval.nombre) = vt;}
  1325. #line 1553 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1326. break;
  1327. case 48:
  1328. #line 151 "analyse_syntaxique.y" /* yacc.c:1646 */
  1329. {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[0].id)); generate_instruction_2(&array, COP, vt, varAddr); generate_instruction_2(&array, COP_LD, vt, vt); (yyval.nombre) = vt;}
  1330. #line 1559 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1331. break;
  1332. case 49:
  1333. #line 154 "analyse_syntaxique.y" /* yacc.c:1646 */
  1334. {
  1335. //gen_jmpf(&table, &array, $3, -1);
  1336. generate_instruction_2(&array, JMF, (yyvsp[-1].nombre), -1);
  1337. free_temp(&table);
  1338. (yyvsp[-3].nombre) = array.index;
  1339. }
  1340. #line 1570 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1341. break;
  1342. case 50:
  1343. #line 160 "analyse_syntaxique.y" /* yacc.c:1646 */
  1344. {table.depth++;}
  1345. #line 1576 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1346. break;
  1347. case 51:
  1348. #line 160 "analyse_syntaxique.y" /* yacc.c:1646 */
  1349. {generate_instruction_1(&array, JMP, -1);}
  1350. #line 1582 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1351. break;
  1352. case 52:
  1353. #line 160 "analyse_syntaxique.y" /* yacc.c:1646 */
  1354. {remove_symboles(&table); table.depth--;}
  1355. #line 1588 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1356. break;
  1357. case 53:
  1358. #line 161 "analyse_syntaxique.y" /* yacc.c:1646 */
  1359. {
  1360. int adr_jmp = array.index;
  1361. update_jmf(&array, (yyvsp[-10].nombre), adr_jmp);
  1362. }
  1363. #line 1597 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1364. break;
  1365. case 54:
  1366. #line 165 "analyse_syntaxique.y" /* yacc.c:1646 */
  1367. {printf("updating jump\n"); update_jmp(&array, (yyvsp[-5].nombre), (yyvsp[0].nombre));}
  1368. #line 1603 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1369. break;
  1370. case 55:
  1371. #line 167 "analyse_syntaxique.y" /* yacc.c:1646 */
  1372. {table.depth++;}
  1373. #line 1609 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1374. break;
  1375. case 56:
  1376. #line 167 "analyse_syntaxique.y" /* yacc.c:1646 */
  1377. {remove_symboles(&table); table.depth--;}
  1378. #line 1615 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1379. break;
  1380. case 57:
  1381. #line 167 "analyse_syntaxique.y" /* yacc.c:1646 */
  1382. {(yyval.nombre) = array.index;}
  1383. #line 1621 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1384. break;
  1385. case 58:
  1386. #line 168 "analyse_syntaxique.y" /* yacc.c:1646 */
  1387. {(yyval.nombre) = array.index;}
  1388. #line 1627 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1389. break;
  1390. case 59:
  1391. #line 169 "analyse_syntaxique.y" /* yacc.c:1646 */
  1392. {(yyval.nombre) = array.index;}
  1393. #line 1633 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1394. break;
  1395. case 60:
  1396. #line 171 "analyse_syntaxique.y" /* yacc.c:1646 */
  1397. {
  1398. (yyvsp[0].nombre) = array.index ;
  1399. }
  1400. #line 1641 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1401. break;
  1402. case 61:
  1403. #line 173 "analyse_syntaxique.y" /* yacc.c:1646 */
  1404. {
  1405. //gen_jmpf(&table, &array, $4, -1);
  1406. generate_instruction_2(&array, JMF, (yyvsp[-1].nombre), -1);
  1407. free_temp(&table);
  1408. (yyvsp[-4].nombre) = array.index;
  1409. }
  1410. #line 1652 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1411. break;
  1412. case 62:
  1413. #line 179 "analyse_syntaxique.y" /* yacc.c:1646 */
  1414. {table.depth++;}
  1415. #line 1658 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1416. break;
  1417. case 63:
  1418. #line 179 "analyse_syntaxique.y" /* yacc.c:1646 */
  1419. {remove_symboles(&table); table.depth--;}
  1420. #line 1664 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1421. break;
  1422. case 64:
  1423. #line 179 "analyse_syntaxique.y" /* yacc.c:1646 */
  1424. {
  1425. int adr_jmp = array.index;
  1426. update_jmf(&array, (yyvsp[-10].nombre), adr_jmp);
  1427. //gen_jmpf(&table, &array, $1, $2);
  1428. generate_instruction_1(&array, JMP, (yyvsp[-9].nombre));
  1429. }
  1430. #line 1675 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1431. break;
  1432. case 65:
  1433. #line 186 "analyse_syntaxique.y" /* yacc.c:1646 */
  1434. {generate_instruction_3(&array, EQ, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1435. #line 1681 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1436. break;
  1437. case 66:
  1438. #line 187 "analyse_syntaxique.y" /* yacc.c:1646 */
  1439. {generate_instruction_3(&array, NEQ, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1440. #line 1687 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1441. break;
  1442. case 67:
  1443. #line 188 "analyse_syntaxique.y" /* yacc.c:1646 */
  1444. {generate_instruction_3(&array, LT, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1445. #line 1693 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1446. break;
  1447. case 68:
  1448. #line 189 "analyse_syntaxique.y" /* yacc.c:1646 */
  1449. {generate_instruction_3(&array, GT, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1450. #line 1699 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1451. break;
  1452. case 69:
  1453. #line 190 "analyse_syntaxique.y" /* yacc.c:1646 */
  1454. {generate_instruction_3(&array, LTE, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1455. #line 1705 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1456. break;
  1457. case 70:
  1458. #line 191 "analyse_syntaxique.y" /* yacc.c:1646 */
  1459. {generate_instruction_3(&array, GTE, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1460. #line 1711 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1461. break;
  1462. case 71:
  1463. #line 192 "analyse_syntaxique.y" /* yacc.c:1646 */
  1464. {generate_instruction_3(&array, AND, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1465. #line 1717 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1466. break;
  1467. case 72:
  1468. #line 193 "analyse_syntaxique.y" /* yacc.c:1646 */
  1469. {generate_instruction_3(&array, OR, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);}
  1470. #line 1723 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1471. break;
  1472. case 73:
  1473. #line 194 "analyse_syntaxique.y" /* yacc.c:1646 */
  1474. {generate_instruction_2(&array, NOT, (yyvsp[0].nombre), (yyvsp[0].nombre)); (yyval.nombre) = (yyvsp[0].nombre);}
  1475. #line 1729 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1476. break;
  1477. case 74:
  1478. #line 195 "analyse_syntaxique.y" /* yacc.c:1646 */
  1479. {(yyval.nombre) = (yyvsp[0].nombre); }
  1480. #line 1735 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1481. break;
  1482. case 75:
  1483. #line 197 "analyse_syntaxique.y" /* yacc.c:1646 */
  1484. {table.depth++; prepare_function_call(&table); return_value = (table.indexAvailableTop - 1);}
  1485. #line 1741 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1486. break;
  1487. case 76:
  1488. #line 198 "analyse_syntaxique.y" /* yacc.c:1646 */
  1489. {int function_index = function_exists(&table_fonctions, (yyvsp[-4].id));
  1490. int jmp_addr = (table_fonctions.array[function_index]).start_addr;
  1491. generate_instruction_2(&array, CALL, jmp_addr, (array.index + 1));
  1492. (yyval.nombre) = return_value;
  1493. }
  1494. #line 1751 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1495. break;
  1496. case 79:
  1497. #line 206 "analyse_syntaxique.y" /* yacc.c:1646 */
  1498. {int arg_addr = prepare_argument_push(&table); generate_instruction_2(&array, COP, arg_addr, (yyvsp[0].nombre)); free_temp(&table);}
  1499. #line 1757 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1500. break;
  1501. case 82:
  1502. #line 210 "analyse_syntaxique.y" /* yacc.c:1646 */
  1503. {generate_instruction_1(&array, PRI, (yyvsp[-2].nombre)); free_temp(&table);}
  1504. #line 1763 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1505. break;
  1506. case 83:
  1507. #line 212 "analyse_syntaxique.y" /* yacc.c:1646 */
  1508. {(yyval.nombre) = generate_instruction_1(&array, RET, (yyvsp[-1].nombre)); free_temp(&table);}
  1509. #line 1769 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1510. break;
  1511. #line 1773 "analyse_syntaxique.tab.c" /* yacc.c:1646 */
  1512. default: break;
  1513. }
  1514. /* User semantic actions sometimes alter yychar, and that requires
  1515. that yytoken be updated with the new translation. We take the
  1516. approach of translating immediately before every use of yytoken.
  1517. One alternative is translating here after every semantic action,
  1518. but that translation would be missed if the semantic action invokes
  1519. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1520. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1521. incorrect destructor might then be invoked immediately. In the
  1522. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1523. to an incorrect destructor call or verbose syntax error message
  1524. before the lookahead is translated. */
  1525. YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  1526. YYPOPSTACK (yylen);
  1527. yylen = 0;
  1528. YY_STACK_PRINT (yyss, yyssp);
  1529. *++yyvsp = yyval;
  1530. /* Now 'shift' the result of the reduction. Determine what state
  1531. that goes to, based on the state we popped back to and the rule
  1532. number reduced by. */
  1533. yyn = yyr1[yyn];
  1534. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  1535. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1536. yystate = yytable[yystate];
  1537. else
  1538. yystate = yydefgoto[yyn - YYNTOKENS];
  1539. goto yynewstate;
  1540. /*--------------------------------------.
  1541. | yyerrlab -- here on detecting error. |
  1542. `--------------------------------------*/
  1543. yyerrlab:
  1544. /* Make sure we have latest lookahead translation. See comments at
  1545. user semantic actions for why this is necessary. */
  1546. yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
  1547. /* If not already recovering from an error, report this error. */
  1548. if (!yyerrstatus)
  1549. {
  1550. ++yynerrs;
  1551. #if ! YYERROR_VERBOSE
  1552. yyerror (YY_("syntax error"));
  1553. #else
  1554. # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
  1555. yyssp, yytoken)
  1556. {
  1557. char const *yymsgp = YY_("syntax error");
  1558. int yysyntax_error_status;
  1559. yysyntax_error_status = YYSYNTAX_ERROR;
  1560. if (yysyntax_error_status == 0)
  1561. yymsgp = yymsg;
  1562. else if (yysyntax_error_status == 1)
  1563. {
  1564. if (yymsg != yymsgbuf)
  1565. YYSTACK_FREE (yymsg);
  1566. yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
  1567. if (!yymsg)
  1568. {
  1569. yymsg = yymsgbuf;
  1570. yymsg_alloc = sizeof yymsgbuf;
  1571. yysyntax_error_status = 2;
  1572. }
  1573. else
  1574. {
  1575. yysyntax_error_status = YYSYNTAX_ERROR;
  1576. yymsgp = yymsg;
  1577. }
  1578. }
  1579. yyerror (yymsgp);
  1580. if (yysyntax_error_status == 2)
  1581. goto yyexhaustedlab;
  1582. }
  1583. # undef YYSYNTAX_ERROR
  1584. #endif
  1585. }
  1586. if (yyerrstatus == 3)
  1587. {
  1588. /* If just tried and failed to reuse lookahead token after an
  1589. error, discard it. */
  1590. if (yychar <= YYEOF)
  1591. {
  1592. /* Return failure if at end of input. */
  1593. if (yychar == YYEOF)
  1594. YYABORT;
  1595. }
  1596. else
  1597. {
  1598. yydestruct ("Error: discarding",
  1599. yytoken, &yylval);
  1600. yychar = YYEMPTY;
  1601. }
  1602. }
  1603. /* Else will try to reuse lookahead token after shifting the error
  1604. token. */
  1605. goto yyerrlab1;
  1606. /*---------------------------------------------------.
  1607. | yyerrorlab -- error raised explicitly by YYERROR. |
  1608. `---------------------------------------------------*/
  1609. yyerrorlab:
  1610. /* Pacify compilers like GCC when the user code never invokes
  1611. YYERROR and the label yyerrorlab therefore never appears in user
  1612. code. */
  1613. if (/*CONSTCOND*/ 0)
  1614. goto yyerrorlab;
  1615. /* Do not reclaim the symbols of the rule whose action triggered
  1616. this YYERROR. */
  1617. YYPOPSTACK (yylen);
  1618. yylen = 0;
  1619. YY_STACK_PRINT (yyss, yyssp);
  1620. yystate = *yyssp;
  1621. goto yyerrlab1;
  1622. /*-------------------------------------------------------------.
  1623. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1624. `-------------------------------------------------------------*/
  1625. yyerrlab1:
  1626. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1627. for (;;)
  1628. {
  1629. yyn = yypact[yystate];
  1630. if (!yypact_value_is_default (yyn))
  1631. {
  1632. yyn += YYTERROR;
  1633. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1634. {
  1635. yyn = yytable[yyn];
  1636. if (0 < yyn)
  1637. break;
  1638. }
  1639. }
  1640. /* Pop the current state because it cannot handle the error token. */
  1641. if (yyssp == yyss)
  1642. YYABORT;
  1643. yydestruct ("Error: popping",
  1644. yystos[yystate], yyvsp);
  1645. YYPOPSTACK (1);
  1646. yystate = *yyssp;
  1647. YY_STACK_PRINT (yyss, yyssp);
  1648. }
  1649. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1650. *++yyvsp = yylval;
  1651. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1652. /* Shift the error token. */
  1653. YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  1654. yystate = yyn;
  1655. goto yynewstate;
  1656. /*-------------------------------------.
  1657. | yyacceptlab -- YYACCEPT comes here. |
  1658. `-------------------------------------*/
  1659. yyacceptlab:
  1660. yyresult = 0;
  1661. goto yyreturn;
  1662. /*-----------------------------------.
  1663. | yyabortlab -- YYABORT comes here. |
  1664. `-----------------------------------*/
  1665. yyabortlab:
  1666. yyresult = 1;
  1667. goto yyreturn;
  1668. #if !defined yyoverflow || YYERROR_VERBOSE
  1669. /*-------------------------------------------------.
  1670. | yyexhaustedlab -- memory exhaustion comes here. |
  1671. `-------------------------------------------------*/
  1672. yyexhaustedlab:
  1673. yyerror (YY_("memory exhausted"));
  1674. yyresult = 2;
  1675. /* Fall through. */
  1676. #endif
  1677. yyreturn:
  1678. if (yychar != YYEMPTY)
  1679. {
  1680. /* Make sure we have latest lookahead translation. See comments at
  1681. user semantic actions for why this is necessary. */
  1682. yytoken = YYTRANSLATE (yychar);
  1683. yydestruct ("Cleanup: discarding lookahead",
  1684. yytoken, &yylval);
  1685. }
  1686. /* Do not reclaim the symbols of the rule whose action triggered
  1687. this YYABORT or YYACCEPT. */
  1688. YYPOPSTACK (yylen);
  1689. YY_STACK_PRINT (yyss, yyssp);
  1690. while (yyssp != yyss)
  1691. {
  1692. yydestruct ("Cleanup: popping",
  1693. yystos[*yyssp], yyvsp);
  1694. YYPOPSTACK (1);
  1695. }
  1696. #ifndef yyoverflow
  1697. if (yyss != yyssa)
  1698. YYSTACK_FREE (yyss);
  1699. #endif
  1700. #if YYERROR_VERBOSE
  1701. if (yymsg != yymsgbuf)
  1702. YYSTACK_FREE (yymsg);
  1703. #endif
  1704. return yyresult;
  1705. }
  1706. #line 214 "analyse_syntaxique.y" /* yacc.c:1906 */
  1707. #include <stdio.h>
  1708. void main(void){
  1709. //TODO: rajouter gestion des erreurs
  1710. initialise_table(&table);
  1711. initialise_function_table(&table_fonctions);
  1712. initialise_asm(&array);
  1713. yyparse();
  1714. print_table(&table);
  1715. printf("\n");
  1716. print_fonction_table(&table_fonctions);
  1717. //remove_symboles(&table, 0);
  1718. //print_table(&table);
  1719. exportInstructions(&array);
  1720. }