File: lexer.l

package info (click to toggle)
sollya 8.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,592 kB
  • sloc: ansic: 124,655; yacc: 7,543; lex: 2,440; makefile: 888; cpp: 77
file content (887 lines) | stat: -rw-r--r-- 32,649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
/*

Copyright 2006-2022 by

Laboratoire de l'Informatique du Parallelisme,
UMR CNRS - ENS Lyon - UCB Lyon 1 - INRIA 5668,

LORIA (CNRS, INPL, INRIA, UHP, U-Nancy 2),

Centre de recherche INRIA Sophia Antipolis Mediterranee, equipe FACTAS,
Sophia Antipolis, France,

Laboratoire d'Informatique de Paris 6, equipe PEQUAN,
UPMC Universite Paris 06 - CNRS - UMR 7606 - LIP6, Paris, France

and by

Laboratoire d'Informatique de Paris 6 - Équipe PEQUAN
Sorbonne Universités
UPMC Univ Paris 06
UMR 7606, LIP6
Boîte Courrier 169
4, place Jussieu
F-75252 Paris Cedex 05
France

and by

Department of Computer Science & Engineering
UAA College of Engineering
University of Alaska Anchorage.

Contributors Ch. Lauter, S. Chevillard

christoph.lauter@christoph-lauter.org
sylvain.chevillard@ens-lyon.org

This software is a computer program whose purpose is to provide an
environment for safe floating-point code development. It is
particularly targeted to the automated implementation of
mathematical floating-point libraries (libm). Amongst other features,
it offers a certified infinity norm, an automatic polynomial
implementer and a fast Remez algorithm.

This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software.  You can  use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".

As a counterpart to the access to the source code and  rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty  and the software's author,  the holder of the
economic rights,  and the successive licensors  have only  limited
liability.

In this respect, the user's attention is drawn to the risks associated
with loading,  using,  modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean  that it is complicated to manipulate,  and  that  also
therefore means  that it is reserved for developers  and  experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and,  more generally, to use and operate it in the
same conditions as regards security.

The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.

This program is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*/

%{

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "expression.h"
#include "parser.h"
#include "general.h"
#include "chain.h"

#define YY_NO_UNPUT 1
#define YY_NO_INPUT 1

/* Mess with the mallocs used by the lexer */
extern void *parserCalloc(size_t, size_t);
extern void *parserMalloc(size_t);
extern void *parserRealloc(void *, size_t);
extern void parserFree(void *);
#undef malloc
#undef realloc
#undef calloc
#undef free
#define malloc parserMalloc
#define realloc parserRealloc
#define calloc parserCalloc
#define free UNUSED_PARAM(yyscanner); parserFree
/* End of the malloc mess */

/* Mess with fprintf to use sollyaFprintf instead. */
#undef  fprintf
#define fprintf UNUSED_PARAM(yyscanner); sollyaFprintf
/* End of fprintf mess */

/* Mess with getc... and fread to use sollya_getc, sollya_feof, sollya_ferror, sollya_fwrite and sollya_fread instead. */
#undef  getc
#undef  fread
#undef  feof
#undef  ferror
#undef  fwrite
#define getc sollya_getc
#define fread sollya_fread
#define feof sollya_feof
#define ferror sollya_ferror
#define fwrite sollya_fwrite
/* End of getc, feof, ferror, fwrite and fread mess */

/* const mess */
#if defined(const)
#undef const
#endif
/* End of the const mess */

%}

%option noyyalloc noyyrealloc noyyfree

%option noyywrap
%option always-interactive
%option reentrant
%option bison-bridge
%option nounput

%x commentstate

CHAR		[a-zA-Z]
NUMBER		[0-9]
HEXNUMBER       (([0-9])|([ABCDEFabcdef]))
SPECIAL         [_$§]

HEXADECIMALCONSTANT ("0x"|"0X")(({HEXNUMBER}*"."{HEXNUMBER}+)|({HEXNUMBER}+((".")?)))(("p"|"P")(((([+-])?)({NUMBER}+))?))

ACONSTANT        ((({NUMBER}+|({NUMBER}*"."{NUMBER}+))(((((" ")*)(([eE]))([+-])?{NUMBER}+)?)))|("infty"|"nan"|"NAN"|"NaN"|"@Inf@"|"@NaN@"))
CONSTANT        ({ACONSTANT})|((("%")({NUMBER})({NUMBER}+)("%"))({ACONSTANT}))
DYADICCONSTANT  ({NUMBER}+)([bB])([+-]?)({NUMBER}+)
HEXCONSTANT     ("0x")({HEXNUMBER}{16}|{HEXNUMBER}{8})

BINARYCONSTANT  (([0-1])+|(([0-1])*"."([0-1])+))"_2"

AMIDPOINTCONSTANT        (({NUMBER}+|({NUMBER}*"."{NUMBER}+))(("~"({NUMBER})+("/")({NUMBER})+("~")))(((((" ")*)(([eE]))([+-])?{NUMBER}+)?)))
MIDPOINTCONSTANT         (({AMIDPOINTCONSTANT})|(("-")((" ")*)({AMIDPOINTCONSTANT})))


