mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-29 20:15:54 +02:00
b2/: add syntax switch
This commit is contained in:
parent
3fff9373e3
commit
1817efd6dc
@ -15,8 +15,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
extern int yyparse(void);
|
||||
#include "lang.h"
|
||||
|
||||
|
||||
static void usage(const char *name)
|
||||
@ -47,6 +46,6 @@ int main(int argc, char **argv)
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
(void) yyparse();
|
||||
parse_hierarchy();
|
||||
return 0;
|
||||
}
|
||||
|
19
b2/lang.h
Normal file
19
b2/lang.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* lang.h - Things lang.l and lang.y export
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LANG_H
|
||||
#define LANG_H
|
||||
|
||||
void parse_hierarchy(void);
|
||||
void parse_characteristics(void);
|
||||
|
||||
#endif /* !LANG_H */
|
27
b2/lang.l
27
b2/lang.l
@ -17,14 +17,41 @@
|
||||
#include "param.h"
|
||||
#include "chr.h"
|
||||
#include "y.tab.h"
|
||||
#include "lang.h"
|
||||
|
||||
|
||||
extern int yyparse(void);
|
||||
|
||||
static int start_token;
|
||||
static int lineno = 1;
|
||||
|
||||
|
||||
void parse_hierarchy(void)
|
||||
{
|
||||
start_token = START_HIERARCHY;
|
||||
yyparse();
|
||||
}
|
||||
|
||||
|
||||
void parse_characteristics(void)
|
||||
{
|
||||
start_token = START_CHAR;
|
||||
yyparse();
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
if (start_token) {
|
||||
int tmp = start_token;
|
||||
|
||||
start_token = 0;
|
||||
return tmp;
|
||||
}
|
||||
%}
|
||||
|
||||
[-_A-Za-z0-9()+./]+ { yylval.s = unique(yytext);
|
||||
return WORD; }
|
||||
|
||||
|
@ -71,6 +71,7 @@ static const struct field *top_field(void)
|
||||
};
|
||||
|
||||
|
||||
%token START_HIERARCHY START_CHAR
|
||||
%token TOK_LE TOK_GE
|
||||
%token <s> WORD
|
||||
|
||||
@ -86,11 +87,15 @@ static const struct field *top_field(void)
|
||||
%%
|
||||
|
||||
all:
|
||||
rule
|
||||
START_HIERARCHY hierarchy
|
||||
;
|
||||
|
||||
hierarchy:
|
||||
nameset hierarchy
|
||||
| rule
|
||||
{
|
||||
field_dump(stderr, $1);
|
||||
}
|
||||
| nameset all
|
||||
;
|
||||
|
||||
nameset:
|
||||
|
Loading…
Reference in New Issue
Block a user