%{
#include <stdio.h>
#include <string.h>
#include "parseComplex.tab.h"
#include "Syslog.h"

int _lineNo = 1;
int _starting = 0;

int fileLineNo() {
  return _lineNo;
}

#undef yywrap

// Defined in parseComplex.y
Boolean isIdentifier( const char * );

int yywrap() 
{
  int ret;
  if (_starting) {
    ret = 0;
    _starting = 0;
  }
  else
    ret = 1;

  return ret; 
}


void restartLexer()
{
  _lineNo = 1;
  _starting = 1;
}


%}

%x COMMENT


%%

"#".*             { }
"//".*            { }
"/*".*"*/"        { }

"/*"              { BEGIN COMMENT; }
<COMMENT>"*/"     { BEGIN INITIAL; }

<COMMENT>^.*      { }

<COMMENT>^[ \t]*\n { _lineNo++; }

[ \t]+            { ; /* Eat extra whitespace */ }
[a-zA-Z0-9_\.\-\/\\]* { yylval.string = strdup(yytext);  return isIdentifier( yytext ) ? Identifier : Word; }
\{                { return '{'; }
\}                { return '}'; }
=                 { return '='; }
\;                { return ';'; }
,                 { return ','; }
\n                { _lineNo++; }
\r                { }
.                 { return yytext[0]; }
%%


