Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

readcuiksystem.l

Go to the documentation of this file.
00001 %{ 
00002 
00004 #include <stdlib.h> 
00005 #include <string.h>
00006 
00007 #include "defines.h" 
00008 #include "error.h"
00009 #include "readcuiksystemtypes.h" 
00010 #include "readcuiksystem.tab.h" 
00013 int Readcuiksystemlex(void);
00014 
00015 extern unsigned int RCSline;
00016 
00017 %} 
00018  
00019 %s IN_COMMENT
00020 
00021 EMPTY                           [ \t]+ 
00022 RETURN                          \n
00023 DIGIT                           [0-9] 
00024 LETTER                          [a-zA-Z] 
00025 R_NUMBER                        (({DIGIT}+(\.{DIGIT}+)?)|(\.{DIGIT}+))((E|e)[+-]?{DIGIT}+)? 
00026 I_NUMBER                        {DIGIT}+ 
00027 IDENTIFIER                      {LETTER}({DIGIT}|{LETTER}|"_")* 
00028 COMMENT                         \%[^{\n|\{}]*
00029 COMMENT2                        \#[^{\n|\{}]*
00030 COMMENT3                        \/\/[^{\n|\{}]*
00031  
00032 %%
00033 {COMMENT}                       { }  
00034 {COMMENT2}                      { }   
00035 {COMMENT3}                      { }   
00036 
00037 <INITIAL>{
00038   "/*"              BEGIN(IN_COMMENT);
00039 }
00040 <IN_COMMENT>{
00041   "*/"      BEGIN(INITIAL);
00042   [^*\n]+   // eat comment in chunks
00043   "*"       // eat the lone star
00044   \n        RCSline++;
00045 }
00046 
00047 {EMPTY}                         { } 
00048 
00049 {RETURN}                        { RCSline++; } 
00050 
00051 "[CONSTANTS]"                   {
00052                                   return(_CONSTANTS);
00053                                 }
00054 
00055 "[SYSTEM VARS]"                 {
00056                                   return(_SYSTEM_VARS);
00057                                 }
00058 
00059 "[SECONDARY VARS]"              {
00060                                   return(_SECONDARY_VARS);
00061                                 }
00062 
00063 "[DUMMY VARS]"                  {
00064                                   return(_DUMMY_VARS);
00065                                 }
00066 
00067 "[CARTESIAN VARS]"              {
00068                                   return(_CARTESIAN_VARS);
00069                                 }
00070 
00071 "[SYSTEM EQS]"                  {
00072                                   return(_SYSTEM_EQS);
00073                                 }
00074 
00075 "[COORD EQS]"                   {
00076                                   return(_COORD_EQS);
00077                                 }
00078 
00079 "[DUMMY EQS]"                   {
00080                                   return(_DUMMY_EQS);
00081                                 }
00082 
00083 "[SEARCH]"                      {
00084                                   return(_SEARCH);
00085                                 }
00086 
00087 DEPTH                           {
00088                                   return(_DEPTH);
00089                                 }
00090 
00091 FIRST                           {
00092                                   return(_FIRST);
00093                                 }
00094 
00095 BREADTH                         {
00096                                   return(_BREADTH);
00097                                 }
00098 
00099 MIN                             { 
00100                                   return(_MIN);
00101                                 }
00102 
00103 INF                             { 
00104                                   return(_INF);
00105                                 }
00106 
00107 PI                              {
00108                                   return(_PI);
00109                                 }
00110 
00111 SIN                             {
00112                                   return(_SIN);
00113                                 }
00114 
00115 COS                             {
00116                                   return(_COS);
00117                                 }
00118 
00119 SQRT                            {
00120                                   return(_SQRT);
00121                                 }
00122 
00123 "="                             {
00124                                   return(_EQU); 
00125                                 }
00126 
00127 ">="                            {
00128                                   return(_GEQ); 
00129                                 }
00130 
00131 "<="                            {
00132                                   return(_LEQ); 
00133                                 }
00134 
00135 ":="                            {
00136                                   return(_ASSIGN); 
00137                                 }
00138 
00139 {I_NUMBER}                      { 
00140                                   char string_tmp[100];
00141                                   
00142                                   memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
00143                                   string_tmp[Readcuiksystemleng]=0;
00144                                   Readcuiksystemlval.int_number=atoi(string_tmp);
00145                                   return(_INTEGER); 
00146                                 } 
00147  
00148 {R_NUMBER}                      { 
00149                                   char string_tmp[100];
00150                                   
00151                                   memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
00152                                   string_tmp[Readcuiksystemleng]=0;
00153                                   Readcuiksystemlval.real_number=atof(string_tmp);
00154                                   
00155                                   return(_REAL);
00156                                 } 
00157   
00158 {IDENTIFIER}                    { 
00159                                   NEW(Readcuiksystemlval.id,Readcuiksystemleng+1,char);
00160                                   memcpy(Readcuiksystemlval.id,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
00161   
00162                                   Readcuiksystemlval.id[Readcuiksystemleng]=0;
00163 
00164                                   return(_IDENTIFIER);  
00165                                 } 
00166 
00167 \{                              {
00168                                    Readcuiksystemerror("The input file can not include the symbol '{'");
00169                                 }
00170 
00171 .                               { return(Readcuiksystemtext[0]); }
00172  
00173 %%
00174 
00183 int Readcuiksystemwrap()
00184 {
00185   return(1);
00186 }
00187