00001
00002
00003 %{
00004 #include "ssParse.tab.h"
00005 #include "ssParse.h"
00006
00007 #include <string.h>
00008
00009 extern FileInfo data;
00010 extern int CommentState;
00011 extern int HaveComment;
00012 extern char CommentText[50000];
00013 %}
00014
00015 %%
00016
00017 "/*" {
00018 int c1 = 0, c2 = input();
00019 for ( ; ; )
00020 {
00021 if (c2 == EOF)
00022 break;
00023 if (c1 == '*' && c2 == '/')
00024 break;
00025 c1 = c2;
00026 c2 = input();
00027 }
00028 };
00029
00030 ^[\t ]*"//BTX".*$ {
00031 int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = input();
00032 for ( ; ; )
00033 {
00034 if (c5 == EOF)
00035 break;
00036 if (c1 == '/' && c2 == '/' && c3 == 'E' && c4 == 'T' && c5 == 'X')
00037 break;
00038 c1 = c2;
00039 c2 = c3;
00040 c3 = c4;
00041 c4 = c5;
00042 c5 = input();
00043 }
00044 for ( ; ; )
00045 {
00046 if (c5 == EOF)
00047 break;
00048 if (c5 == '\n')
00049 break;
00050 c5 = input();
00051 }
00052 };
00053
00054 ^[\t ]*"// .NAME".* {
00055 int pos = 1;
00056 while (yytext[pos-1] != 'M' || yytext[pos] != 'E')
00057 pos++;
00058 yylval.str = (char *)malloc(yyleng + 1 - pos - 1);
00059 memcpy(yylval.str,yytext+ pos + 1,yyleng - pos - 1);
00060 yylval.str[yyleng - pos - 1] = '\0';
00061 data.NameComment = strdup(yylval.str);
00062 }
00063
00064 ^[\t ]*"// .SECTION Description".* {
00065 CommentState = 1;
00066 data.Description = (char*)malloc(100000);
00067 data.Description[0] = '\0';
00068 };
00069
00070 ^[\t ]*"// .SECTION See Also".* {
00071 CommentState = 3;
00072 data.SeeAlso = (char*)malloc(100000);
00073 data.SeeAlso[0] = '\0';
00074 };
00075
00076 ^[\t ]*"// .SECTION see also".* {
00077 CommentState = 3;
00078 data.SeeAlso = (char*)malloc(100000);
00079 data.SeeAlso[0] = '\0';
00080 };
00081
00082 ^[\t ]*"// .SECTION Caveats".* {
00083 CommentState = 4;
00084 data.Caveats = (char*)malloc(100000);
00085 data.Caveats[0] = '\0';
00086 };
00087
00088 ^[\t ]*"// Description:".* {
00089 CommentState = 2;
00090 HaveComment = 1;
00091 CommentText[0] = '\0';
00092 };
00093
00094 ^[\t ]*[\n] {
00095 HaveComment = 0;
00096 CommentState = 0;
00097 };
00098
00099 ^[\t ]*"//".* {
00100 int pos = 1;
00101 while (yytext[pos-1] != '/' || yytext[pos] != '/')
00102 pos++;
00103 yylval.str = (char *)malloc(yyleng + 1 - pos - 1 + 1);
00104 memcpy(yylval.str,yytext+ pos + 1,yyleng - pos - 1);
00105 yylval.str[yyleng - pos - 1] = '\n';
00106 yylval.str[yyleng - pos] = '\0';
00107 switch (CommentState)
00108 {
00109 case 1:
00110 strcat(data.Description,yylval.str);
00111 break;
00112 case 2:
00113 strcat(CommentText,yylval.str);
00114 break;
00115 case 3:
00116 strcat(data.SeeAlso,yylval.str);
00117 break;
00118 case 4:
00119 strcat(data.Caveats,yylval.str);
00120 break;
00121 }
00122 };
00123
00124 "//".* ;
00125
00126 "VTK_EXPORT" ;
00127
00128 "vtkNotUsed"[ ]*"("[^)]*")" ;
00129
00130 "["[\t\n\ ]*[1-9][0-9]*[\t\n ]*"]" {
00131 sscanf(yytext + 1, "%d", &yylval.integer);
00132 return(ARRAY_NUM);
00133 }
00134
00135
00136 "class "[\t\n ]*[a-zA-Z0-9_]*[\t\n ]*";" return(CLASS_REF);
00137
00138 "void"[\t\n ]*"("[\t\n ]*"*"[a-zA-Z0-9_]*[\t\n ]*")"[\t\n ]*"("[\t\n ]*"void"[\t\n ]*"*"[\n\t ]*")" return(VAR_FUNCTION);
00139
00140 "short"[\t\n ]*"int" return(SHORT);
00141 "long"[\t\n ]*"int" return(LONG);
00142 "int"[\t\n ]*"short" return(SHORT);
00143 "int"[\t\n ]*"long" return(LONG);
00144
00145 "class" return(CLASS);
00146 "public" return(PUBLIC);
00147 "private" return(PRIVATE);
00148 "protected" return(PROTECTED);
00149 "int" return(INT);
00150 "float" return(FLOAT);
00151 "short" return(SHORT);
00152 "long" return(LONG);
00153 "double" return(DOUBLE);
00154 "void" return(VOID);
00155 "char" return(CHAR);
00156 "virtual" return(VIRTUAL);
00157 "const" return(CONST);
00158 "operator" return(OPERATOR);
00159 "unsigned" return(UNSIGNED);
00160 "friend" return(FRIEND);
00161 "static" return(STATIC);
00162
00163 "vtkSetMacro" return(SetMacro);
00164 "vtkGetMacro" return(GetMacro);
00165 "vtkSetStringMacro" return(SetStringMacro);
00166 "vtkGetStringMacro" return(GetStringMacro);
00167 "vtkSetClampMacro" return(SetClampMacro);
00168 "vtkSetObjectMacro" return(SetObjectMacro);
00169 "vtkSetReferenceCountedObjectMacro" return(SetReferenceCountedObjectMacro);
00170 "vtkGetObjectMacro" return(GetObjectMacro);
00171 "vtkBooleanMacro" return(BooleanMacro);
00172 "vtkSetVector2Macro" return(SetVector2Macro);
00173 "vtkSetVector3Macro" return(SetVector3Macro);
00174 "vtkSetVector4Macro" return(SetVector4Macro);
00175 "vtkSetVector6Macro" return(SetVector6Macro);
00176 "vtkGetVector2Macro" return(GetVector2Macro);
00177 "vtkGetVector3Macro" return(GetVector3Macro);
00178 "vtkGetVector4Macro" return(GetVector4Macro);
00179 "vtkGetVector6Macro" return(GetVector6Macro);
00180 "vtkSetVectorMacro" return(SetVectorMacro);
00181 "vtkGetVectorMacro" return(GetVectorMacro);
00182 "vtkViewportCoordinateMacro" return(ViewportCoordinateMacro);
00183 "vtkWorldCoordinateMacro" return(WorldCoordinateMacro);
00184 "vtkTypeMacro" return(TypeMacro);
00185
00186 [0-9]+ {
00187 sscanf(yytext, "%d", &yylval.integer);
00188 return(NUM);
00189 }
00190
00191 \"[^\"]+\" {
00192 yylval.str = strdup(yytext + 1);
00193 yylval.str[strlen(yytext)-2] = '\0';
00194 return(STRING);
00195 }
00196
00197 ^"#"[^\n]*$ ;
00198
00199
00200 "vtk"[0-9a-zA-Z_]* {
00201 yylval.str = (char *)malloc(yyleng + 1);
00202 memcpy(yylval.str, yytext, yyleng);
00203 yylval.str[yyleng] = '\0';
00204 return(VTK_ID);
00205 }
00206
00207 "ss"[0-9a-zA-Z_]* {
00208 yylval.str = (char *)malloc(yyleng + 1);
00209 memcpy(yylval.str, yytext, yyleng);
00210 yylval.str[yyleng] = '\0';
00211 return(VTK_ID);
00212 }
00213
00214 [a-zA-Z_][0-9a-zA-Z_]* {
00215 yylval.str = (char *)malloc(yyleng + 1);
00216 memcpy(yylval.str,yytext,yyleng);
00217 yylval.str[yyleng] = '\0';
00218 return(ID);
00219 }
00220
00221 [\t\n ] ;
00222
00223
00224 "[" return(yytext[0]);
00225 "]" return(yytext[0]);
00226
00227
00228 [~{}] return (yytext[0]);
00229 [():] return (yytext[0]);
00230 [;*=] return (yytext[0]);
00231 [,&.] return (yytext[0]);
00232 [---] return (yytext[0]);
00233
00234 . return(OTHER);
00235 %%
00236
00237 /*
00238 * $Log: ssParse.l,v $
00239 * Revision 1.4 2004/02/07 18:27:32 pfb
00240 * Added 'ss' prefix for VTK_ID.
00241 *
00242 * Revision 1.3 2004/01/27 16:18:36 pfb
00243 * Modified to that ssParse.y and ssParse.l link together (as opposed to
00244 * include).
00245 *
00246 * Revision 1.2 2001/07/12 07:38:37 pfb
00247 * Fixed single char return rule. Whether it works or not has not been confirmed.
00248 *
00249 *
00250 */