%{
  /* The lexical analyser for a DDL2 file */
  /* This scanner parses a star file into items and attributes pairs.*/
#include <stdio.h>
#include "ddl2parse.tab.h"
%}

%x inputtext

%%
^;                             BEGIN(inputtext);
<inputtext>.*                 /* do nothing */
<inputtext>\n/[^;]            /* do nothing */
<inputtext>\n;                {BEGIN(0); return(DATASTRING);}/* finished text */
"#".*"\n"                     /* do nothing (comment) */
"data_"[[:graph:]]+           {strncpy(yylval.item, yytext,yyleng+1); 
                               return DICDEF;}
"save_"[[:graph:]]+           {strncpy(yylval.item, yytext,yyleng+1);
                               return BEGINSAVE;}
"save_"                        return ENDSAVE;
"loop_"                                  /*  return LOOP; */
"_variable_name"              {return VARNAME;}
"_item_type.code"             {return VARTYPE;}
"_item_aliases.alias_name"    {return NAMEALIAS;}
"_item.name"                  {return NAME;}
"_"[a-zA-Z0-9_.]*[a-zA-Z0-9]+ {return UNKATTR;} /* cannot finish with _ or . */
"code"                        {return CHAR;}
"char"                        {return CHAR;}
"float"                       {return NUMB;}
"numb"                        {return NUMB;}
"int"                         {return NUMB;}
"null"                        {return NOTHING;}
"string"                      {return STRING;}
"'_"[^'\n ]+"'"         {strncpy(yylval.item, yytext,yyleng+1); 
                           return ITEMNAME;}
"'"[^'\n]*"'"                  {strncpy(yylval.item, yytext, yyleng+1);
                           return DATASTRING;}
"\""[^"\n]*"\""                  {strncpy(yylval.item, yytext, yyleng+1);
                           return DATASTRING;}
[^[:space:]]+             {strncpy(yylval.item+1, yytext,yyleng+1);
                           strncat(yylval.item,"'",2);
                           yylval.item[0]='\'';   /* string */
                           return DATASTRING;}
[[:space:]]+              /* do nothing */