IDENTIFIER        ({CHAR}|{SPECIAL})({CHAR}|{NUMBER}|{SPECIAL})*

DOT             "."    

LPAR            "("
RPAR            ")"

LBRACKET        "["
RBRACKET        "]"

PI              ("pi")|("Pi")

PLUS            "+"
MINUS           "-"
APPROX          "~"
MUL             "*"
DIV             "/"
POW             "^"
SQRT            "sqrt"
EXP             "exp"
FREEVAR         "_x_"
LOG             "log"
LOG2            "log2"
LOG10           "log10"
SIN             "sin"
COS             "cos"
TAN             "tan"
ASIN            "asin"
ACOS            "acos"
ATAN            "atan"
SINH            "sinh"
COSH            "cosh"
TANH            "tanh"
ASINH           "asinh"
ACOSH           "acosh"
ATANH           "atanh"
ABS             "abs"
ERF             "erf"
ERFC            "erfc"
LOG1P           "log1p"
EXPM1           "expm1"

EQUAL           "="
COMMA           ","
PREC            "prec"
POINTS          "points"
EXCLAMATION     "!"
DOUBLECOLON     "::"
COLON           ":"
DOTCOLON        ".:"
COLONDOT        ":."
ASSIGNEQUAL     ":="

SEMICOLON       ";"
QUIT            "quit"
PRINT           "print"
SUPPRESSMESSAGE "suppressmessage"
UNSUPPRESSMESSAGE "unsuppressmessage"
DIFF            "diff"
DIRTYSIMPLIFY   "dirtysimplify"
CANONICAL       "canonical"
PLOT            "plot"
REMEZ           "remez"
ANNOTATEFUNCTION "annotatefunction"
FPMINIMAX       "fpminimax"
INFNORM         "infnorm"
SUPNORM         "supnorm"
DIAM            "diam"

DOUBLELONG       "double"
SINGLELONG       "single"
QUADLONG         "quad"
HALFPRECISIONLONG "halfprecision"
DOUBLEDOUBLELONG "doubledouble"
TRIPLEDOUBLELONG "tripledouble"
DOUBLEEXTENDEDLONG "doubleextended"


DOUBLESHORT      "D"
SINGLESHORT      "SG"
QUADSHORT        "QD"
HALFPRECISIONSHORT "HP"
DOUBLEDOUBLESHORT "DD"
TRIPLEDOUBLESHORT "TD"
DOUBLEEXTENDEDSHORT "DE"


DOUBLE          ({DOUBLELONG}|{DOUBLESHORT})
SINGLE          ({SINGLELONG}|{SINGLESHORT})
QUAD            ({QUADLONG}|{QUADSHORT})
HALFPRECISION   ({HALFPRECISIONLONG}|{HALFPRECISIONSHORT})
DOUBLEDOUBLE    ({DOUBLEDOUBLELONG}|{DOUBLEDOUBLESHORT})
TRIPLEDOUBLE    ({TRIPLEDOUBLELONG}|{TRIPLEDOUBLESHORT})
DOUBLEEXTENDED  ({DOUBLEEXTENDEDLONG}|{DOUBLEEXTENDEDSHORT})

HORNER          "horner"
DEGREE          "degree"
EXPAND          "expand"

SIMPLIFYSAFE1   "simplify"
SIMPLIFYSAFE2   "simplifysafe"

SIMPLIFYSAFE    ({SIMPLIFYSAFE1}|{SIMPLIFYSAFE2})

TAYLOR          "taylor"
TAYLORFORM      "taylorform"
CHEBYSHEVFORM   "chebyshevform"
AUTODIFF        "autodiff"

FINDZEROS       "findzeros"
FPFINDZEROS     "fpfindzeros"
DIRTYINFNORM    "dirtyinfnorm"
GCD             "gcd"
EUCLDIV         "div"
EUCLMOD         "mod"
NUMBERROOTS     "numberroots"

EVALUATE        "evaluate"


NUMERATOR       "numerator"
DENOMINATOR     "denominator"

DYADIC          "dyadic"
DISPLAY         "display"
ON              "on"
OFF             "off"
POWERS          "powers"
BINARY          "binary"
HEXADECIMAL     "hexadecimal"

INTEGRAL        "integral"
DIRTYINTEGRAL   "dirtyintegral"

