Added quantiling UDAFs
[com/gs-lite.git] / src / ftacmp / ext_fcns.l
index 084ae3a..ba3f8a9 100644 (file)
-/* ------------------------------------------------
-Copyright 2014 AT&T Intellectual Property
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
- ------------------------------------------- */
-
-
-/*
-       MUST COMPILE WITH
-               flex -PExt_fcnsParser -oext_fcnslexer.cc ext_fcns.l
-       (or equivalent).
-*/     
-
-%{
-/*
- * AT&T lex can't handle this lexer due to lex bugs.  It works with flex
- * 2.3.7, pclex 2.0.5, and MKS lex 3.1a.
- */
-
- #include "parse_ext_fcns.h"
- #include <string.h>
-
-
-
-#include "ext_fcns.tab.cc.h"
-
-/*
-       Some includes that flex doesn't include as standard,
-       but which are needed.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-
-
-//             Prevent flex from defining yywrap as extern "C" 
-
-#define YY_SKIP_YYWRAP
-
-/*             No lex lib, supply the yywrap fcn. that normally resides there
-*/
-
-int Ext_fcnsParserwrap(){return(1);}
-
-extern int Ext_fcnsParserdebug;
-
-
-/*
-               These variables are used for error reporting:
-               flex_lineno : the line currently being parsed when the error occurs.
-               flexch : the character on the line where the error occurs
-               flex_linebuf : store the line for reporting.
-
-               NOTE : 1) the fixed size flex_linebuf buffer is dangerous.
-                          2) You might get pointed to a place shortly after
-                                 where the syntax error occurs.  It is close enough
-                                 for now.
-*/
-
-int flex_ext_fcns_lineno = 1;
-int flex_ext_fcns_ch = 0;
-char flex_ext_fcns_linebuf[20000];
-
-//void Ext_fcnsParsererror(char *s);
-
-void Ext_fcnsParsererror(char *s){
-       fprintf(stderr,"On line %d, char %d: %s (token %s):\n%s\n",
-                               flex_ext_fcns_lineno, flex_ext_fcns_ch, s, Ext_fcnsParsertext, flex_ext_fcns_linebuf );
-       fprintf(stderr,"%*s\n",1+flex_ext_fcns_ch,"^");
-}
-
-
-%}
-       /* MKS needs the next line to increase the NFA table */
-%e 1200
-%option noyywrap
-
-%%
-
-       /* literal keyword tokens */
-
- /*
-                       The actions associated with each text token are to
-                       keep track of the current location (for syntax error reporting)
-                       and to report any necessary info to the emf.y parse tree builder
-
-                       Its likely that there are a number of omissions, inconsistencies
-                       (some keywords do not need to be in caps), and relics
-                       (keywords such as BETWEEN, INDICATOR, etc., are not used
-                        in emf.y)
-                       This parser is somewhat of a work in progress.
- */
-
-FUN            { flex_ext_fcns_ch+=Ext_fcnsParserleng; return FUN; }
-PRED   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return PRED; }
-UDAF   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return UDAF; }
-EXTR   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return EXTR; }
-STATE  { flex_ext_fcns_ch+=Ext_fcnsParserleng; return STATE; }
-SFUN   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return SFUN; }
-HANDLE         { flex_ext_fcns_ch+=Ext_fcnsParserleng; return HANDLE; }
-CONST          { flex_ext_fcns_ch+=Ext_fcnsParserleng; return CONST; }
-CLASS          { flex_ext_fcns_ch+=Ext_fcnsParserleng; return CLASS; }
-;      {flex_ext_fcns_ch+=Ext_fcnsParserleng; return SEMICOLON;}
-
-[(),\[\]]    { flex_ext_fcns_ch+=Ext_fcnsParserleng; return yytext[0]; }
-
-
-       /* names */
-
-[A-Za-z][A-Za-z0-9_]*  { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParserlval.strval = strdup(yytext); return NAME; }
-
-       /* numbers */
-
-[0-9]+ |
-[0-9]+UL       { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParserlval.strval = strdup(yytext);  return INTNUM; }
-
-       /* strings */
-
-'[^'\n]*'      {
-               
-               int c;
-               
-               Ext_fcnsParserlval.strval = strdup(Ext_fcnsParsertext+1); 
-
-               c = yyinput();
-
-               unput(c);       /* just peeking */
-               if(c != '\'') {
-                       flex_ext_fcns_ch+=Ext_fcnsParserleng; 
-                       Ext_fcnsParserlval.strval[Ext_fcnsParserleng-2] = '\0';
-                       return STRING_TOKEN;
-               } else
-                       yymore();
-       }
-               
-'[^'\n]*$      { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParsererror("Unterminated string"); }
-
-
-
- /*                                                                                                                    */
- /*            Newline : advance the error reporting line number       */
- /*            and grab the next line into flex_linebuf                        */
- /*                                                                                                                    */
-
-\n.*           {flex_ext_fcns_ch=0; flex_ext_fcns_lineno++;
-                          strcpy(flex_ext_fcns_linebuf,Ext_fcnsParsertext+1);
-                          yyless(1);
-                          }
-
-[ \t\r]+       {flex_ext_fcns_ch+=Ext_fcnsParserleng; }        /* white space */
-
-"--".*$                {flex_ext_fcns_ch+=Ext_fcnsParserleng; };       /* comment */
-"//".*$                {flex_ext_fcns_ch+=Ext_fcnsParserleng; };       /* comment */
-
- /*            Parse error on anything else.           */                              
-.|\n                   {fprintf(stderr,"Warning: unknown token (ignored)\n");  Ext_fcnsParsererror(yytext);}
-
-%%
-
-
+/* ------------------------------------------------\r
+Copyright 2014 AT&T Intellectual Property\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+     http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+ ------------------------------------------- */\r
+\r
+\r
+/*\r
+       MUST COMPILE WITH\r
+               flex -PExt_fcnsParser -oext_fcnslexer.cc ext_fcns.l\r
+       (or equivalent).\r
+*/     \r
+\r
+%{\r
+/*\r
+ * AT&T lex can't handle this lexer due to lex bugs.  It works with flex\r
+ * 2.3.7, pclex 2.0.5, and MKS lex 3.1a.\r
+ */\r
+\r
+ #include "parse_ext_fcns.h"\r
+ #include <string.h>\r
+\r
+\r
+\r
+#include "ext_fcns.tab.cc.h"\r
+\r
+/*\r
+       Some includes that flex doesn't include as standard,\r
+       but which are needed.\r
+*/\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+\r
+//             Prevent flex from defining yywrap as extern "C" \r
+\r
+#define YY_SKIP_YYWRAP\r
+\r
+/*             No lex lib, supply the yywrap fcn. that normally resides there\r
+*/\r
+\r
+int Ext_fcnsParserwrap(){return(1);}\r
+\r
+extern int Ext_fcnsParserdebug;\r
+\r
+\r
+/*\r
+               These variables are used for error reporting:\r
+               flex_lineno : the line currently being parsed when the error occurs.\r
+               flexch : the character on the line where the error occurs\r
+               flex_linebuf : store the line for reporting.\r
+\r
+               NOTE : 1) the fixed size flex_linebuf buffer is dangerous.\r
+                          2) You might get pointed to a place shortly after\r
+                                 where the syntax error occurs.  It is close enough\r
+                                 for now.\r
+*/\r
+\r
+int flex_ext_fcns_lineno = 1;\r
+int flex_ext_fcns_ch = 0;\r
+char flex_ext_fcns_linebuf[20000];\r
+\r
+//void Ext_fcnsParsererror(char *s);\r
+\r
+void Ext_fcnsParsererror(char *s){\r
+       fprintf(stderr,"On line %d, char %d: %s (token %s):\n%s\n",\r
+                               flex_ext_fcns_lineno, flex_ext_fcns_ch, s, Ext_fcnsParsertext, flex_ext_fcns_linebuf );\r
+       fprintf(stderr,"%*s\n",1+flex_ext_fcns_ch,"^");\r
+}\r
+\r
+\r
+%}\r
+       /* MKS needs the next line to increase the NFA table */\r
+%e 1200\r
+%option noyywrap\r
+\r
+%%\r
+\r
+       /* literal keyword tokens */\r
+\r
+ /*\r
+                       The actions associated with each text token are to\r
+                       keep track of the current location (for syntax error reporting)\r
+                       and to report any necessary info to the emf.y parse tree builder\r
+\r
+                       Its likely that there are a number of omissions, inconsistencies\r
+                       (some keywords do not need to be in caps), and relics\r
+                       (keywords such as BETWEEN, INDICATOR, etc., are not used\r
+                        in emf.y)\r
+                       This parser is somewhat of a work in progress.\r
+ */\r
+\r
+FUN            { flex_ext_fcns_ch+=Ext_fcnsParserleng; return FUN; }\r
+PRED   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return PRED; }\r
+UDAF   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return UDAF; }\r
+EXTR   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return EXTR; }\r
+STATE  { flex_ext_fcns_ch+=Ext_fcnsParserleng; return STATE; }\r
+SFUN   { flex_ext_fcns_ch+=Ext_fcnsParserleng; return SFUN; }\r
+HANDLE         { flex_ext_fcns_ch+=Ext_fcnsParserleng; return HANDLE; }\r
+CONST          { flex_ext_fcns_ch+=Ext_fcnsParserleng; return CONST; }\r
+CLASS          { flex_ext_fcns_ch+=Ext_fcnsParserleng; return CLASS; }\r
+;      {flex_ext_fcns_ch+=Ext_fcnsParserleng; return SEMICOLON;}\r
+\r
+[(),\[\]]    { flex_ext_fcns_ch+=Ext_fcnsParserleng; return yytext[0]; }\r
+\r
+\r
+       /* names */\r
+\r
+[A-Za-z][A-Za-z0-9_]*  { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParserlval.strval = strdup(yytext); return NAME; }\r
+\r
+       /* numbers */\r
+\r
+[0-9]+ |\r
+[0-9]+UL       { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParserlval.strval = strdup(yytext);  return INTNUM; }\r
+\r
+       /* strings */\r
+\r
+'[^'\n]*'      {\r
+               \r
+               int c;\r
+               \r
+               Ext_fcnsParserlval.strval = strdup(Ext_fcnsParsertext+1); \r
+\r
+               c = yyinput();\r
+\r
+               unput(c);       /* just peeking */\r
+               if(c != '\'') {\r
+                       flex_ext_fcns_ch+=Ext_fcnsParserleng; \r
+                       Ext_fcnsParserlval.strval[Ext_fcnsParserleng-2] = '\0';\r
+                       return STRING_TOKEN;\r
+               } else\r
+                       yymore();\r
+       }\r
+               \r
+'[^'\n]*$      { flex_ext_fcns_ch+=Ext_fcnsParserleng; Ext_fcnsParsererror("Unterminated string"); }\r
+\r
+\r
+\r
+ /*                                                                                                                    */\r
+ /*            Newline : advance the error reporting line number       */\r
+ /*            and grab the next line into flex_linebuf                        */\r
+ /*                                                                                                                    */\r
+\r
+\n.*           {flex_ext_fcns_ch=0; flex_ext_fcns_lineno++;\r
+                          strcpy(flex_ext_fcns_linebuf,Ext_fcnsParsertext+1);\r
+                          yyless(1);\r
+                          }\r
+\r
+[ \t\r]+       {flex_ext_fcns_ch+=Ext_fcnsParserleng; }        /* white space */\r
+\r
+"--".*$                {flex_ext_fcns_ch+=Ext_fcnsParserleng; };       /* comment */\r
+"//".*$                {flex_ext_fcns_ch+=Ext_fcnsParserleng; };       /* comment */\r
+\r
+ /*            Parse error on anything else.           */                              \r
+.|\n                   {fprintf(stderr,"Warning: unknown token (ignored)\n");  Ext_fcnsParsererror(yytext);}\r
\r
+\r
+%%\r
+\r
+\r