[14] | 1 | %{ |
---|
| 2 | /**CFile*********************************************************************** |
---|
| 3 | |
---|
| 4 | FileName [ctlp.l] |
---|
| 5 | |
---|
| 6 | PackageName [ctlp] |
---|
| 7 | |
---|
| 8 | Synopsis [Lexical analyzer for CTL formula parser. See ctlp.h for syntax.] |
---|
| 9 | |
---|
| 10 | Author [Gary York, Ramin Hojati, Tom Shiple, Yuji Kukimoto, |
---|
| 11 | Jae-Young Jang] |
---|
| 12 | |
---|
| 13 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
| 14 | All rights reserved. |
---|
| 15 | |
---|
| 16 | Permission is hereby granted, without written agreement and without license |
---|
| 17 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
| 18 | documentation for any purpose, provided that the above copyright notice and |
---|
| 19 | the following two paragraphs appear in all copies of this software. |
---|
| 20 | |
---|
| 21 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
| 22 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
| 23 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
| 24 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 25 | |
---|
| 26 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
| 27 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
| 28 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
| 29 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
| 30 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
| 31 | |
---|
| 32 | Revision [$Id: ctlp.l,v 1.8 2010/04/09 23:30:23 fabio Exp $] |
---|
| 33 | |
---|
| 34 | ******************************************************************************/ |
---|
| 35 | |
---|
| 36 | #include "ctlpRead.h" |
---|
| 37 | |
---|
| 38 | /*---------------------------------------------------------------------------*/ |
---|
| 39 | /* Constant declarations */ |
---|
| 40 | /*---------------------------------------------------------------------------*/ |
---|
| 41 | |
---|
| 42 | /*---------------------------------------------------------------------------*/ |
---|
| 43 | /* Variable declarations */ |
---|
| 44 | /*---------------------------------------------------------------------------*/ |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | /**AutomaticStart*************************************************************/ |
---|
| 48 | |
---|
| 49 | /*---------------------------------------------------------------------------*/ |
---|
| 50 | /* Static function prototypes */ |
---|
| 51 | /*---------------------------------------------------------------------------*/ |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | /**AutomaticEnd***************************************************************/ |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | /*---------------------------------------------------------------------------*/ |
---|
| 59 | /* Definition of internal functions */ |
---|
| 60 | /*---------------------------------------------------------------------------*/ |
---|
| 61 | |
---|
| 62 | /**Function******************************************************************** |
---|
| 63 | |
---|
| 64 | Synopsis [Initializes global variables for parsing file.] |
---|
| 65 | |
---|
| 66 | SideEffects [] |
---|
| 67 | |
---|
| 68 | ******************************************************************************/ |
---|
| 69 | void |
---|
| 70 | CtlpFileSetup( |
---|
| 71 | FILE * fp) |
---|
| 72 | { |
---|
| 73 | CtlpYyin = fp; |
---|
| 74 | CtlpYylineno = 1; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | /*---------------------------------------------------------------------------*/ |
---|
| 78 | /* Definition of static functions */ |
---|
| 79 | /*---------------------------------------------------------------------------*/ |
---|
| 80 | |
---|
| 81 | /**Function******************************************************************** |
---|
| 82 | |
---|
| 83 | Synopsis [Prints error message and sets global error flag.] |
---|
| 84 | |
---|
| 85 | SideEffects [] |
---|
| 86 | |
---|
| 87 | ******************************************************************************/ |
---|
| 88 | static void |
---|
| 89 | CtlpYyerror( |
---|
| 90 | char * errmsg) |
---|
| 91 | { |
---|
| 92 | (void) fprintf(vis_stderr, "%s in line %d with token \"%s\"\n", errmsg, CtlpYylineno, yytext); |
---|
| 93 | CtlpGlobalError = 1; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | %} |
---|
| 97 | |
---|
| 98 | /*---------------------------------------------------------------------------*/ |
---|
| 99 | /* Lexical analyzer rules */ |
---|
| 100 | /*---------------------------------------------------------------------------*/ |
---|
| 101 | |
---|
| 102 | %option noyywrap |
---|
| 103 | %option yylineno |
---|
| 104 | |
---|
| 105 | /* substitution strings */ |
---|
| 106 | /* alnum is the same set in alnumsymbol in io.l except [ and ] being |
---|
| 107 | removed here for the until operator */ |
---|
| 108 | /* - , =, and ; are intentionally removed |
---|
| 109 | - is used for -> and <-> |
---|
| 110 | = is used for foo = bar |
---|
| 111 | ; is used for delimitters */ |
---|
| 112 | /* ( and ) are intentionally removed since they are used as parentheses */ |
---|
| 113 | /* +, *, and ^ have to be used surrounded by spaces |
---|
| 114 | since they are symbols. ! can be attached immediately w/o spaces though |
---|
| 115 | since it is not a symbol */ |
---|
| 116 | alnum [A-Za-z0-9\^\?\|\/\+\*\$\<\>~@\_#\$%\:\"\'\.] |
---|
| 117 | /*alnum [A-Za-z0-9\^\?\|\/\[\]\+\*\$\<\>~@\_#\$%\:\"\'\.]*/ |
---|
| 118 | %% |
---|
| 119 | |
---|
| 120 | [ \t\n\r] ; |
---|
| 121 | |
---|
| 122 | "#".* ; |
---|
| 123 | |
---|
| 124 | A { return(TOK_FORALL); } |
---|
| 125 | AX { return(TOK_FORALL_NEXT); } |
---|
| 126 | AF { return(TOK_FORALL_EVENTUALLY); } |
---|
| 127 | AG { return(TOK_FORALL_GLOBALLY); } |
---|
| 128 | |
---|
| 129 | E { return(TOK_EXISTS); } |
---|
| 130 | EX { return(TOK_EXISTS_NEXT); } |
---|
| 131 | EF { return(TOK_EXISTS_EVENTUALLY); } |
---|
| 132 | EG { return(TOK_EXISTS_GLOBALLY); } |
---|
| 133 | |
---|
| 134 | AX:[0-9]+ { return(TOK_FORALL_NEXT_MULT); } |
---|
| 135 | EX:[0-9]+ { return(TOK_EXISTS_NEXT_MULT); } |
---|
| 136 | |
---|
| 137 | U { return(TOK_UNTIL); } |
---|
| 138 | |
---|
| 139 | TRUE { return(TOK_TRUE); } |
---|
| 140 | |
---|
| 141 | FALSE { return(TOK_FALSE); } |
---|
| 142 | |
---|
| 143 | \\DEFINE | |
---|
| 144 | \\Define | |
---|
| 145 | \\define { return(TOK_DEFINE); } |
---|
| 146 | |
---|
| 147 | \+ { return(TOK_OR); } |
---|
| 148 | \|\| { return(TOK_OR); } |
---|
| 149 | \* { return(TOK_AND); } |
---|
| 150 | \&\& { return(TOK_AND); } |
---|
| 151 | ! { return(TOK_NOT); } |
---|
| 152 | "^" { return(TOK_XOR); } |
---|
| 153 | "->" { return(TOK_THEN); } |
---|
| 154 | "<->" { return(TOK_EQ); } |
---|
| 155 | = { return(TOK_ASSIGN); } |
---|
| 156 | == { return(TOK_EQIV); } |
---|
| 157 | \, { return(TOK_COMMA); } |
---|
| 158 | \\ { return(TOK_MACRO); } |
---|
| 159 | |
---|
| 160 | {alnum}+ { return(TOK_ID); } |
---|
| 161 | {alnum}+\[[ ]*[0-9]+[ ]*\] { return(TOK_ID2); } |
---|
| 162 | {alnum}+\[[ ]*[0-9]+[ ]*\:[ ]*[0-9]+[ ]*\] { return(TOK_ID_VECTOR); } |
---|
| 163 | |
---|
| 164 | . { return CtlpYytext[0]; } |
---|
| 165 | %% |
---|