STRINGDELIMITER [\"]
OCTALCHAR       [01234567]
OCTAL           ({OCTALCHAR})(({OCTALCHAR})?)(({OCTALCHAR})?)
HEXACHAR        [0123456789ABCDEFabcdef]
HEXA            ({HEXACHAR})(({HEXACHAR})?)
STRING          ({STRINGDELIMITER})((("\\\\")|(("\\")[\"\'\?ntabfrv])|(("\\")({OCTAL}))|(("\\x")({HEXA}))|([^\"\\]))*)({STRINGDELIMITER})


VERBOSITY       "verbosity"
SHOWMESSAGENUMBERS "showmessagenumbers"

WORSTCASE       "worstcase"

LEFTANGLE       "<"
RIGHTANGLEUNDERSCORE ">_"
RIGHTANGLEDOT ">."
RIGHTANGLE      ">"
STARLEFTANGLE   "*<"
RIGHTANGLESTAR  ">*"

COMPAREEQUAL    "=="
EXCLAMATIONEQUAL "!="

AND             "&&"
OR              "||"

SUBSTITUTE      "substitute"
COMPOSEPOLYNOMIALS "composepolynomials"
BEZOUT          "bezout"

DOTS            "..."

IMPLEMENTPOLY   "implementpoly"
IMPLEMENTCONST  "implementconstant"

INTERPOLATE     "interpolate"

CHECKINFNORM    "checkinfnorm"

TAYLORRECURSIONS "taylorrecursions"

PRINTHEXA       ("printhexa"|"printdouble")
PRINTFLOAT      ("printfloat"|"printsingle")
PRINTBINARY     "printbinary"

ROUNDCOEFFICIENTS "roundcoefficients"


RESTART         "restart"


ZERODENOMINATORS "zerodenominators"
ISEVALUABLE     "isevaluable"
HONORCOEFFPREC  "honorcoeffprec"

ACCURATEINFNORM  "accurateinfnorm"


FILE            "file"
POSTSCRIPT      "postscript"
POSTSCRIPTFILE  "postscriptfile"

PRINTEXPANSION  "printexpansion"

BASHEXECUTE     "bashexecute"
BASHEVALUATE    "bashevaluate"
GETSUPPRESSEDMESSAGES "getsuppressedmessages"
GETBACKTRACE    "getbacktrace"
EXTERNALPLOT    "externalplot"
PERTURB         "perturb"

COEFF           "coeff"
SUBPOLY         "subpoly"

QUESTIONMARK    "?"

SEARCHGAL       "searchgal"


RATIONALAPPROX  "rationalapprox"

COMMENTSTART    "/*"
COMMENTEND      "*/"

ONELINECOMMENT  ("//"|"#!")([^\n])*"\n"

WRITE           "write"

ASCIIPLOT       "asciiplot"


ROUNDTOFORMAT   "round"
MINUSWORD       "RD"
PLUSWORD        "RU"
ZEROWORD        "RZ"
NEAREST         "RN"


GUESSDEGREE     "guessdegree"

PARSE           "parse"

AUTOSIMPLIFY    "autosimplify"

TIMING          "timing"
TIME            "time"
FULLPARENTHESES "fullparentheses"
MIDPOINTMODE    "midpointmode"
SUPPRESSWARNINGS "roundingwarnings"
RATIONALMODE    "rationalmode"
DIEONERRORMODE  "dieonerrormode"

LIBRARY         "library"
LIBRARYCONSTANT "libraryconstant"

HOPITALRECURSIONS "hopitalrecursions"

HELP            "help"

DIRTYFINDZEROS  "dirtyfindzeros"

CEIL            "ceil"
FLOOR           "floor"
NEARESTINT      "nearestint"

HEAD            "head"
TAIL            "tail"

VERTBAR         "|"
AT              "@"

IF              "if"
THEN            "then"
ELSE            "else"
FOR             "for"
IN              "in"
FROM            "from"
TO              "to"
BY              "by"
DO              "do"
BEGIN           "begin"
END             "end"
LBRACE          "{"
RBRACE          "}"

WHILEDEF        "while"

TRUE            "true"
FALSE           "false"
DEFAULT         "default"

MATCH           "match"
WITH            "with"

RENAME          "rename"
BIND            "bind"
OBJECTNAME      "objectname"

LENGTH          "length"

ABSOLUTE        "absolute"
RELATIVE        "relative"
DECIMAL         "decimal"
FIXED           "fixed"
FLOATING        "floating"

ERROR           "error"

PRINTXML        "printxml"

INF             "inf"
MID             "mid"
SUP             "sup"

MIN             "min"
MAX             "max"

READXML         "readxml"

MANTISSA        "mantissa"
EXPONENT        "exponent"
PRECISION       "precision"

REVERT          "revert"
SORT            "sort"

READFILE        "readfile"

ROUNDCORRECTLY  "roundcorrectly"

EXECUTE         "execute"

VERSION         "version"

ISBOUND         "isbound"

EXTERNALPROC    "externalproc"
EXTERNALDATA    "externaldata"
VOID            "void"
CONSTANTTYPE    "constant"
FUNCTION        "function"
OBJECT          "object"
RANGE           "range"
INTEGER         "integer"
STRINGTYPE      "string"
BOOLEAN         "boolean"
LIST            "list"
OF              "of"

VAR             "var"

PROC            "proc"
PROCEDURE       "procedure"
RETURN          "return"
NOP             "nop"

%%




{COMMENTSTART}  {     BEGIN(commentstate); }

<commentstate>{COMMENTEND} { BEGIN(INITIAL); }

<commentstate>. { /* Eat up comments */

                 }

<commentstate>[\n] { /* Eat up newlines in comments */

		}



{ONELINECOMMENT} {  /* Eat up comments */
                     carriageReturnLexed();
                 }

<<EOF>>         {
		     if (!eliminatePromptBackup) sollyaPrintf("\n");
		     yyterminate();
                }

{MIDPOINTCONSTANT}                          {
					      constBuffer2 = (char *) safeCalloc(yyleng+1,sizeof(char));
					      if (removeSpaces(constBuffer2,yytext)) {
						printMessage(2,SOLLYA_MSG_SPACES_REMOVED_FROM_CONSTANT_IN_SCIENTIF_NOTAT,"Information: removed spaces in scientific notation constant \"%s\", it will be considered as \"%s\"\n",yytext,constBuffer2);
					      }
					      yylval->value = constBuffer2;
                                              newTokenLexed(); return MIDPOINTCONSTANTTOKEN; }
{CONSTANT}                                  {
					      constBuffer2 = (char *) safeCalloc(yyleng+1,sizeof(char));
					      if (removeSpaces(constBuffer2,yytext)) {
						printMessage(2,SOLLYA_MSG_SPACES_REMOVED_FROM_CONSTANT_IN_SCIENTIF_NOTAT,"Information: removed spaces in scientific notation constant \"%s\", it will be considered as \"%s\"\n",yytext,constBuffer2);
					      }
					      yylval->value = constBuffer2;
                                              newTokenLexed(); return CONSTANTTOKEN; }
{DYADICCONSTANT} 			    {
                                              constBuffer = (char *) safeCalloc(yyleng+1,sizeof(char));
					      strncpy(constBuffer,yytext,yyleng);
					      yylval->value = constBuffer;
                                              newTokenLexed(); return DYADICCONSTANTTOKEN; }
{HEXADECIMALCONSTANT}     		    { constBuffer = (char *) safeCalloc(yyleng+1,sizeof(char));
					      strncpy(constBuffer,yytext,yyleng);
					      yylval->value = constBuffer;
                                              newTokenLexed(); return HEXADECIMALCONSTANTTOKEN; }
{HEXCONSTANT}     			    { constBuffer = (char *) safeCalloc(yyleng+1,sizeof(char));
					      strncpy(constBuffer,yytext,yyleng);
					      yylval->value = constBuffer;
                                              newTokenLexed(); return HEXCONSTANTTOKEN; }
{BINARYCONSTANT}  			    { constBuffer = (char *) safeCalloc(yyleng-1,sizeof(char));
					      strncpy(constBuffer,yytext,yyleng-2);
					      yylval->value = constBuffer;
                                              newTokenLexed(); return BINARYCONSTANTTOKEN; }

{PI}              			    { newTokenLexed(); return PITOKEN; }

{STRING}          			    {
					      constBuffer = (char *) safeCalloc(yyleng-1,sizeof(char));
					      constBuffer2 = (char *) safeCalloc(yyleng-1,sizeof(char));
					      strncpy(constBuffer2,yytext+1,yyleng-2);
					      demaskString(constBuffer,constBuffer2);
					      safeFree(constBuffer2);
					      yylval->value = constBuffer;
                                              newTokenLexed(); return STRINGTOKEN; }

{LPAR}            			    { newTokenLexed(); return LPARTOKEN; }
{RPAR}            			    { newTokenLexed(); return RPARTOKEN; }
{LBRACKET}        			    { newTokenLexed(); return LBRACKETTOKEN; }
{RBRACKET}        			    { newTokenLexed(); return RBRACKETTOKEN; }
{EXCLAMATIONEQUAL}			    { newTokenLexed(); return EXCLAMATIONEQUALTOKEN; }
{COMPAREEQUAL}                              { newTokenLexed(); return COMPAREEQUALTOKEN; }
{EQUAL}           			    { newTokenLexed(); return EQUALTOKEN; }
{ASSIGNEQUAL}          			    { newTokenLexed(); return ASSIGNEQUALTOKEN; }
{COMMA}           			    { newTokenLexed(); return COMMATOKEN; }
{EXCLAMATION}				    { newTokenLexed(); return EXCLAMATIONTOKEN; }
{SEMICOLON}       			    { newTokenLexed(); return SEMICOLONTOKEN; }
{LEFTANGLE}       			    { newTokenLexed(); return LEFTANGLETOKEN; }
{STARLEFTANGLE}   			    { newTokenLexed(); return STARLEFTANGLETOKEN; }
{RIGHTANGLEUNDERSCORE}			    { newTokenLexed(); return RIGHTANGLEUNDERSCORETOKEN; }
{RIGHTANGLEDOT} 			    { newTokenLexed(); return RIGHTANGLEDOTTOKEN; }
{RIGHTANGLESTAR}			    { newTokenLexed(); return RIGHTANGLESTARTOKEN; }
{RIGHTANGLE}      			    { newTokenLexed(); return RIGHTANGLETOKEN; }
{DOTS}            			    { newTokenLexed(); return DOTSTOKEN; }
{DOT}            			    { newTokenLexed(); return DOTTOKEN; }
{QUESTIONMARK}				    { newTokenLexed(); return QUESTIONMARKTOKEN; }
{AND}         				    { newTokenLexed(); return ANDTOKEN; }
{OR}         				    { newTokenLexed(); return ORTOKEN; }
{VERTBAR}				    { newTokenLexed(); return VERTBARTOKEN; }
{VAR}					    { newTokenLexed(); return VARTOKEN; }
{PROC}					    { newTokenLexed(); return PROCTOKEN; }
{PROCEDURE}				    { newTokenLexed(); return PROCEDURETOKEN; }
{RETURN}				    { newTokenLexed(); return RETURNTOKEN; }
{NOP}	         			    { newTokenLexed(); return NOPTOKEN; }
{AT}					    { newTokenLexed(); return ATTOKEN; }
{DOUBLECOLON}				    { newTokenLexed(); return DOUBLECOLONTOKEN; }
{COLON}  				    { newTokenLexed(); return COLONTOKEN; }
{DOTCOLON}				    { newTokenLexed(); return DOTCOLONTOKEN; }
{COLONDOT}				    { newTokenLexed(); return COLONDOTTOKEN; }

{PLUS}            			    { newTokenLexed(); return PLUSTOKEN; }
{MINUS}           			    { newTokenLexed(); return MINUSTOKEN; }
{APPROX}           			    { newTokenLexed(); return APPROXTOKEN; }
{MUL}          				    { newTokenLexed(); return MULTOKEN; }
{DIV}            			    { newTokenLexed(); return DIVTOKEN; }
{POW}            			    { newTokenLexed(); return POWTOKEN; }

{SQRT}            			    { newTokenLexed(); return SQRTTOKEN; }
{EXP}             			    { newTokenLexed(); return EXPTOKEN; }
{FREEVAR}             			    { newTokenLexed(); return FREEVARTOKEN; }
{LOG}             			    { newTokenLexed(); return LOGTOKEN; }
{LOG2}            			    { newTokenLexed(); return LOG2TOKEN; }
{LOG10}           			    { newTokenLexed(); return LOG10TOKEN; }
{SIN}             			    { newTokenLexed(); return SINTOKEN; }
{COS}             			    { newTokenLexed(); return COSTOKEN; }
{TAN}             			    { newTokenLexed(); return TANTOKEN; }
{ASIN}            			    { newTokenLexed(); return ASINTOKEN; }
{ACOS}            			    { newTokenLexed(); return ACOSTOKEN; }
{ATAN}            			    { newTokenLexed(); return ATANTOKEN; }
{SINH}            			    { newTokenLexed(); return SINHTOKEN; }
{COSH}            			    { newTokenLexed(); return COSHTOKEN; }
{TANH}            			    { newTokenLexed(); return TANHTOKEN; }
{ASINH}           			    { newTokenLexed(); return ASINHTOKEN; }
{ACOSH}           			    { newTokenLexed(); return ACOSHTOKEN; }
{ATANH}           			    { newTokenLexed(); return ATANHTOKEN; }
{ABS}             			    { newTokenLexed(); return ABSTOKEN; }
{ERF}             			    { newTokenLexed(); return ERFTOKEN; }
{ERFC}            			    { newTokenLexed(); return ERFCTOKEN; }
{LOG1P}           			    { newTokenLexed(); return LOG1PTOKEN; }
{EXPM1}           			    { newTokenLexed(); return EXPM1TOKEN; }
{DOUBLE}          			    { newTokenLexed(); return DOUBLETOKEN; }
{SINGLE}          			    { newTokenLexed(); return SINGLETOKEN; }
{QUAD}          			    { newTokenLexed(); return QUADTOKEN; }
{HALFPRECISION}          		    { newTokenLexed(); return HALFPRECISIONTOKEN; }
{DOUBLEDOUBLE}				    { newTokenLexed(); return DOUBLEDOUBLETOKEN; }
{TRIPLEDOUBLE}    			    { newTokenLexed(); return TRIPLEDOUBLETOKEN; }
{DOUBLEEXTENDED}  			    { newTokenLexed(); return DOUBLEEXTENDEDTOKEN; }
{CEIL}            			    { newTokenLexed(); return CEILTOKEN; }
{FLOOR}           			    { newTokenLexed(); return FLOORTOKEN; }
{NEARESTINT}           			    { newTokenLexed(); return NEARESTINTTOKEN; }

{PREC}            			    { newTokenLexed(); return PRECTOKEN; }
{POINTS}          			    { newTokenLexed(); return POINTSTOKEN; }
{DIAM}            			    { newTokenLexed(); return DIAMTOKEN; }
{DISPLAY}          			    { newTokenLexed(); return DISPLAYTOKEN; }
{VERBOSITY}       			    { newTokenLexed(); return VERBOSITYTOKEN; }
{SHOWMESSAGENUMBERS}			    { newTokenLexed(); return SHOWMESSAGENUMBERSTOKEN; }
{CANONICAL}       			    { newTokenLexed(); return CANONICALTOKEN; }
{AUTOSIMPLIFY}    			    { newTokenLexed(); return AUTOSIMPLIFYTOKEN; }
{TAYLORRECURSIONS}			    { newTokenLexed(); return TAYLORRECURSIONSTOKEN; }
{TIMING}          			    { newTokenLexed(); return TIMINGTOKEN; }
{TIME}          			    { newTokenLexed(); return TIMETOKEN; }
{FULLPARENTHESES} 			    { newTokenLexed(); return FULLPARENTHESESTOKEN; }
{MIDPOINTMODE}    			    { newTokenLexed(); return MIDPOINTMODETOKEN; }
{DIEONERRORMODE}    			    { newTokenLexed(); return DIEONERRORMODETOKEN; }
{SUPPRESSWARNINGS}			    { newTokenLexed(); return SUPPRESSWARNINGSTOKEN; }
{RATIONALMODE}			            { newTokenLexed(); return RATIONALMODETOKEN; }
{HOPITALRECURSIONS}			    { newTokenLexed(); return HOPITALRECURSIONSTOKEN; }

{ON}              			    { newTokenLexed(); return ONTOKEN; }
{OFF}             			    { newTokenLexed(); return OFFTOKEN; }
{DYADIC}				    { newTokenLexed(); return DYADICTOKEN; }
{POWERS}          			    { newTokenLexed(); return POWERSTOKEN; }
{BINARY}          			    { newTokenLexed(); return BINARYTOKEN; }
{HEXADECIMAL}          			    { newTokenLexed(); return HEXADECIMALTOKEN; }
{FILE}            			    { newTokenLexed(); return FILETOKEN; }
{POSTSCRIPT}      			    { newTokenLexed(); return POSTSCRIPTTOKEN; }
{POSTSCRIPTFILE}  			    { newTokenLexed(); return POSTSCRIPTFILETOKEN; }
{PERTURB}         			    { newTokenLexed(); return PERTURBTOKEN; }
{MINUSWORD}       			    { newTokenLexed(); return MINUSWORDTOKEN; }
{PLUSWORD}        			    { newTokenLexed(); return PLUSWORDTOKEN; }
{ZEROWORD}        			    { newTokenLexed(); return ZEROWORDTOKEN; }
{NEAREST}         			    { newTokenLexed(); return NEARESTTOKEN; }
{HONORCOEFFPREC} 			    { newTokenLexed(); return HONORCOEFFPRECTOKEN; }
{TRUE}					    { newTokenLexed(); return TRUETOKEN; }
{FALSE}					    { newTokenLexed(); return FALSETOKEN; }
{DEFAULT}				    { newTokenLexed(); return DEFAULTTOKEN; }
{MATCH} 				    { newTokenLexed(); return MATCHTOKEN; }
{WITH}  				    { newTokenLexed(); return WITHTOKEN; }
{HEAD}   				    { newTokenLexed(); return HEADTOKEN; }
{ROUNDCORRECTLY}   		       	    { newTokenLexed(); return ROUNDCORRECTLYTOKEN; }
{REVERT}   				    { newTokenLexed(); return REVERTTOKEN; }
{SORT}   				    { newTokenLexed(); return SORTTOKEN; }
{MANTISSA}   				    { newTokenLexed(); return MANTISSATOKEN; }
{EXPONENT}   				    { newTokenLexed(); return EXPONENTTOKEN; }
{PRECISION}   				    { newTokenLexed(); return PRECISIONTOKEN; }
{TAIL}   				    { newTokenLexed(); return TAILTOKEN; }
{INF}   				    { newTokenLexed(); return INFTOKEN; }
{MID}   				    { newTokenLexed(); return MIDTOKEN; }
{SUP}   				    { newTokenLexed(); return SUPTOKEN; }
{MIN}   				    { newTokenLexed(); return MINTOKEN; }
{MAX}   				    { newTokenLexed(); return MAXTOKEN; }
{READXML}   				    { newTokenLexed(); return READXMLTOKEN; }
{LENGTH}   				    { newTokenLexed(); return LENGTHTOKEN; }
{ABSOLUTE}   				    { newTokenLexed(); return ABSOLUTETOKEN; }
{RELATIVE}   				    { newTokenLexed(); return RELATIVETOKEN; }
{DECIMAL}   				    { newTokenLexed(); return DECIMALTOKEN; }
{FIXED}   				    { newTokenLexed(); return FIXEDTOKEN; }
{FLOATING}   				    { newTokenLexed(); return FLOATINGTOKEN; }

{ERROR}   				    { newTokenLexed(); return ERRORTOKEN; }
{READFILE}   				    { newTokenLexed(); return READFILETOKEN; }
{ISBOUND}   				    { newTokenLexed(); return ISBOUNDTOKEN; }

{QUIT}            			    {
                                              newTokenLexed();
                                              return QUITTOKEN;
                                            }
{RESTART}         			    { newTokenLexed(); return RESTARTTOKEN; }
{VERSION}         			    { newTokenLexed(); return VERSIONTOKEN; }

{LIBRARY}         			    { newTokenLexed(); return LIBRARYTOKEN; }
{LIBRARYCONSTANT}         		    { newTokenLexed(); return LIBRARYCONSTANTTOKEN; }

{DIFF}            			    { newTokenLexed(); return DIFFTOKEN; }
{DIRTYSIMPLIFY}				    { newTokenLexed(); return DIRTYSIMPLIFYTOKEN; }
{REMEZ}           			    { newTokenLexed(); return REMEZTOKEN; }
{ANNOTATEFUNCTION}           		    { newTokenLexed(); return ANNOTATEFUNCTIONTOKEN; }
{FPMINIMAX}           			    { newTokenLexed(); return FPMINIMAXTOKEN; }
{HORNER}          			    { newTokenLexed(); return HORNERTOKEN; }
{EXPAND}          			    { newTokenLexed(); return EXPANDTOKEN; }
{SIMPLIFYSAFE}				    { newTokenLexed(); return SIMPLIFYSAFETOKEN; }
{TAYLOR}         			    { newTokenLexed(); return TAYLORTOKEN; }
{TAYLORFORM}         			    { newTokenLexed(); return TAYLORFORMTOKEN; }
{CHEBYSHEVFORM}         		    { newTokenLexed(); return CHEBYSHEVFORMTOKEN; }
{AUTODIFF}         			    { newTokenLexed(); return AUTODIFFTOKEN; }
{DEGREE}          			    { newTokenLexed(); return DEGREETOKEN; }
{NUMERATOR}       			    { newTokenLexed(); return NUMERATORTOKEN; }
{DENOMINATOR}     			    { newTokenLexed(); return DENOMINATORTOKEN; }
{SUBSTITUTE}      			    { newTokenLexed(); return SUBSTITUTETOKEN; }
{COMPOSEPOLYNOMIALS}      		    { newTokenLexed(); return COMPOSEPOLYNOMIALSTOKEN; }
{BEZOUT}      		                    { newTokenLexed(); return BEZOUTTOKEN; }
{COEFF}           			    { newTokenLexed(); return COEFFTOKEN; }
{SUBPOLY}         			    { newTokenLexed(); return SUBPOLYTOKEN; }
{ROUNDCOEFFICIENTS} 			    { newTokenLexed(); return ROUNDCOEFFICIENTSTOKEN; }
{RATIONALAPPROX}  			    { newTokenLexed(); return RATIONALAPPROXTOKEN; }
{ACCURATEINFNORM}  			    { newTokenLexed(); return ACCURATEINFNORMTOKEN; }
{ROUNDTOFORMAT}   			    { newTokenLexed(); return ROUNDTOFORMATTOKEN; }
{EVALUATE}        			    { newTokenLexed(); return EVALUATETOKEN; }

{PARSE}           			    { newTokenLexed(); return PARSETOKEN; }

{PRINT}           			    { newTokenLexed(); return PRINTTOKEN; }
{SUPPRESSMESSAGE}           		    { newTokenLexed(); return SUPPRESSMESSAGETOKEN; }
{UNSUPPRESSMESSAGE}           		    { newTokenLexed(); return UNSUPPRESSMESSAGETOKEN; }
{PRINTXML}           			    { newTokenLexed(); return PRINTXMLTOKEN; }
{EXECUTE}           			    { newTokenLexed(); return EXECUTETOKEN; }
{PLOT}            			    { newTokenLexed(); return PLOTTOKEN; }
{PRINTHEXA}       			    { newTokenLexed(); return PRINTHEXATOKEN; }
{PRINTFLOAT}       			    { newTokenLexed(); return PRINTFLOATTOKEN; }
{PRINTBINARY}     			    { newTokenLexed(); return PRINTBINARYTOKEN; }
{PRINTEXPANSION}  			    { newTokenLexed(); return PRINTEXPANSIONTOKEN; }
{BASHEXECUTE}     			    { newTokenLexed(); return BASHEXECUTETOKEN; }
{BASHEVALUATE}     			    { newTokenLexed(); return BASHEVALUATETOKEN; }
{GETSUPPRESSEDMESSAGES}     		    { newTokenLexed(); return GETSUPPRESSEDMESSAGESTOKEN; }
{GETBACKTRACE}     		            { newTokenLexed(); return GETBACKTRACETOKEN; }
{EXTERNALPLOT}    			    { newTokenLexed(); return EXTERNALPLOTTOKEN; }
{WRITE}           			    { newTokenLexed(); return WRITETOKEN; }
{ASCIIPLOT}       			    { newTokenLexed(); return ASCIIPLOTTOKEN; }
{RENAME}         			    { newTokenLexed(); return RENAMETOKEN; }
{OBJECTNAME}         			    { newTokenLexed(); return OBJECTNAMETOKEN; }
{BIND}         			            { newTokenLexed(); return BINDTOKEN; }

{INFNORM}         			    { newTokenLexed(); return INFNORMTOKEN; }
{SUPNORM}         			    { newTokenLexed(); return SUPNORMTOKEN; }
{FINDZEROS}       			    { newTokenLexed(); return FINDZEROSTOKEN; }
{FPFINDZEROS}     			    { newTokenLexed(); return FPFINDZEROSTOKEN; }
{DIRTYINFNORM}    			    { newTokenLexed(); return DIRTYINFNORMTOKEN; }
{GCD}     			            { newTokenLexed(); return GCDTOKEN; }
{EUCLDIV}     			            { newTokenLexed(); return EUCLDIVTOKEN; }
{EUCLMOD}     			            { newTokenLexed(); return EUCLMODTOKEN; }
{NUMBERROOTS}    			    { newTokenLexed(); return NUMBERROOTSTOKEN; }
{INTEGRAL}        			    { newTokenLexed(); return INTEGRALTOKEN; }
{DIRTYINTEGRAL}				    { newTokenLexed(); return DIRTYINTEGRALTOKEN; }
{WORSTCASE}       			    { newTokenLexed(); return WORSTCASETOKEN; }
{IMPLEMENTPOLY}				    { newTokenLexed(); return IMPLEMENTPOLYTOKEN; }
{IMPLEMENTCONST}                            { newTokenLexed(); return IMPLEMENTCONSTTOKEN; }
{INTERPOLATE}				    { newTokenLexed(); return INTERPOLATETOKEN; }
{CHECKINFNORM}    			    { newTokenLexed(); return CHECKINFNORMTOKEN; }
{ZERODENOMINATORS}			    { newTokenLexed(); return ZERODENOMINATORSTOKEN; }
{ISEVALUABLE}     			    { newTokenLexed(); return ISEVALUABLETOKEN; }
{SEARCHGAL}       			    { newTokenLexed(); return SEARCHGALTOKEN; }
{GUESSDEGREE}     			    { newTokenLexed(); return GUESSDEGREETOKEN; }
{DIRTYFINDZEROS}  			    { newTokenLexed(); return DIRTYFINDZEROSTOKEN; }

{IF}					    { newTokenLexed(); return IFTOKEN; }
{THEN}					    { newTokenLexed(); return THENTOKEN; }
{ELSE}					    { newTokenLexed(); return ELSETOKEN; }
{FOR}					    { newTokenLexed(); return FORTOKEN; }
{IN}					    { newTokenLexed(); return INTOKEN; }
{FROM}					    { newTokenLexed(); return FROMTOKEN; }
{TO}					    { newTokenLexed(); return TOTOKEN; }
{BY}					    { newTokenLexed(); return BYTOKEN; }
{DO}					    { newTokenLexed(); return DOTOKEN; }
{BEGIN}					    { newTokenLexed(); return BEGINTOKEN; }
{END}					    { newTokenLexed(); return ENDTOKEN; }
{LBRACE}				    { newTokenLexed(); return LEFTCURLYBRACETOKEN; }
{RBRACE}				    { newTokenLexed(); return RIGHTCURLYBRACETOKEN; }
{WHILEDEF}				    { newTokenLexed(); return WHILETOKEN; }

{EXTERNALPROC}                              { newTokenLexed(); return EXTERNALPROCTOKEN; }
{EXTERNALDATA}                              { newTokenLexed(); return EXTERNALDATATOKEN; }
{VOID}                                      { newTokenLexed(); return VOIDTOKEN; }
{CONSTANTTYPE}                              { newTokenLexed(); return CONSTANTTYPETOKEN; }
{FUNCTION}                                  { newTokenLexed(); return FUNCTIONTOKEN; }
{OBJECT}                                    { newTokenLexed(); return OBJECTTOKEN; }
{RANGE}                                     { newTokenLexed(); return RANGETOKEN; }
{INTEGER}                                   { newTokenLexed(); return INTEGERTOKEN; }
{STRINGTYPE}                                { newTokenLexed(); return STRINGTYPETOKEN; }
{BOOLEAN}                                   { newTokenLexed(); return BOOLEANTOKEN; }
{LIST}                                      { newTokenLexed(); return LISTTOKEN; }
{OF}                                        { newTokenLexed(); return OFTOKEN; }

{HELP}            			    { newTokenLexed(); return HELPTOKEN; }


[ \t]		{ /* Eat up spaces and tabulators */
		}

[\r]            { /* Eat up carriage return for compatibility with DOS-like systems */
                }

[\n]		{
                     carriageReturnLexed();
		}

{IDENTIFIER}        			    { constBuffer = (char *) safeCalloc(yyleng+1,sizeof(char));
					      strncpy(constBuffer,yytext,yyleng);
					      yylval->value = constBuffer;
					      newTokenLexed(); return IDENTIFIERTOKEN; }

.		{ /* otherwise */
			printMessage(1,SOLLYA_MSG_A_CHARACTER_COULD_NOT_BE_RECOGNIZED,"The character \"%s\" cannot be recognized. Will ignore it.\n",
				yytext);
		}

%%

FILE *getCurrentLexerStream() {
  return yyget_in(scanner);
}

char *getCurrentLexSymbol() {
  char *str;

  str = (char *) safeCalloc(yyget_leng(scanner)+1,sizeof(char));
  strcpy(str,yyget_text(scanner));

  return str;
}

void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
{
        UNUSED_PARAM(yyscanner);
        return (void *) malloc( size );
}

void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
{
        /* The cast to (char *) in the following accommodates both
         * implementations that use char* generic pointers, and those
         * that use void* generic pointers.  It works with the latter
         * because both ANSI C and C++ allow castless assignment from
         * any pointer type to void*, and deal with argument conversions
         * as though doing an assignment.
         */
        UNUSED_PARAM(yyscanner);
        return (void *) realloc( (char *) ptr, size );
}

void yyfree (void * ptr , yyscan_t yyscanner)
{
        UNUSED_PARAM(yyscanner);
        free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
}