1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-07-03 01:15:29 +03:00
eda-tools/b2/lang.l
2012-03-18 13:24:12 -03:00

60 lines
930 B
Plaintext

%{
/*
* lang.l - BOOM syntax
*
* Copyright 2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdarg.h>
#include <stdlib.h>
#include "util.h"
#include "param.h"
#include "y.tab.h"
static int lineno = 1;
%}
%%
[-_A-Za-z0-9()+./]+ { yylval.s = unique(yytext);
return WORD; }
"<=" return TOK_LE;
">=" return TOK_GE;
[ \t] ;
\n lineno++;
^#[^n]*\n lineno++;
. return *yytext;
%%
void yyerrorf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "%d: ", lineno);
vfprintf(stderr, fmt, ap) ;
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
void yyerror(const char *s)
{
fprintf(stderr, "%d: %s\n", lineno, s);
exit(1);
}