X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fftacmp%2Fres.l;h=a9036c26632ff77965afa48d37abf1ef93d10714;hb=refs%2Fchanges%2F78%2F4778%2F1;hp=99113f958d73fc72acd287a3e7aec52548576424;hpb=07495effe193ca3f73c3bf0ce417068f9ac9dcdd;p=com%2Fgs-lite.git diff --git a/src/ftacmp/res.l b/src/ftacmp/res.l index 99113f9..a9036c2 100644 --- a/src/ftacmp/res.l +++ b/src/ftacmp/res.l @@ -1,223 +1,223 @@ -/* ------------------------------------------------ -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 -PResParser -oreslexer.cc res.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_fta.h" - #include - - - -#include "res.tab.cc.h" - -/* - Some includes that flex doesn't include as standard, - but which are needed. -*/ - -#include -#include - - -// Prevent flex from defining yywrap as extern "C" - -#define YY_SKIP_YYWRAP - -/* No lex lib, supply the yywrap fcn. that normally resides there -*/ - -int ResParserwrap(){return(1);} - -extern int ResParserdebug; - - -/* - These variables are used for error reporting: - flex_res_lineno : the line currently being parsed when the error occurs. - flex_res_ch : the character on the line where the error occurs - flex_res_linebuf : store the line for reporting. - - NOTE : 1) the fixed size flex_res_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_res_lineno = 1; -int flex_res_ch = 0; -char flex_res_linebuf[20000]; - -char *flex_res_stringinput = NULL; -int flex_res_stringinput_ptr = 0; -FILE *flex_res_fileinput = NULL; -int my_ResParser_yyinput(char *buf, int max_size); - - - -void ResParsererror(char *s){ - int i; - fprintf(stderr,"On line %d, char %d: %s (token %s):\n%s\n", - flex_res_lineno, flex_res_ch, s, ResParsertext, flex_res_linebuf ); - for(i=0;i=/] { flex_res_ch+=ResParserleng; return yytext[0]; } - - /* names */ - -[A-Za-z_][A-Za-z0-9_]* { flex_res_ch+=ResParserleng; ResParserlval.strval = strdup(yytext); return NAME; } - - - /* strings */ - -'[^'\n]*' { - - int c; - - ResParserlval.strval = strdup(ResParsertext+1); - - c = yyinput(); - - unput(c); /* just peeking */ - if(c != '\'') { - flex_res_ch+=ResParserleng; - ResParserlval.strval[ResParserleng-2] = '\0'; - return STRING_TOKEN; - } else - yymore(); - } - -'[^'\n]*$ { flex_res_ch+=ResParserleng; ResParsererror("Unterminated string"); } - - /* */ - /* Newline : advance the error reporting line number */ - /* and grab the next line into flex_res_linebuf */ - /* */ - -\n.* {flex_res_ch=0; flex_res_lineno++; - strcpy(flex_res_linebuf,ResParsertext+1); - yyless(1); - } - -[ \t\r]+ {flex_res_ch+=ResParserleng; } /* white space */ - -"--".*$ {flex_res_ch+=ResParserleng; }; /* comment */ -"//".*$ {flex_res_ch+=ResParserleng; }; /* comment */ -" + + + +#include "res.tab.cc.h" + +/* + Some includes that flex doesn't include as standard, + but which are needed. +*/ + +#include +#include + + +// Prevent flex from defining yywrap as extern "C" + +#define YY_SKIP_YYWRAP + +/* No lex lib, supply the yywrap fcn. that normally resides there +*/ + +int ResParserwrap(){return(1);} + +extern int ResParserdebug; + + +/* + These variables are used for error reporting: + flex_res_lineno : the line currently being parsed when the error occurs. + flex_res_ch : the character on the line where the error occurs + flex_res_linebuf : store the line for reporting. + + NOTE : 1) the fixed size flex_res_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_res_lineno = 1; +int flex_res_ch = 0; +char flex_res_linebuf[20000]; + +char *flex_res_stringinput = NULL; +int flex_res_stringinput_ptr = 0; +FILE *flex_res_fileinput = NULL; +int my_ResParser_yyinput(char *buf, int max_size); + + + +void ResParsererror(char *s){ + int i; + fprintf(stderr,"On line %d, char %d: %s (token %s):\n%s\n", + flex_res_lineno, flex_res_ch, s, ResParsertext, flex_res_linebuf ); + for(i=0;i=/] { flex_res_ch+=ResParserleng; return yytext[0]; } + + /* names */ + +[A-Za-z_][A-Za-z0-9_]* { flex_res_ch+=ResParserleng; ResParserlval.strval = strdup(yytext); return NAME; } + + + /* strings */ + +'[^'\n]*' { + + int c; + + ResParserlval.strval = strdup(ResParsertext+1); + + c = yyinput(); + + unput(c); /* just peeking */ + if(c != '\'') { + flex_res_ch+=ResParserleng; + ResParserlval.strval[ResParserleng-2] = '\0'; + return STRING_TOKEN; + } else + yymore(); + } + +'[^'\n]*$ { flex_res_ch+=ResParserleng; ResParsererror("Unterminated string"); } + + /* */ + /* Newline : advance the error reporting line number */ + /* and grab the next line into flex_res_linebuf */ + /* */ + +\n.* {flex_res_ch=0; flex_res_lineno++; + strcpy(flex_res_linebuf,ResParsertext+1); + yyless(1); + } + +[ \t\r]+ {flex_res_ch+=ResParserleng; } /* white space */ + +"--".*$ {flex_res_ch+=ResParserleng; }; /* comment */ +"//".*$ {flex_res_ch+=ResParserleng; }; /* comment */ +"