Subversion Repositories wimsdev

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* A Bison parser, made from unites.y
  2.    by GNU bison 1.35.  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. # define        REAL    257
  7. # define        SPC     258
  8. # define        Uh      259
  9. # define        Umin    260
  10. # define        Um      261
  11. # define        Ug      262
  12. # define        Us      263
  13. # define        UA      264
  14. # define        UK      265
  15. # define        Umol    266
  16. # define        Ucd     267
  17. # define        UHz     268
  18. # define        UN      269
  19. # define        UPa     270
  20. # define        UJ      271
  21. # define        UW      272
  22. # define        UC      273
  23. # define        UV      274
  24. # define        Uohm    275
  25. # define        US      276
  26. # define        UF      277
  27. # define        UT      278
  28. # define        UWb     279
  29. # define        UH      280
  30. # define        Ulm     281
  31. # define        Ulx     282
  32. # define        UBq     283
  33. # define        UGy     284
  34. # define        USv     285
  35. # define        Urad    286
  36. # define        Usr     287
  37. # define        PUIS    288
  38. # define        PP      289
  39. # define        POINT   290
  40. # define        BARRE   291
  41. # define        Uda     292
  42. # define        Uma     293
  43. # define        Usa     294
  44. # define        Uangs   295
  45. # define        Ubarn   296
  46. # define        Uare    297
  47. # define        Ul      298
  48. # define        Ut      299
  49. # define        Ubar    300
  50. # define        UeV     301
  51. # define        Uuam    302
  52. # define        Signif  303
  53.  
  54. #line 1 "unites.y"
  55.  
  56. /* inclusions, définition */
  57. #include <string.h>
  58. #include <stdlib.h>
  59. #include <stdio.h>
  60. #include <math.h>
  61. #include "unites.h"
  62.  
  63.   char * unit_names[BU_LAST]={"m","kg","s","A","K","mol","cd"};
  64.  
  65.   typedef struct{
  66.     int i;
  67.     double multip, maxmultip;
  68.     uniteSI unite;
  69.     int base[BU_LAST];
  70.     char * s, * v;
  71.     double val;
  72.     int signif;
  73.   } yystype;
  74.  
  75. #define YYSTYPE yystype
  76.  
  77.  extern char * yytext;
  78.  extern FILE * yyin;
  79.  
  80. /* variables globales */
  81. #define MAXBUF 255
  82.  char buffer[MAXBUF+1], buffer2[MAXBUF+1];
  83.  yystype result;
  84.  double val_real;
  85.  int val_int, count_signif=0;
  86.  long pos;
  87.  
  88. /* les unités du SI */
  89. /* Handbook of Chemistry & Physics 78, CRC Press 1997, page 1-20 */
  90. unite_data unites[TU_LAST] ={
  91. /*TUh*/   {"h",    "seconde",3600.0,     { 0, 0, 1, 0, 0, 0, 0}},
  92. /*TUmin*/ {"min",   "seconde", 60.0,     { 0, 0, 1, 0, 0, 0, 0}},
  93. /*TUm*/   {"m",      "mètre",   1.0,     { 1, 0, 0, 0, 0, 0, 0}},
  94. /*TUg*/   {"g",    "kilogramme",1.0e-3,  { 0, 1, 0, 0, 0, 0, 0}},
  95. /*TUs*/   {"s",      "seconde", 1.0,     { 0, 0, 1, 0, 0, 0, 0}},
  96. /*TUA*/   {"A",      "ampère",  1.0,     { 0, 0, 0, 1, 0, 0, 0}},
  97. /*TUK*/   {"K",      "kelvin",  1.0,     { 0, 0, 0, 0, 1, 0, 0}},
  98. /*TUmol*/ {"mol",    "mol",     1.0,     { 0, 0, 0, 0, 0, 1, 0}},
  99. /*TUcd*/  {"cd",     "candela", 1.0,     { 0, 0, 0, 0, 0, 0, 1}},
  100. /*TUHz*/  {"Hz",     "hetrz",   1.0,     { 0,-1, 0, 0, 0, 0, 0}},
  101. /*TUN*/   {"N",      "newton",  1.0,     { 1, 1,-2, 0, 0, 0, 0}},
  102. /*TUPa*/  {"Pa",     "pascal",  1.0,     {-1, 1,-2, 0, 0, 0, 0}},
  103. /*TUJ*/   {"J",      "joule",   1.0,     { 2, 1,-2, 0, 0, 0, 0}},
  104. /*TUW */  {"W",      "watt",    1.0,     { 2, 1,-3, 0, 0, 0, 0}},
  105. /*TUC*/   {"C",      "coulomb", 1.0,     { 0, 0, 1, 1, 0, 0, 0}},
  106. /*TUV*/   {"V",      "volt",    1.0,     { 2, 1,-3,-1, 0, 0, 0}},
  107. /*TUohm*/ {"\\Omega","ohm",     1.0,     { 2, 1,-3,-2, 0, 0, 0}},
  108. /*TUS*/   {"S",      "siemens", 1.0,     {-2,-1, 3, 2, 0, 0, 0}},
  109. /*TUF*/   {"F",      "farad",   1.0,     {-2,-1, 4, 2, 0, 0, 0}},
  110. /*TUT*/   {"T",      "tesla",   1.0,     { 0, 1,-2,-1, 0, 0, 0}},
  111. /*TUWb*/  {"Wb",     "weber",   1.0,     { 2, 1,-2,-1, 0, 0, 0}},
  112. /*TUH*/   {"H",      "henry",   1.0,     { 2, 1,-2,-2, 0, 0, 0}},
  113. /*TUlm*/  {"lm",     "lumen",   1.0,     { 0, 0, 0, 0, 0, 0, 1}},
  114. /*TUlx*/  {"lx",     "lux",     1.0,     {-2, 0, 0, 0, 0, 0, 1}},
  115. /*TUBq */ {"Bq",     "becquerel",1.0,    { 0, 0,-1, 0, 0, 0, 0}},
  116. /*TUGy*/  {"Gy",     "gray",     1.0,    { 2, 0,-2, 0, 0, 0, 0}},
  117. /*TUSv*/  {"Sv",     "sievert",  1.0,    { 2, 0,-2, 0, 0, 0, 0}},
  118. /*TUrad*/ {"rad",    "radian",   1.0,    { 0, 0, 0, 0, 0, 0, 0}},
  119. /*TUsr*/  {"sr" ,    "stéradian",1.0,    { 0, 0, 0, 0, 0, 0, 0}},
  120. /*TUnull*/{"" ,    "sans unité",1.0,     { 0, 0, 0, 0, 0, 0, 0}},
  121. /*TUda*/  {"°", "degré", M_PI/180.0,     { 0, 0, 0, 0, 0, 0, 0}},
  122. /*TUma*/  {"'", "minute", M_PI/10800,    { 0, 0, 0, 0, 0, 0, 0}},
  123. /*TUsa*/  {"''","seconde",M_PI/648000 ,  { 0, 0, 0, 0, 0, 0, 0}},
  124. /*TUangs*/ {"\\o{A}", "angström", 1e-10, { 1, 0, 0, 0, 0, 0, 0}},
  125. /*TUbarn*/ {"b", "barn", 1e-28,          { 2, 0, 0, 0, 0, 0, 0}},
  126. /*TUare*/  {"a", "are", 1e2,             { 2, 0, 0, 0, 0, 0, 0}},
  127. /*TUl*/    {"L", "litre", 1e-3,          { 3, 0, 0, 0, 0, 0, 0}},
  128. /*TUt*/    {"t", "tonne", 1e3,              { 0, 1, 0, 0, 0, 0, 0}},
  129. /*TUbar*/  {"bar", "bar", 1e5,            {-1, 1,-2, 0, 0, 0, 0}},
  130. /*TUeV*/   {"eV", "eV", 1.60218e-19,       { 0, 0, 1, 1, 0, 0, 0}},
  131. /*TUuam*/  {"uma", "uma", 1.66054e-27,    { 0, 1, 0, 0, 0, 0, 0}}
  132. };
  133.  
  134. unite_data pref_units[] ={
  135. /*TUm*/   {"m",      "mètre",   1.0,     { 1, 0, 0, 0, 0, 0, 0}},
  136. /*   */   {"kg",    "kilogramme",1.0,    { 0, 1, 0, 0, 0, 0, 0}},
  137. /*TUs*/   {"s",      "seconde", 1.0,     { 0, 0, 1, 0, 0, 0, 0}},
  138. /*TUA*/   {"A",      "ampère",  1.0,     { 0, 0, 0, 1, 0, 0, 0}},
  139. /*TUK*/   {"K",      "kelvin",  1.0,     { 0, 0, 0, 0, 1, 0, 0}},
  140. /*TUmol*/ {"mol",    "mol",     1.0,     { 0, 0, 0, 0, 0, 1, 0}},
  141. /*TUcd*/  {"cd",     "candela", 1.0,     { 0, 0, 0, 0, 0, 0, 1}},
  142. /*TUHz*/  {"Hz",     "hetrz",   1.0,     { 0,-1, 0, 0, 0, 0, 0}},
  143. /*TUN*/   {"N",      "newton",  1.0,     { 1, 1,-2, 0, 0, 0, 0}},
  144. /*TUPa*/  {"Pa",     "pascal",  1.0,     {-1, 1,-2, 0, 0, 0, 0}},
  145. /*TUJ*/   {"J",      "joule",   1.0,     { 2, 1,-2, 0, 0, 0, 0}},
  146. /*TUW */  {"W",      "watt",    1.0,     { 2, 1,-3, 0, 0, 0, 0}},
  147. /*TUC*/   {"C",      "coulomb", 1.0,     { 0, 0, 1, 1, 0, 0, 0}},
  148. /*TUV*/   {"V",      "volt",    1.0,     { 2, 1,-3,-1, 0, 0, 0}},
  149. /*TUohm*/ {"ohm",    "ohm",     1.0,     { 2, 1,-3,-2, 0, 0, 0}},
  150. /*TUS*/   {"S",      "siemens", 1.0,     {-2,-1, 3, 2, 0, 0, 0}},
  151. /*TUF*/   {"F",      "farad",   1.0,     {-2,-1, 4, 2, 0, 0, 0}},
  152. /*TUT*/   {"T",      "tesla",   1.0,     { 0, 1,-2,-1, 0, 0, 0}},
  153. /*TUWb*/  {"Wb",     "weber",   1.0,     { 2, 1,-2,-1, 0, 0, 0}},
  154. /*TUH*/   {"H",      "henry",   1.0,     { 2, 1,-2,-2, 0, 0, 0}},
  155. /*TUlm*/  {"lm",     "lumen",   1.0,     { 0, 0, 0, 0, 0, 0, 1}},
  156. /*TUlx*/  {"lx",     "lux",     1.0,     {-2, 0, 0, 0, 0, 0, 1}},
  157. };
  158.  
  159. int significative(char* text);
  160. int significative(char* text){
  161.   // returns the number of significative numbers of a real
  162.   // if the real is null returns zero.
  163.   int i,j,result=0;
  164.   for(i=0;
  165.       i<strlen(text)&&(text[i]=='0'||text[i]=='.'|| text[i]=='+'||text[i]=='-');
  166.       i++){
  167.     //skip leading plus,minus,zeros and the decimal point
  168.   }
  169.   for(j=i;j<strlen(text)&&(text[j]>='0'&&text[j]<='9'||text[j]=='.');j++){
  170.     if (text[j]!='.') {
  171.       result++;
  172.     } else {
  173.       //skip the decimal point
  174.     }
  175.   }
  176.   return result;
  177. }
  178.  
  179. #ifndef YYSTYPE
  180. # define YYSTYPE int
  181. # define YYSTYPE_IS_TRIVIAL 1
  182. #endif
  183. #ifndef YYDEBUG
  184. # define YYDEBUG 0
  185. #endif
  186.  
  187.  
  188.  
  189. #define YYFINAL         75
  190. #define YYFLAG          -32768
  191. #define YYNTBASE        50
  192.  
  193. /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
  194. #define YYTRANSLATE(x) ((unsigned)(x) <= 303 ? yytranslate[x] : 63)
  195.  
  196. /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
  197. static const char yytranslate[] =
  198. {
  199.        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  203.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  204.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  205.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  206.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  207.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  208.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  209.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  210.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  211.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  212.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  213.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  214.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  215.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  216.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  217.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  218.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  219.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  220.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  221.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  222.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  223.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  224.        2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
  225.        6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  226.       16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  227.       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  228.       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  229.       46,    47,    48,    49
  230. };
  231.  
  232. #if YYDEBUG
  233. static const short yyprhs[] =
  234. {
  235.        0,     0,     2,     4,     8,    10,    14,    19,    21,    24,
  236.       25,    27,    30,    32,    35,    38,    40,    43,    46,    49,
  237.       52,    54,    57,    58,    60,    62,    64,    66,    68,    70,
  238.       72,    74,    76,    78,    80,    82,    84,    86,    88,    90,
  239.       92,    94,    96,    98,   100,   102,   104,   106,   108,   110,
  240.      112,   114,   116,   118,   120,   122,   124,   126,   128,   130,
  241.      132,   134,   136,   138,   140
  242. };
  243. static const short yyrhs[] =
  244. {
  245.       51,     0,    53,     0,    52,    54,    51,     0,    52,     0,
  246.        3,    54,    55,     0,     3,    54,    55,    49,     0,     3,
  247.        0,     3,    49,     0,     0,     4,     0,    55,    56,     0,
  248.       59,     0,    57,    59,     0,    37,    59,     0,    36,     0,
  249.        7,    62,     0,    24,    62,     0,     5,    62,     0,    61,
  250.       62,     0,    62,     0,    58,    60,     0,     0,    34,     0,
  251.       35,     0,     5,     0,     6,     0,     7,     0,     8,     0,
  252.        9,     0,    10,     0,    11,     0,    12,     0,    13,     0,
  253.       14,     0,    15,     0,    16,     0,    17,     0,    24,     0,
  254.       18,     0,    19,     0,    20,     0,    21,     0,    22,     0,
  255.       23,     0,    25,     0,    26,     0,    27,     0,    28,     0,
  256.       29,     0,    30,     0,    31,     0,    32,     0,    33,     0,
  257.       38,     0,    39,     0,    40,     0,    41,     0,    42,     0,
  258.       43,     0,    44,     0,    45,     0,    46,     0,    47,     0,
  259.       48,     0
  260. };
  261.  
  262. #endif
  263.  
  264. #if YYDEBUG
  265. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  266. static const short yyrline[] =
  267. {
  268.        0,   180,   181,   184,   193,   196,   197,   203,   211,   221,
  269.      222,   225,   237,   240,   246,   260,   263,   271,   278,   285,
  270.      292,   297,   319,   320,   323,   348,   350,   351,   352,   353,
  271.      354,   355,   356,   357,   358,   359,   360,   361,   362,   363,
  272.      364,   365,   366,   367,   368,   369,   370,   371,   372,   373,
  273.      374,   375,   376,   377,   378,   379,   380,   381,   382,   383,
  274.      384,   385,   386,   387,   388
  275. };
  276. #endif
  277.  
  278.  
  279. #if (YYDEBUG) || defined YYERROR_VERBOSE
  280.  
  281. /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
  282. static const char *const yytname[] =
  283. {
  284.   "$", "error", "$undefined.", "REAL", "SPC", "Uh", "Umin", "Um", "Ug",
  285.   "Us", "UA", "UK", "Umol", "Ucd", "UHz", "UN", "UPa", "UJ", "UW", "UC",
  286.   "UV", "Uohm", "US", "UF", "UT", "UWb", "UH", "Ulm", "Ulx", "UBq", "UGy",
  287.   "USv", "Urad", "Usr", "PUIS", "PP", "POINT", "BARRE", "Uda", "Uma",
  288.   "Usa", "Uangs", "Ubarn", "Uare", "Ul", "Ut", "Ubar", "UeV", "Uuam",
  289.   "Signif", "but", "valeur_mixte", "valeur", "sans_unite", "spc", "unite",
  290.   "suiv_unit", "point", "prim_unit1", "prim_unit", "puissance01",
  291.   "prefixe", "base_unite", 0
  292. };
  293. #endif
  294.  
  295. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  296. static const short yyr1[] =
  297. {
  298.        0,    50,    50,    51,    51,    52,    52,    53,    53,    54,
  299.       54,    55,    55,    56,    56,    57,    58,    58,    58,    58,
  300.       58,    59,    60,    60,    61,    62,    62,    62,    62,    62,
  301.       62,    62,    62,    62,    62,    62,    62,    62,    62,    62,
  302.       62,    62,    62,    62,    62,    62,    62,    62,    62,    62,
  303.       62,    62,    62,    62,    62,    62,    62,    62,    62,    62,
  304.       62,    62,    62,    62,    62
  305. };
  306.  
  307. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  308. static const short yyr2[] =
  309. {
  310.        0,     1,     1,     3,     1,     3,     4,     1,     2,     0,
  311.        1,     2,     1,     2,     2,     1,     2,     2,     2,     2,
  312.        1,     2,     0,     1,     1,     1,     1,     1,     1,     1,
  313.        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  314.        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  315.        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  316.        1,     1,     1,     1,     1
  317. };
  318.  
  319. /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
  320.    doesn't specify something else to do.  Zero means the default is an
  321.    error. */
  322. static const short yydefact[] =
  323. {
  324.        0,     9,     1,     4,     2,    10,     8,     0,     0,    25,
  325.       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  326.       36,    37,    39,    40,    41,    42,    43,    44,    38,    45,
  327.       46,    47,    48,    49,    50,    51,    52,    53,    24,    54,
  328.       55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
  329.        5,    22,    12,     0,    20,     9,     3,    25,    27,    38,
  330.       18,    16,    17,    15,     0,     6,    11,     0,    23,    21,
  331.       19,    14,    13,     0,     0,     0
  332. };
  333.  
  334. static const short yydefgoto[] =
  335. {
  336.       73,     2,     3,     4,     7,    50,    66,    67,    51,    52,
  337.       69,    53,    54
  338. };
  339.  
  340. static const short yypact[] =
  341. {
  342.       -1,     0,-32768,     5,-32768,-32768,-32768,    45,     8,    89,
  343.   -32768,    89,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  344.   -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    89,-32768,
  345.   -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  346.   -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  347.      -31,   -22,-32768,    89,-32768,     9,-32768,-32768,-32768,-32768,
  348.   -32768,-32768,-32768,-32768,    45,-32768,-32768,    45,-32768,-32768,
  349.   -32768,-32768,-32768,    14,    15,-32768
  350. };
  351.  
  352. static const short yypgoto[] =
  353. {
  354.   -32768,    11,-32768,-32768,    13,-32768,-32768,-32768,-32768,   -57,
  355.   -32768,-32768,    -8
  356. };
  357.  
  358.  
  359. #define YYLAST          137
  360.  
  361.  
  362. static const short yytable[] =
  363. {
  364.       -7,    60,     1,    61,     5,    63,    64,    71,    -9,     5,
  365.       72,    55,    68,     5,    74,    75,     8,     0,    65,    56,
  366.       62,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  367.        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  368.        0,     0,     0,     0,     0,    70,     0,     0,     0,     6,
  369.        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
  370.       19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  371.       29,    30,    31,    32,    33,    34,    35,    36,    37,     0,
  372.       38,     0,     0,    39,    40,    41,    42,    43,    44,    45,
  373.       46,    47,    48,    49,    57,    10,    58,    12,    13,    14,
  374.       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  375.       25,    26,    27,    59,    29,    30,    31,    32,    33,    34,
  376.       35,    36,    37,     0,     0,     0,     0,    39,    40,    41,
  377.       42,    43,    44,    45,    46,    47,    48,    49
  378. };
  379.  
  380. static const short yycheck[] =
  381. {
  382.        0,     9,     3,    11,     4,    36,    37,    64,     3,     4,
  383.       67,     3,    34,     4,     0,     0,     3,    -1,    49,     8,
  384.       28,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  385.       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  386.       -1,    -1,    -1,    -1,    -1,    53,    -1,    -1,    -1,    49,
  387.        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
  388.       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  389.       25,    26,    27,    28,    29,    30,    31,    32,    33,    -1,
  390.       35,    -1,    -1,    38,    39,    40,    41,    42,    43,    44,
  391.       45,    46,    47,    48,     5,     6,     7,     8,     9,    10,
  392.       11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
  393.       21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
  394.       31,    32,    33,    -1,    -1,    -1,    -1,    38,    39,    40,
  395.       41,    42,    43,    44,    45,    46,    47,    48
  396. };
  397. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  398. #line 3 "/usr/share/bison/bison.simple"
  399.  
  400. /* Skeleton output parser for bison,
  401.  
  402.    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
  403.    Foundation, Inc.
  404.  
  405.    This program is free software; you can redistribute it and/or modify
  406.    it under the terms of the GNU General Public License as published by
  407.    the Free Software Foundation; either version 2, or (at your option)
  408.    any later version.
  409.  
  410.    This program is distributed in the hope that it will be useful,
  411.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  412.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  413.    GNU General Public License for more details.
  414.  
  415.    You should have received a copy of the GNU General Public License
  416.    along with this program; if not, write to the Free Software
  417.    Foundation, Inc., 59 Temple Place - Suite 330,
  418.    Boston, MA 02111-1307, USA.  */
  419.  
  420. /* As a special exception, when this file is copied by Bison into a
  421.    Bison output file, you may use that output file without restriction.
  422.    This special exception was added by the Free Software Foundation
  423.    in version 1.24 of Bison.  */
  424.  
  425. /* This is the parser code that is written into each bison parser when
  426.    the %semantic_parser declaration is not specified in the grammar.
  427.    It was written by Richard Stallman by simplifying the hairy parser
  428.    used when %semantic_parser is specified.  */
  429.  
  430. /* All symbols defined below should begin with yy or YY, to avoid
  431.    infringing on user name space.  This should be done even for local
  432.    variables, as they might otherwise be expanded by user macros.
  433.    There are some unavoidable exceptions within include files to
  434.    define necessary library symbols; they are noted "INFRINGES ON
  435.    USER NAME SPACE" below.  */
  436.  
  437. #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
  438.  
  439. /* The parser invokes alloca or malloc; define the necessary symbols.  */
  440.  
  441. # if YYSTACK_USE_ALLOCA
  442. #  define YYSTACK_ALLOC alloca
  443. # else
  444. #  ifndef YYSTACK_USE_ALLOCA
  445. #   if defined (alloca) || defined (_ALLOCA_H)
  446. #    define YYSTACK_ALLOC alloca
  447. #   else
  448. #    ifdef __GNUC__
  449. #     define YYSTACK_ALLOC __builtin_alloca
  450. #    endif
  451. #   endif
  452. #  endif
  453. # endif
  454.  
  455. # ifdef YYSTACK_ALLOC
  456.    /* Pacify GCC's `empty if-body' warning. */
  457. #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  458. # else
  459. #  if defined (__STDC__) || defined (__cplusplus)
  460. #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  461. #   define YYSIZE_T size_t
  462. #  endif
  463. #  define YYSTACK_ALLOC malloc
  464. #  define YYSTACK_FREE free
  465. # endif
  466. #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
  467.  
  468.  
  469. #if (! defined (yyoverflow) \
  470.      && (! defined (__cplusplus) \
  471.          || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  472.  
  473. /* A type that is properly aligned for any stack member.  */
  474. union yyalloc
  475. {
  476.   short yyss;
  477.   YYSTYPE yyvs;
  478. # if YYLSP_NEEDED
  479.   YYLTYPE yyls;
  480. # endif
  481. };
  482.  
  483. /* The size of the maximum gap between one aligned stack and the next.  */
  484. # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
  485.  
  486. /* The size of an array large to enough to hold all stacks, each with
  487.    N elements.  */
  488. # if YYLSP_NEEDED
  489. #  define YYSTACK_BYTES(N) \
  490.      ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))      \
  491.       + 2 * YYSTACK_GAP_MAX)
  492. # else
  493. #  define YYSTACK_BYTES(N) \
  494.      ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
  495.       + YYSTACK_GAP_MAX)
  496. # endif
  497.  
  498. /* Copy COUNT objects from FROM to TO.  The source and destination do
  499.    not overlap.  */
  500. # ifndef YYCOPY
  501. #  if 1 < __GNUC__
  502. #   define YYCOPY(To, From, Count) \
  503.       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  504. #  else
  505. #   define YYCOPY(To, From, Count)              \
  506.       do                                        \
  507.         {                                       \
  508.           register YYSIZE_T yyi;                \
  509.           for (yyi = 0; yyi < (Count); yyi++)   \
  510.             (To)[yyi] = (From)[yyi];            \
  511.         }                                       \
  512.       while (0)
  513. #  endif
  514. # endif
  515.  
  516. /* Relocate STACK from its old location to the new one.  The
  517.    local variables YYSIZE and YYSTACKSIZE give the old and new number of
  518.    elements in the stack, and YYPTR gives the new location of the
  519.    stack.  Advance YYPTR to a properly aligned location for the next
  520.    stack.  */
  521. # define YYSTACK_RELOCATE(Stack)                                        \
  522.     do                                                                  \
  523.       {                                                                 \
  524.         YYSIZE_T yynewbytes;                                            \
  525.         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
  526.         Stack = &yyptr->Stack;                                          \
  527.         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;   \
  528.         yyptr += yynewbytes / sizeof (*yyptr);                          \
  529.       }                                                                 \
  530.     while (0)
  531.  
  532. #endif
  533.  
  534.  
  535. #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
  536. # define YYSIZE_T __SIZE_TYPE__
  537. #endif
  538. #if ! defined (YYSIZE_T) && defined (size_t)
  539. # define YYSIZE_T size_t
  540. #endif
  541. #if ! defined (YYSIZE_T)
  542. # if defined (__STDC__) || defined (__cplusplus)
  543. #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  544. #  define YYSIZE_T size_t
  545. # endif
  546. #endif
  547. #if ! defined (YYSIZE_T)
  548. # define YYSIZE_T unsigned int
  549. #endif
  550.  
  551. #define yyerrok         (yyerrstatus = 0)
  552. #define yyclearin       (yychar = YYEMPTY)
  553. #define YYEMPTY         -2
  554. #define YYEOF           0
  555. #define YYACCEPT        goto yyacceptlab
  556. #define YYABORT         goto yyabortlab
  557. #define YYERROR         goto yyerrlab1
  558. /* Like YYERROR except do call yyerror.  This remains here temporarily
  559.    to ease the transition to the new meaning of YYERROR, for GCC.
  560.    Once GCC version 2 has supplanted version 1, this can go.  */
  561. #define YYFAIL          goto yyerrlab
  562. #define YYRECOVERING()  (!!yyerrstatus)
  563. #define YYBACKUP(Token, Value)                                  \
  564. do                                                              \
  565.   if (yychar == YYEMPTY && yylen == 1)                          \
  566.     {                                                           \
  567.       yychar = (Token);                                         \
  568.       yylval = (Value);                                         \
  569.       yychar1 = YYTRANSLATE (yychar);                           \
  570.       YYPOPSTACK;                                               \
  571.       goto yybackup;                                            \
  572.     }                                                           \
  573.   else                                                          \
  574.     {                                                           \
  575.       yyerror ("syntax error: cannot back up");                 \
  576.       YYERROR;                                                  \
  577.     }                                                           \
  578. while (0)
  579.  
  580. #define YYTERROR        1
  581. #define YYERRCODE       256
  582.  
  583.  
  584. /* YYLLOC_DEFAULT -- Compute the default location (before the actions
  585.    are run).
  586.  
  587.    When YYLLOC_DEFAULT is run, CURRENT is set the location of the
  588.    first token.  By default, to implement support for ranges, extend
  589.    its range to the last symbol.  */
  590.  
  591. #ifndef YYLLOC_DEFAULT
  592. # define YYLLOC_DEFAULT(Current, Rhs, N)        \
  593.    Current.last_line   = Rhs[N].last_line;      \
  594.    Current.last_column = Rhs[N].last_column;
  595. #endif
  596.  
  597.  
  598. /* YYLEX -- calling `yylex' with the right arguments.  */
  599.  
  600. #if YYPURE
  601. # if YYLSP_NEEDED
  602. #  ifdef YYLEX_PARAM
  603. #   define YYLEX                yylex (&yylval, &yylloc, YYLEX_PARAM)
  604. #  else
  605. #   define YYLEX                yylex (&yylval, &yylloc)
  606. #  endif
  607. # else /* !YYLSP_NEEDED */
  608. #  ifdef YYLEX_PARAM
  609. #   define YYLEX                yylex (&yylval, YYLEX_PARAM)
  610. #  else
  611. #   define YYLEX                yylex (&yylval)
  612. #  endif
  613. # endif /* !YYLSP_NEEDED */
  614. #else /* !YYPURE */
  615. # define YYLEX                  yylex ()
  616. #endif /* !YYPURE */
  617.  
  618.  
  619. /* Enable debugging if requested.  */
  620. #if YYDEBUG
  621.  
  622. # ifndef YYFPRINTF
  623. #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  624. #  define YYFPRINTF fprintf
  625. # endif
  626.  
  627. # define YYDPRINTF(Args)                        \
  628. do {                                            \
  629.   if (yydebug)                                  \
  630.     YYFPRINTF Args;                             \
  631. } while (0)
  632. /* Nonzero means print parse trace.  It is left uninitialized so that
  633.    multiple parsers can coexist.  */
  634. int yydebug;
  635. #else /* !YYDEBUG */
  636. # define YYDPRINTF(Args)
  637. #endif /* !YYDEBUG */
  638.  
  639. /* YYINITDEPTH -- initial size of the parser's stacks.  */
  640. #ifndef YYINITDEPTH
  641. # define YYINITDEPTH 200
  642. #endif
  643.  
  644. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  645.    if the built-in stack extension method is used).
  646.  
  647.    Do not make this value too large; the results are undefined if
  648.    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
  649.    evaluated with infinite-precision integer arithmetic.  */
  650.  
  651. #if YYMAXDEPTH == 0
  652. # undef YYMAXDEPTH
  653. #endif
  654.  
  655. #ifndef YYMAXDEPTH
  656. # define YYMAXDEPTH 10000
  657. #endif
  658. #ifdef YYERROR_VERBOSE
  659.  
  660. # ifndef yystrlen
  661. #  if defined (__GLIBC__) && defined (_STRING_H)
  662. #   define yystrlen strlen
  663. #  else
  664. /* Return the length of YYSTR.  */
  665. static YYSIZE_T
  666. #   if defined (__STDC__) || defined (__cplusplus)
  667. yystrlen (const char *yystr)
  668. #   else
  669. yystrlen (yystr)
  670.      const char *yystr;
  671. #   endif
  672. {
  673.   register const char *yys = yystr;
  674.  
  675.   while (*yys++ != '\0')
  676.     continue;
  677.  
  678.   return yys - yystr - 1;
  679. }
  680. #  endif
  681. # endif
  682.  
  683. # ifndef yystpcpy
  684. #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
  685. #   define yystpcpy stpcpy
  686. #  else
  687. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  688.    YYDEST.  */
  689. static char *
  690. #   if defined (__STDC__) || defined (__cplusplus)
  691. yystpcpy (char *yydest, const char *yysrc)
  692. #   else
  693. yystpcpy (yydest, yysrc)
  694.      char *yydest;
  695.      const char *yysrc;
  696. #   endif
  697. {
  698.   register char *yyd = yydest;
  699.   register const char *yys = yysrc;
  700.  
  701.   while ((*yyd++ = *yys++) != '\0')
  702.     continue;
  703.  
  704.   return yyd - 1;
  705. }
  706. #  endif
  707. # endif
  708. #endif
  709. #line 315 "/usr/share/bison/bison.simple"
  710.  
  711.  
  712. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  713.    into yyparse.  The argument should have type void *.
  714.    It should actually point to an object.
  715.    Grammar actions can access the variable by casting it
  716.    to the proper pointer type.  */
  717.  
  718. #ifdef YYPARSE_PARAM
  719. # if defined (__STDC__) || defined (__cplusplus)
  720. #  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  721. #  define YYPARSE_PARAM_DECL
  722. # else
  723. #  define YYPARSE_PARAM_ARG YYPARSE_PARAM
  724. #  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  725. # endif
  726. #else /* !YYPARSE_PARAM */
  727. # define YYPARSE_PARAM_ARG
  728. # define YYPARSE_PARAM_DECL
  729. #endif /* !YYPARSE_PARAM */
  730.  
  731. /* Prevent warning if -Wstrict-prototypes.  */
  732. #ifdef __GNUC__
  733. # ifdef YYPARSE_PARAM
  734. int yyparse (void *);
  735. # else
  736. int yyparse (void);
  737. # endif
  738. #endif
  739.  
  740. /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
  741.    variables are global, or local to YYPARSE.  */
  742.  
  743. #define YY_DECL_NON_LSP_VARIABLES                       \
  744. /* The lookahead symbol.  */                            \
  745. int yychar;                                             \
  746.                                                         \
  747. /* The semantic value of the lookahead symbol. */       \
  748. YYSTYPE yylval;                                         \
  749.                                                         \
  750. /* Number of parse errors so far.  */                   \
  751. int yynerrs;
  752.  
  753. #if YYLSP_NEEDED
  754. # define YY_DECL_VARIABLES                      \
  755. YY_DECL_NON_LSP_VARIABLES                       \
  756.                                                 \
  757. /* Location data for the lookahead symbol.  */  \
  758. YYLTYPE yylloc;
  759. #else
  760. # define YY_DECL_VARIABLES                      \
  761. YY_DECL_NON_LSP_VARIABLES
  762. #endif
  763.  
  764.  
  765. /* If nonreentrant, generate the variables here. */
  766.  
  767. #if !YYPURE
  768. YY_DECL_VARIABLES
  769. #endif  /* !YYPURE */
  770.  
  771. int
  772. yyparse (YYPARSE_PARAM_ARG)
  773.      YYPARSE_PARAM_DECL
  774. {
  775.   /* If reentrant, generate the variables here. */
  776. #if YYPURE
  777.   YY_DECL_VARIABLES
  778. #endif  /* !YYPURE */
  779.  
  780.   register int yystate;
  781.   register int yyn;
  782.   int yyresult;
  783.   /* Number of tokens to shift before error messages enabled.  */
  784.   int yyerrstatus;
  785.   /* Lookahead token as an internal (translated) token number.  */
  786.   int yychar1 = 0;
  787.  
  788.   /* Three stacks and their tools:
  789.      `yyss': related to states,
  790.      `yyvs': related to semantic values,
  791.      `yyls': related to locations.
  792.  
  793.      Refer to the stacks thru separate pointers, to allow yyoverflow
  794.      to reallocate them elsewhere.  */
  795.  
  796.   /* The state stack. */
  797.   short yyssa[YYINITDEPTH];
  798.   short *yyss = yyssa;
  799.   register short *yyssp;
  800.  
  801.   /* The semantic value stack.  */
  802.   YYSTYPE yyvsa[YYINITDEPTH];
  803.   YYSTYPE *yyvs = yyvsa;
  804.   register YYSTYPE *yyvsp;
  805.  
  806. #if YYLSP_NEEDED
  807.   /* The location stack.  */
  808.   YYLTYPE yylsa[YYINITDEPTH];
  809.   YYLTYPE *yyls = yylsa;
  810.   YYLTYPE *yylsp;
  811. #endif
  812.  
  813. #if YYLSP_NEEDED
  814. # define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  815. #else
  816. # define YYPOPSTACK   (yyvsp--, yyssp--)
  817. #endif
  818.  
  819.   YYSIZE_T yystacksize = YYINITDEPTH;
  820.  
  821.  
  822.   /* The variables used to return semantic value and location from the
  823.      action routines.  */
  824.   YYSTYPE yyval;
  825. #if YYLSP_NEEDED
  826.   YYLTYPE yyloc;
  827. #endif
  828.  
  829.   /* When reducing, the number of symbols on the RHS of the reduced
  830.      rule. */
  831.   int yylen;
  832.  
  833.   YYDPRINTF ((stderr, "Starting parse\n"));
  834.  
  835.   yystate = 0;
  836.   yyerrstatus = 0;
  837.   yynerrs = 0;
  838.   yychar = YYEMPTY;             /* Cause a token to be read.  */
  839.  
  840.   /* Initialize stack pointers.
  841.      Waste one element of value and location stack
  842.      so that they stay on the same level as the state stack.
  843.      The wasted elements are never initialized.  */
  844.  
  845.   yyssp = yyss;
  846.   yyvsp = yyvs;
  847. #if YYLSP_NEEDED
  848.   yylsp = yyls;
  849. #endif
  850.   goto yysetstate;
  851.  
  852. /*------------------------------------------------------------.
  853. | yynewstate -- Push a new state, which is found in yystate.  |
  854. `------------------------------------------------------------*/
  855.  yynewstate:
  856.   /* In all cases, when you get here, the value and location stacks
  857.      have just been pushed. so pushing a state here evens the stacks.
  858.      */
  859.   yyssp++;
  860.  
  861.  yysetstate:
  862.   *yyssp = yystate;
  863.  
  864.   if (yyssp >= yyss + yystacksize - 1)
  865.     {
  866.       /* Get the current used size of the three stacks, in elements.  */
  867.       YYSIZE_T yysize = yyssp - yyss + 1;
  868.  
  869. #ifdef yyoverflow
  870.       {
  871.         /* Give user a chance to reallocate the stack. Use copies of
  872.            these so that the &'s don't force the real ones into
  873.            memory.  */
  874.         YYSTYPE *yyvs1 = yyvs;
  875.         short *yyss1 = yyss;
  876.  
  877.         /* Each stack pointer address is followed by the size of the
  878.            data in use in that stack, in bytes.  */
  879. # if YYLSP_NEEDED
  880.         YYLTYPE *yyls1 = yyls;
  881.         /* This used to be a conditional around just the two extra args,
  882.            but that might be undefined if yyoverflow is a macro.  */
  883.         yyoverflow ("parser stack overflow",
  884.                     &yyss1, yysize * sizeof (*yyssp),
  885.                     &yyvs1, yysize * sizeof (*yyvsp),
  886.                     &yyls1, yysize * sizeof (*yylsp),
  887.                     &yystacksize);
  888.         yyls = yyls1;
  889. # else
  890.         yyoverflow ("parser stack overflow",
  891.                     &yyss1, yysize * sizeof (*yyssp),
  892.                     &yyvs1, yysize * sizeof (*yyvsp),
  893.                     &yystacksize);
  894. # endif
  895.         yyss = yyss1;
  896.         yyvs = yyvs1;
  897.       }
  898. #else /* no yyoverflow */
  899. # ifndef YYSTACK_RELOCATE
  900.       goto yyoverflowlab;
  901. # else
  902.       /* Extend the stack our own way.  */
  903.       if (yystacksize >= YYMAXDEPTH)
  904.         goto yyoverflowlab;
  905.       yystacksize *= 2;
  906.       if (yystacksize > YYMAXDEPTH)
  907.         yystacksize = YYMAXDEPTH;
  908.  
  909.       {
  910.         short *yyss1 = yyss;
  911.         union yyalloc *yyptr =
  912.           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  913.         if (! yyptr)
  914.           goto yyoverflowlab;
  915.         YYSTACK_RELOCATE (yyss);
  916.         YYSTACK_RELOCATE (yyvs);
  917. # if YYLSP_NEEDED
  918.         YYSTACK_RELOCATE (yyls);
  919. # endif
  920. # undef YYSTACK_RELOCATE
  921.         if (yyss1 != yyssa)
  922.           YYSTACK_FREE (yyss1);
  923.       }
  924. # endif
  925. #endif /* no yyoverflow */
  926.  
  927.       yyssp = yyss + yysize - 1;
  928.       yyvsp = yyvs + yysize - 1;
  929. #if YYLSP_NEEDED
  930.       yylsp = yyls + yysize - 1;
  931. #endif
  932.  
  933.       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  934.                   (unsigned long int) yystacksize));
  935.  
  936.       if (yyssp >= yyss + yystacksize - 1)
  937.         YYABORT;
  938.     }
  939.  
  940.   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  941.  
  942.   goto yybackup;
  943.  
  944.  
  945. /*-----------.
  946. | yybackup.  |
  947. `-----------*/
  948. yybackup:
  949.  
  950. /* Do appropriate processing given the current state.  */
  951. /* Read a lookahead token if we need one and don't already have one.  */
  952. /* yyresume: */
  953.  
  954.   /* First try to decide what to do without reference to lookahead token.  */
  955.  
  956.   yyn = yypact[yystate];
  957.   if (yyn == YYFLAG)
  958.     goto yydefault;
  959.  
  960.   /* Not known => get a lookahead token if don't already have one.  */
  961.  
  962.   /* yychar is either YYEMPTY or YYEOF
  963.      or a valid token in external form.  */
  964.  
  965.   if (yychar == YYEMPTY)
  966.     {
  967.       YYDPRINTF ((stderr, "Reading a token: "));
  968.       yychar = YYLEX;
  969.     }
  970.  
  971.   /* Convert token to internal form (in yychar1) for indexing tables with */
  972.  
  973.   if (yychar <= 0)              /* This means end of input. */
  974.     {
  975.       yychar1 = 0;
  976.       yychar = YYEOF;           /* Don't call YYLEX any more */
  977.  
  978.       YYDPRINTF ((stderr, "Now at end of input.\n"));
  979.     }
  980.   else
  981.     {
  982.       yychar1 = YYTRANSLATE (yychar);
  983.  
  984. #if YYDEBUG
  985.      /* We have to keep this `#if YYDEBUG', since we use variables
  986.         which are defined only if `YYDEBUG' is set.  */
  987.       if (yydebug)
  988.         {
  989.           YYFPRINTF (stderr, "Next token is %d (%s",
  990.                      yychar, yytname[yychar1]);
  991.           /* Give the individual parser a way to print the precise
  992.              meaning of a token, for further debugging info.  */
  993. # ifdef YYPRINT
  994.           YYPRINT (stderr, yychar, yylval);
  995. # endif
  996.           YYFPRINTF (stderr, ")\n");
  997.         }
  998. #endif
  999.     }
  1000.  
  1001.   yyn += yychar1;
  1002.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  1003.     goto yydefault;
  1004.  
  1005.   yyn = yytable[yyn];
  1006.  
  1007.   /* yyn is what to do for this token type in this state.
  1008.      Negative => reduce, -yyn is rule number.
  1009.      Positive => shift, yyn is new state.
  1010.        New state is final state => don't bother to shift,
  1011.        just return success.
  1012.      0, or most negative number => error.  */
  1013.  
  1014.   if (yyn < 0)
  1015.     {
  1016.       if (yyn == YYFLAG)
  1017.         goto yyerrlab;
  1018.       yyn = -yyn;
  1019.       goto yyreduce;
  1020.     }
  1021.   else if (yyn == 0)
  1022.     goto yyerrlab;
  1023.  
  1024.   if (yyn == YYFINAL)
  1025.     YYACCEPT;
  1026.  
  1027.   /* Shift the lookahead token.  */
  1028.   YYDPRINTF ((stderr, "Shifting token %d (%s), ",
  1029.               yychar, yytname[yychar1]));
  1030.  
  1031.   /* Discard the token being shifted unless it is eof.  */
  1032.   if (yychar != YYEOF)
  1033.     yychar = YYEMPTY;
  1034.  
  1035.   *++yyvsp = yylval;
  1036. #if YYLSP_NEEDED
  1037.   *++yylsp = yylloc;
  1038. #endif
  1039.  
  1040.   /* Count tokens shifted since error; after three, turn off error
  1041.      status.  */
  1042.   if (yyerrstatus)
  1043.     yyerrstatus--;
  1044.  
  1045.   yystate = yyn;
  1046.   goto yynewstate;
  1047.  
  1048.  
  1049. /*-----------------------------------------------------------.
  1050. | yydefault -- do the default action for the current state.  |
  1051. `-----------------------------------------------------------*/
  1052. yydefault:
  1053.   yyn = yydefact[yystate];
  1054.   if (yyn == 0)
  1055.     goto yyerrlab;
  1056.   goto yyreduce;
  1057.  
  1058.  
  1059. /*-----------------------------.
  1060. | yyreduce -- Do a reduction.  |
  1061. `-----------------------------*/
  1062. yyreduce:
  1063.   /* yyn is the number of a rule to reduce with.  */
  1064.   yylen = yyr2[yyn];
  1065.  
  1066.   /* If YYLEN is nonzero, implement the default value of the action:
  1067.      `$$ = $1'.
  1068.  
  1069.      Otherwise, the following line sets YYVAL to the semantic value of
  1070.      the lookahead token.  This behavior is undocumented and Bison
  1071.      users should not rely upon it.  Assigning to YYVAL
  1072.      unconditionally makes the parser a bit smaller, and it avoids a
  1073.      GCC warning that YYVAL may be used uninitialized.  */
  1074.   yyval = yyvsp[1-yylen];
  1075.  
  1076. #if YYLSP_NEEDED
  1077.   /* Similarly for the default location.  Let the user run additional
  1078.      commands if for instance locations are ranges.  */
  1079.   yyloc = yylsp[1-yylen];
  1080.   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  1081. #endif
  1082.  
  1083. #if YYDEBUG
  1084.   /* We have to keep this `#if YYDEBUG', since we use variables which
  1085.      are defined only if `YYDEBUG' is set.  */
  1086.   if (yydebug)
  1087.     {
  1088.       int yyi;
  1089.  
  1090.       YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
  1091.                  yyn, yyrline[yyn]);
  1092.  
  1093.       /* Print the symbols being reduced, and their result.  */
  1094.       for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
  1095.         YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
  1096.       YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  1097.     }
  1098. #endif
  1099.  
  1100.   switch (yyn) {
  1101.  
  1102. case 1:
  1103. #line 180 "unites.y"
  1104. {result = yyvsp[0];;
  1105.     break;}
  1106. case 2:
  1107. #line 181 "unites.y"
  1108. {result = yyvsp[0];;
  1109.     break;}
  1110. case 3:
  1111. #line 184 "unites.y"
  1112. {
  1113.   int i;
  1114.   for(i=0; i < BU_LAST; i++){
  1115.     if (yyvsp[-2].base[i] != yyvsp[0].base[i]) yyerror ("not homogeneous units");
  1116.   }
  1117.   if (yyvsp[-2].multip <= yyvsp[0].maxmultip) yyerror ("incorrect mutiple units ordering");
  1118.   yyval.val=yyvsp[-2].val*yyvsp[-2].multip+yyvsp[0].val*yyvsp[0].multip;
  1119.   yyval.multip=1; yyval.maxmultip = yyvsp[-2].multip;
  1120. ;
  1121.     break;}
  1122. case 4:
  1123. #line 193 "unites.y"
  1124. {yyval=yyvsp[0]; yyval.maxmultip=yyvsp[0].multip;;
  1125.     break;}
  1126. case 5:
  1127. #line 196 "unites.y"
  1128. {yyval=yyvsp[0]; yyval.val=val_real; yyval.signif=0;;
  1129.     break;}
  1130. case 6:
  1131. #line 197 "unites.y"
  1132. {
  1133.   yyval=yyvsp[-1]; yyval.val=val_real;
  1134.   yyval.signif=val_int;
  1135. ;
  1136.     break;}
  1137. case 7:
  1138. #line 203 "unites.y"
  1139. {
  1140.   int i;
  1141.   yyval=yyvsp[0];
  1142.   yyval.val=val_real;
  1143.   for (i=0; i < BU_LAST; i++){yyval.base[i]=unites[TUnull].base[i];}
  1144.   yyval.multip=1.0;
  1145.   yyval.signif=0;
  1146. ;
  1147.     break;}
  1148. case 8:
  1149. #line 211 "unites.y"
  1150. {
  1151.   int i;
  1152.   yyval=yyvsp[-1];
  1153.   yyval.val=val_real;
  1154.   for (i=0; i < BU_LAST; i++){yyval.base[i]=unites[TUnull].base[i];}
  1155.   yyval.multip=1.0;
  1156.   yyval.signif=val_int;
  1157. ;
  1158.     break;}
  1159. case 11:
  1160. #line 225 "unites.y"
  1161. {
  1162.   int index;
  1163.   yyval.unite = TU_LAST; /* unité non renseignée */
  1164.   strncpy(buffer,yyvsp[-1].s,MAXBUF);
  1165.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1166.   free(yyvsp[-1].s); free(yyvsp[0].s);
  1167.   yyval.s=strdup(buffer);
  1168.   for(index=0; index< BU_LAST; index++){
  1169.     yyval.base[index] = yyvsp[-1].base[index]+yyvsp[0].base[index] ;
  1170.   }
  1171.   yyval.multip = yyvsp[-1].multip*yyvsp[0].multip;
  1172. ;
  1173.     break;}
  1174. case 12:
  1175. #line 237 "unites.y"
  1176. { yyval=yyvsp[0]; ;
  1177.     break;}
  1178. case 13:
  1179. #line 240 "unites.y"
  1180. {
  1181.   yyval=yyvsp[0]; strncpy(buffer,".",MAXBUF);
  1182.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1183.   free(yyvsp[0].s);
  1184.   yyval.s=strdup(buffer);
  1185. ;
  1186.     break;}
  1187. case 14:
  1188. #line 246 "unites.y"
  1189. {
  1190.   int index;
  1191.   yyval=yyvsp[0];
  1192.   yyval.multip = 1/ yyval.multip;
  1193.   strncpy(buffer,"/",MAXBUF);
  1194.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1195.   free(yyvsp[0].s);
  1196.   yyval.s=strdup(buffer);
  1197.   for(index=0; index< BU_LAST; index++){
  1198.     yyval.base[index] *= -1;
  1199.   }
  1200. ;
  1201.     break;}
  1202. case 16:
  1203. #line 264 "unites.y"
  1204. {
  1205.   yyval=yyvsp[0];
  1206.   strncpy(buffer,"m",MAXBUF);
  1207.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1208.   free(yyvsp[0].s);
  1209.   yyval.s = strdup(buffer); yyval.multip*=1e-3;
  1210. ;
  1211.     break;}
  1212. case 17:
  1213. #line 271 "unites.y"
  1214. {
  1215.   yyval=yyvsp[0];
  1216.   strncpy(buffer,"T",MAXBUF);
  1217.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1218.   free(yyvsp[0].s);
  1219.   yyval.s = strdup(buffer); yyval.multip*=1e12;
  1220. ;
  1221.     break;}
  1222. case 18:
  1223. #line 278 "unites.y"
  1224. {
  1225.   yyval=yyvsp[0];
  1226.   strncpy(buffer,"h",MAXBUF);
  1227.   strncat(buffer,yyvsp[0].s,MAXBUF-strlen(yyvsp[0].s));
  1228.   free(yyvsp[0].s);
  1229.   yyval.s = strdup(buffer); yyval.multip*=1e2;
  1230. ;
  1231.     break;}
  1232. case 19:
  1233. #line 285 "unites.y"
  1234. {
  1235.   yyval=yyvsp[0];
  1236.   strncpy(buffer, yyvsp[-1].s,MAXBUF);
  1237.   strncat(buffer, yyvsp[0].s, MAXBUF-strlen(yyvsp[0].s));
  1238.   free(yyvsp[-1].s); free(yyvsp[0].s);yyval.s=strdup(buffer);
  1239.   yyval.multip*=yyvsp[-1].multip;
  1240.   ;
  1241.     break;}
  1242. case 20:
  1243. #line 292 "unites.y"
  1244. {
  1245.   yyval=yyvsp[0];
  1246. ;
  1247.     break;}
  1248. case 21:
  1249. #line 297 "unites.y"
  1250. {
  1251.   int index;
  1252.   double r;
  1253.  
  1254.   yyval.i=yyvsp[0].i;
  1255.   strncpy(buffer, yyvsp[-1].s,MAXBUF);
  1256.   if (yyvsp[0].i!=1){
  1257.     strncat(buffer, "^{%d}",MAXBUF-strlen( "^{%d}"));
  1258.     sprintf(buffer2, buffer, yyvsp[0].i);
  1259.   }
  1260.   else strncpy(buffer2,buffer,MAXBUF);
  1261.   yyval.s=strdup(buffer2); free(yyvsp[-1].s);
  1262.   for(index=0; index< BU_LAST; index++){
  1263.     yyval.base[index] = unites[yyvsp[-1].unite].base[index]*yyvsp[0].i;
  1264.   }
  1265.   for(index=0, r=1; index<yyvsp[0].i ; index++){
  1266.     r*= yyval.multip;
  1267.   }
  1268.   yyval.multip=r;
  1269. ;
  1270.     break;}
  1271. case 22:
  1272. #line 319 "unites.y"
  1273. {yyval.i=1;;
  1274.     break;}
  1275. case 23:
  1276. #line 320 "unites.y"
  1277. {yyval.i = atoi(yytext);;
  1278.     break;}
  1279. case 24:
  1280. #line 324 "unites.y"
  1281. {yyval.s = strdup(yytext); yyval.multip=1.0;
  1282.  switch (yytext[0]){
  1283.  case 'y' : yyval.multip = 1e-24; break;
  1284.  case 'z' : yyval.multip = 1e-21; break;
  1285.  case 'a' : yyval.multip = 1e-18; break;
  1286.  case 'f' : yyval.multip = 1e-15; break;
  1287.  case 'p' : yyval.multip = 1e-12; break;
  1288.  case 'n' : yyval.multip = 1e-9; break;
  1289.  case 'µ' : yyval.multip = 1e-6; break;
  1290.  case 'c' : yyval.multip = 1e-2; break;
  1291.  case 'd' : if (!strcmp (yytext,"da") ) yyval.multip = 10.0;
  1292.     else yyval.multip = 0.1; break;
  1293.  case 'h' : yyval.multip = 1e2; break;
  1294.  case 'k' : yyval.multip = 1e3; break;
  1295.  case 'M' : yyval.multip = 1e6; break;
  1296.  case 'G' : yyval.multip = 1e9; break;
  1297.  case 'P' : yyval.multip = 1e15; break;
  1298.  case 'E' : yyval.multip = 1e18; break;
  1299.  case 'Z' : yyval.multip = 1e21; break;
  1300.  case 'Y': yyval.multip = 1e24; break;
  1301.  }
  1302. ;
  1303.     break;}
  1304. case 25:
  1305. #line 349 "unites.y"
  1306. {yyval.unite=TUh; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1307.     break;}
  1308. case 26:
  1309. #line 350 "unites.y"
  1310. {yyval.unite=TUmin; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1311.     break;}
  1312. case 27:
  1313. #line 351 "unites.y"
  1314. {yyval.unite=TUm; yyval.s = strdup("m"); yyval.multip=unites[yyval.unite].multiplicateur;;
  1315.     break;}
  1316. case 28:
  1317. #line 352 "unites.y"
  1318. {yyval.unite=TUg; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1319.     break;}
  1320. case 29:
  1321. #line 353 "unites.y"
  1322. {yyval.unite=TUs; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1323.     break;}
  1324. case 30:
  1325. #line 354 "unites.y"
  1326. { yyval.unite = TUA; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1327.     break;}
  1328. case 31:
  1329. #line 355 "unites.y"
  1330. { yyval.unite = TUK; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1331.     break;}
  1332. case 32:
  1333. #line 356 "unites.y"
  1334. { yyval.unite = TUmol; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1335.     break;}
  1336. case 33:
  1337. #line 357 "unites.y"
  1338. { yyval.unite = TUcd; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1339.     break;}
  1340. case 34:
  1341. #line 358 "unites.y"
  1342. { yyval.unite = TUHz; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1343.     break;}
  1344. case 35:
  1345. #line 359 "unites.y"
  1346. { yyval.unite = TUN; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1347.     break;}
  1348. case 36:
  1349. #line 360 "unites.y"
  1350. { yyval.unite = TUPa; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1351.     break;}
  1352. case 37:
  1353. #line 361 "unites.y"
  1354. { yyval.unite = TUJ; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1355.     break;}
  1356. case 38:
  1357. #line 362 "unites.y"
  1358. { yyval.unite = TUT; yyval.s = strdup("T"); yyval.multip=unites[yyval.unite].multiplicateur;;
  1359.     break;}
  1360. case 39:
  1361. #line 363 "unites.y"
  1362. { yyval.unite = TUW; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1363.     break;}
  1364. case 40:
  1365. #line 364 "unites.y"
  1366. { yyval.unite = TUC; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1367.     break;}
  1368. case 41:
  1369. #line 365 "unites.y"
  1370. { yyval.unite = TUV; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1371.     break;}
  1372. case 42:
  1373. #line 366 "unites.y"
  1374. { yyval.unite = TUohm; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1375.     break;}
  1376. case 43:
  1377. #line 367 "unites.y"
  1378. { yyval.unite = TUS; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1379.     break;}
  1380. case 44:
  1381. #line 368 "unites.y"
  1382. { yyval.unite = TUF; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1383.     break;}
  1384. case 45:
  1385. #line 369 "unites.y"
  1386. { yyval.unite = TUWb; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1387.     break;}
  1388. case 46:
  1389. #line 370 "unites.y"
  1390. { yyval.unite = TUH; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1391.     break;}
  1392. case 47:
  1393. #line 371 "unites.y"
  1394. { yyval.unite = TUlm; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1395.     break;}
  1396. case 48:
  1397. #line 372 "unites.y"
  1398. { yyval.unite = TUlx; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1399.     break;}
  1400. case 49:
  1401. #line 373 "unites.y"
  1402. { yyval.unite = TUBq; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1403.     break;}
  1404. case 50:
  1405. #line 374 "unites.y"
  1406. { yyval.unite = TUGy; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1407.     break;}
  1408. case 51:
  1409. #line 375 "unites.y"
  1410. { yyval.unite = TUSv; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1411.     break;}
  1412. case 52:
  1413. #line 376 "unites.y"
  1414. { yyval.unite = TUrad; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1415.     break;}
  1416. case 53:
  1417. #line 377 "unites.y"
  1418. { yyval.unite = TUsr; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1419.     break;}
  1420. case 54:
  1421. #line 378 "unites.y"
  1422. { yyval.unite = TUda; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1423.     break;}
  1424. case 55:
  1425. #line 379 "unites.y"
  1426. { yyval.unite = TUma; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1427.     break;}
  1428. case 56:
  1429. #line 380 "unites.y"
  1430. { yyval.unite = TUsa; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1431.     break;}
  1432. case 57:
  1433. #line 381 "unites.y"
  1434. { yyval.unite = TUangs; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1435.     break;}
  1436. case 58:
  1437. #line 382 "unites.y"
  1438. { yyval.unite = TUbarn; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1439.     break;}
  1440. case 59:
  1441. #line 383 "unites.y"
  1442. { yyval.unite = TUare; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1443.     break;}
  1444. case 60:
  1445. #line 384 "unites.y"
  1446. { yyval.unite = TUl; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1447.     break;}
  1448. case 61:
  1449. #line 385 "unites.y"
  1450. { yyval.unite = TUt; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1451.     break;}
  1452. case 62:
  1453. #line 386 "unites.y"
  1454. { yyval.unite = TUbar; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1455.     break;}
  1456. case 63:
  1457. #line 387 "unites.y"
  1458. { yyval.unite = TUeV; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1459.     break;}
  1460. case 64:
  1461. #line 388 "unites.y"
  1462. { yyval.unite = TUuam; yyval.s = strdup(yytext); yyval.multip=unites[yyval.unite].multiplicateur;;
  1463.     break;}
  1464. }
  1465.  
  1466. #line 705 "/usr/share/bison/bison.simple"
  1467.  
  1468.   yyvsp -= yylen;
  1469.   yyssp -= yylen;
  1470. #if YYLSP_NEEDED
  1471.   yylsp -= yylen;
  1472. #endif
  1473.  
  1474. #if YYDEBUG
  1475.   if (yydebug)
  1476.     {
  1477.       short *yyssp1 = yyss - 1;
  1478.       YYFPRINTF (stderr, "state stack now");
  1479.       while (yyssp1 != yyssp)
  1480.         YYFPRINTF (stderr, " %d", *++yyssp1);
  1481.       YYFPRINTF (stderr, "\n");
  1482.     }
  1483. #endif
  1484.  
  1485.   *++yyvsp = yyval;
  1486. #if YYLSP_NEEDED
  1487.   *++yylsp = yyloc;
  1488. #endif
  1489.  
  1490.   /* Now `shift' the result of the reduction.  Determine what state
  1491.      that goes to, based on the state we popped back to and the rule
  1492.      number reduced by.  */
  1493.  
  1494.   yyn = yyr1[yyn];
  1495.  
  1496.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1497.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1498.     yystate = yytable[yystate];
  1499.   else
  1500.     yystate = yydefgoto[yyn - YYNTBASE];
  1501.  
  1502.   goto yynewstate;
  1503.  
  1504.  
  1505. /*------------------------------------.
  1506. | yyerrlab -- here on detecting error |
  1507. `------------------------------------*/
  1508. yyerrlab:
  1509.   /* If not already recovering from an error, report this error.  */
  1510.   if (!yyerrstatus)
  1511.     {
  1512.       ++yynerrs;
  1513.  
  1514. #ifdef YYERROR_VERBOSE
  1515.       yyn = yypact[yystate];
  1516.  
  1517.       if (yyn > YYFLAG && yyn < YYLAST)
  1518.         {
  1519.           YYSIZE_T yysize = 0;
  1520.           char *yymsg;
  1521.           int yyx, yycount;
  1522.  
  1523.           yycount = 0;
  1524.           /* Start YYX at -YYN if negative to avoid negative indexes in
  1525.              YYCHECK.  */
  1526.           for (yyx = yyn < 0 ? -yyn : 0;
  1527.                yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
  1528.             if (yycheck[yyx + yyn] == yyx)
  1529.               yysize += yystrlen (yytname[yyx]) + 15, yycount++;
  1530.           yysize += yystrlen ("parse error, unexpected ") + 1;
  1531.           yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
  1532.           yymsg = (char *) YYSTACK_ALLOC (yysize);
  1533.           if (yymsg != 0)
  1534.             {
  1535.               char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
  1536.               yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
  1537.  
  1538.               if (yycount < 5)
  1539.                 {
  1540.                   yycount = 0;
  1541.                   for (yyx = yyn < 0 ? -yyn : 0;
  1542.                        yyx < (int) (sizeof (yytname) / sizeof (char *));
  1543.                        yyx++)
  1544.                     if (yycheck[yyx + yyn] == yyx)
  1545.                       {
  1546.                         const char *yyq = ! yycount ? ", expecting " : " or ";
  1547.                         yyp = yystpcpy (yyp, yyq);
  1548.                         yyp = yystpcpy (yyp, yytname[yyx]);
  1549.                         yycount++;
  1550.                       }
  1551.                 }
  1552.               yyerror (yymsg);
  1553.               YYSTACK_FREE (yymsg);
  1554.             }
  1555.           else
  1556.             yyerror ("parse error; also virtual memory exhausted");
  1557.         }
  1558.       else
  1559. #endif /* defined (YYERROR_VERBOSE) */
  1560.         yyerror ("parse error");
  1561.     }
  1562.   goto yyerrlab1;
  1563.  
  1564.  
  1565. /*--------------------------------------------------.
  1566. | yyerrlab1 -- error raised explicitly by an action |
  1567. `--------------------------------------------------*/
  1568. yyerrlab1:
  1569.   if (yyerrstatus == 3)
  1570.     {
  1571.       /* If just tried and failed to reuse lookahead token after an
  1572.          error, discard it.  */
  1573.  
  1574.       /* return failure if at end of input */
  1575.       if (yychar == YYEOF)
  1576.         YYABORT;
  1577.       YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
  1578.                   yychar, yytname[yychar1]));
  1579.       yychar = YYEMPTY;
  1580.     }
  1581.  
  1582.   /* Else will try to reuse lookahead token after shifting the error
  1583.      token.  */
  1584.  
  1585.   yyerrstatus = 3;              /* Each real token shifted decrements this */
  1586.  
  1587.   goto yyerrhandle;
  1588.  
  1589.  
  1590. /*-------------------------------------------------------------------.
  1591. | yyerrdefault -- current state does not do anything special for the |
  1592. | error token.                                                       |
  1593. `-------------------------------------------------------------------*/
  1594. yyerrdefault:
  1595. #if 0
  1596.   /* This is wrong; only states that explicitly want error tokens
  1597.      should shift them.  */
  1598.  
  1599.   /* If its default is to accept any token, ok.  Otherwise pop it.  */
  1600.   yyn = yydefact[yystate];
  1601.   if (yyn)
  1602.     goto yydefault;
  1603. #endif
  1604.  
  1605.  
  1606. /*---------------------------------------------------------------.
  1607. | yyerrpop -- pop the current state because it cannot handle the |
  1608. | error token                                                    |
  1609. `---------------------------------------------------------------*/
  1610. yyerrpop:
  1611.   if (yyssp == yyss)
  1612.     YYABORT;
  1613.   yyvsp--;
  1614.   yystate = *--yyssp;
  1615. #if YYLSP_NEEDED
  1616.   yylsp--;
  1617. #endif
  1618.  
  1619. #if YYDEBUG
  1620.   if (yydebug)
  1621.     {
  1622.       short *yyssp1 = yyss - 1;
  1623.       YYFPRINTF (stderr, "Error: state stack now");
  1624.       while (yyssp1 != yyssp)
  1625.         YYFPRINTF (stderr, " %d", *++yyssp1);
  1626.       YYFPRINTF (stderr, "\n");
  1627.     }
  1628. #endif
  1629.  
  1630. /*--------------.
  1631. | yyerrhandle.  |
  1632. `--------------*/
  1633. yyerrhandle:
  1634.   yyn = yypact[yystate];
  1635.   if (yyn == YYFLAG)
  1636.     goto yyerrdefault;
  1637.  
  1638.   yyn += YYTERROR;
  1639.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1640.     goto yyerrdefault;
  1641.  
  1642.   yyn = yytable[yyn];
  1643.   if (yyn < 0)
  1644.     {
  1645.       if (yyn == YYFLAG)
  1646.         goto yyerrpop;
  1647.       yyn = -yyn;
  1648.       goto yyreduce;
  1649.     }
  1650.   else if (yyn == 0)
  1651.     goto yyerrpop;
  1652.  
  1653.   if (yyn == YYFINAL)
  1654.     YYACCEPT;
  1655.  
  1656.   YYDPRINTF ((stderr, "Shifting error token, "));
  1657.  
  1658.   *++yyvsp = yylval;
  1659. #if YYLSP_NEEDED
  1660.   *++yylsp = yylloc;
  1661. #endif
  1662.  
  1663.   yystate = yyn;
  1664.   goto yynewstate;
  1665.  
  1666.  
  1667. /*-------------------------------------.
  1668. | yyacceptlab -- YYACCEPT comes here.  |
  1669. `-------------------------------------*/
  1670. yyacceptlab:
  1671.   yyresult = 0;
  1672.   goto yyreturn;
  1673.  
  1674. /*-----------------------------------.
  1675. | yyabortlab -- YYABORT comes here.  |
  1676. `-----------------------------------*/
  1677. yyabortlab:
  1678.   yyresult = 1;
  1679.   goto yyreturn;
  1680.  
  1681. /*---------------------------------------------.
  1682. | yyoverflowab -- parser overflow comes here.  |
  1683. `---------------------------------------------*/
  1684. yyoverflowlab:
  1685.   yyerror ("parser stack overflow");
  1686.   yyresult = 2;
  1687.   /* Fall through.  */
  1688.  
  1689. yyreturn:
  1690. #ifndef yyoverflow
  1691.   if (yyss != yyssa)
  1692.     YYSTACK_FREE (yyss);
  1693. #endif
  1694.   return yyresult;
  1695. }
  1696. #line 393 "unites.y"
  1697.  
  1698.  
  1699. #include "lex.yy.c"
  1700. /* le programme lui-même */
  1701.  
  1702. inline int yyerror(char * msg){
  1703.   printf("ERROR at %ld : %s\n", pos, msg);
  1704.   exit(1);
  1705. }
  1706.  
  1707. void test_verbeux(){
  1708.   int i;
  1709.   yyparse();
  1710.   if (result.s) {
  1711.     if (result.unite == TU_LAST){
  1712.       printf("%s %g SI (équation aux dimensions : ", result.s,
  1713.              result.multip*result.val );
  1714.       for (i=0; i<BU_LAST; i++){
  1715.         printf("%3d", result.base[i]);
  1716.       }
  1717.       printf(")\n");
  1718.     }
  1719.     else {
  1720.       if (result.i!=1)
  1721.         printf ("%s (%g %s)^{%d}\n", result.s,
  1722.                 result.multip*result.val,
  1723.                 unites[result.unite].nom, result.i);
  1724.       else printf("%s %g %s\n", result.s,
  1725.                   result.multip*result.val,
  1726.                   unites[result.unite].nom);
  1727.     }
  1728.   }
  1729.   else fprintf(stderr, "problème : result.s = null\n");
  1730. }
  1731.  
  1732. void sortie_normalisee(){
  1733.   /***************************************************/
  1734.   /* le format des données en sortie est :           */
  1735.   /* double int int int int int int int              */
  1736.   /* et signifie  dans l'ordre                       */
  1737.   /***************************************************/
  1738.   /* valeur                                          */
  1739.   /* puissance en unité de longueur (m)              */
  1740.   /* puissance en unité de masse (kg)                */
  1741.   /* puissance en unité de temps (s)                 */
  1742.   /* puissance en unité de courant (A)               */
  1743.   /* puissance en unité de température (K)           */
  1744.   /* puissance en unité de quantité de matière (mol) */
  1745.   /* puissance en unité de inutensité lumineuse (cd) */
  1746.   /* nombre de chiffres significatifs                */
  1747.   /* un zéro pour des extensions futures             */
  1748.   /***************************************************/
  1749.   int i,s=0;
  1750.  
  1751.   yyparse();
  1752.   printf("%g", result.multip*result.val );
  1753.   if (count_signif){ //il faut prendre en compte les nombres significatifs
  1754.     if (!result.signif) {
  1755.       s=significative(result.v);
  1756.     } else {
  1757.       s=result.signif;
  1758.     }
  1759.   }
  1760.   for (i=0; i<BU_LAST; i++){
  1761.     printf(" %3d", result.base[i]);
  1762.   }
  1763.   printf("    %d    0\n",s);
  1764. }
  1765.  
  1766. void sortie_texte(){
  1767.   /***************************************************/
  1768.   /* le format des données en sortie est :           */
  1769.   /* double string                                   */
  1770.   /* et signifie  dans l'ordre                       */
  1771.   /***************************************************/
  1772.   /* valeur  (compte tenu des ciffres significatifs) */
  1773.   /* unité   (SI)                                    */
  1774.   /***************************************************/
  1775.   int i,j,
  1776.     s=0,
  1777.     notfirst=0,
  1778.     trouve=0,
  1779.     nb_pref=sizeof(pref_units)/sizeof(pref_units[0]);
  1780.  
  1781.   yyparse();
  1782.   if (!result.signif) {
  1783.     s=significative(result.v);
  1784.   } else {
  1785.     s=result.signif;
  1786.   }
  1787.   // affiche la valeur
  1788.   if (s<=1){
  1789.     printf("%1.0e", result.multip*result.val );
  1790.   } else {
  1791.     printf("%1.*e", s-1,result.multip*result.val );
  1792.   }
  1793.   //affiche l'unité SI.
  1794.   //recherche s'il y a une unité préférentielle
  1795.   for (i=0; i<nb_pref; i++){
  1796.     trouve=(result.base[0]==pref_units[i].base[0]);
  1797.     for (j=1; j<BU_LAST; j++){
  1798.       trouve &= (result.base[j]==pref_units[i].base[j]);
  1799.     }
  1800.     if (trouve){
  1801.       printf("%s\n",pref_units[i].sym);
  1802.       return;
  1803.     }
  1804.   }
  1805.   for (i=0; i<BU_LAST; i++){
  1806.     if (result.base[i]!=0){
  1807.       if (notfirst) printf(".");
  1808.       printf("%s",unit_names[i]);
  1809.       notfirst=1;
  1810.       if (result.base[i]!=1){
  1811.         printf("^%d",result.base[i]);
  1812.       }
  1813.     }
  1814.   }
  1815.   printf("\n");
  1816. }
  1817.  
  1818. int main(int argc, char * argv[]){
  1819.   char * optstr = "os";
  1820.   int ch;
  1821.   while (-1 != (ch=getopt(argc,argv,optstr))){
  1822.     switch(ch){
  1823.     case 's':
  1824.       count_signif=1;
  1825.       sortie_normalisee();
  1826.       return 0;
  1827.       break;
  1828.     case 'o':
  1829.       sortie_texte();
  1830.       return 0;
  1831.       break;
  1832.     default:
  1833.       break;
  1834.     }
  1835.   }
  1836.   /*test_verbeux();*/
  1837.   sortie_normalisee();
  1838.   return 0;
  1839. }
  1840.