Skip to content

Commit d74edf6

Browse files
committed
Initial commit
0 parents  commit d74edf6

18 files changed

+948
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
build/
2+
Makefile.in
3+
INSTALL
4+
aclocal.m4
5+
autom4te.cache/
6+
configure
7+
depcomp
8+
install-sh
9+
missing
10+
*.o

AUTHORS

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Written by:
2+
3+
Nick Gasson <[email protected]>
4+

COPYING

+674
Large diffs are not rendered by default.

ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Empty
2+

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SUBDIRS = src test

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nothing here yet

README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nothing here yet

autogen.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
aclocal -I m4
2+
autoconf
3+
automake -a

config.h.in

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* config.h.in. Generated from configure.ac by autoheader. */
2+
3+
/* Name of package */
4+
#undef PACKAGE
5+
6+
/* Define to the address where bug reports for this package should be sent. */
7+
#undef PACKAGE_BUGREPORT
8+
9+
/* Define to the full name of this package. */
10+
#undef PACKAGE_NAME
11+
12+
/* Define to the full name and version of this package. */
13+
#undef PACKAGE_STRING
14+
15+
/* Define to the one symbol short name of this package. */
16+
#undef PACKAGE_TARNAME
17+
18+
/* Define to the home page for this package. */
19+
#undef PACKAGE_URL
20+
21+
/* Define to the version of this package. */
22+
#undef PACKAGE_VERSION
23+
24+
/* Version number of package */
25+
#undef VERSION

configure.ac

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
AC_INIT([nhdl], [0.1],
2+
[Nick Gasson <[email protected]>],
3+
[xcowsay])
4+
AM_INIT_AUTOMAKE([-Wall color-tests])
5+
6+
AC_PROG_CC
7+
AC_PROG_INSTALL
8+
9+
AC_CONFIG_HEADERS([config.h])
10+
AC_OUTPUT([Makefile src/Makefile test/Makefile])

src/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin_PROGRAMS = nhdl
2+
3+
AM_CFLAGS = -Wall
4+
5+
nhdl_SOURCES = nhdl.c

src/ident.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef _IDENT_H
2+
#define _IDENT_H
3+
4+
#include "lib.h"
5+
6+
typedef struct ident *ident_t;
7+
8+
ident_t make_ident(const char *str);
9+
const char *istr(ident_t ident);
10+
11+
void ident_freeze(void);
12+
void ident_store(lib_t lib);
13+
void ident_load(lib_t lib);
14+
size_t ident_key(ident_t ident);
15+
16+
#endif // _IDENT_H

src/lexer.l

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/* -*- mode: c -*- */
2+
3+
/*
4+
* Copyright (C) 2008, 2010-2011 Nick Gasson
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
%{
21+
#include "tokens.h"
22+
23+
#define YY_INPUT(buf, result, max_size) { \
24+
result = get_next_char(buf, max_size); \
25+
if (result <= 0) \
26+
result = YY_NULL; \
27+
}
28+
29+
Lvals lvals;
30+
%}
31+
32+
/* TODO: look at string_literal and character_literal */
33+
34+
ID [a-zA-Z][a-zA-Z_0-9]*
35+
STRING \".*\"
36+
CHAR '.'
37+
COMMENT --.*\n
38+
INT [0-9]+
39+
40+
A [aA]
41+
B [bB]
42+
C [cC]
43+
D [dD]
44+
E [eE]
45+
F [fF]
46+
G [gG]
47+
H [hH]
48+
I [iI]
49+
L [lL]
50+
N [nN]
51+
M [mM]
52+
O [oO]
53+
P [pP]
54+
R [rR]
55+
S [sS]
56+
T [tT]
57+
U [uU]
58+
W [wW]
59+
Y [yY]
60+
X [xX]
61+
62+
ENTITY {E}{N}{T}{I}{T}{Y}
63+
IS {I}{S}
64+
END {E}{N}{D}
65+
GENERIC {G}{E}{N}{E}{R}{I}{C}
66+
PORT {P}{O}{R}{T}
67+
CONSTANT {C}{O}{N}{S}{T}{A}{N}{T}
68+
CONFIGURATION {C}{O}{N}{F}{I}{G}{U}{R}{A}{T}{I}{O}{N}
69+
COMPONENT {C}{O}{M}{P}{O}{N}{E}{N}{T}
70+
ARCHITECTURE {A}{R}{C}{H}{I}{T}{E}{C}{T}{U}{R}{E}
71+
OF {O}{F}
72+
BEGIN {B}{E}{G}{I}{N}
73+
AND {A}{N}{D}
74+
OR {O}{R}
75+
XOR {X}{O}{R}
76+
XNOR {X}{N}{O}{R}
77+
NAND {N}{A}{N}{D}
78+
ABS {A}{B}{S}
79+
NOT {N}{O}{T}
80+
ALL {A}{L}{L}
81+
IN {I}{N}
82+
OUT {O}{U}{T}
83+
BUFFER {B}{U}{F}{F}{E}{R}
84+
BUS {B}{U}{S}
85+
UNAFFECTED {U}{N}{A}{F}{F}{E}{C}{T}{E}{D}
86+
SIGNAL {S}{I}{G}{N}{A}{L}
87+
PROCESS {P}{R}{O}{C}{E}{S}{S}
88+
WAIT {W}{A}{I}{T}
89+
REPORT {R}{E}{P}{O}{R}{T}
90+
91+
%%
92+
93+
{COMMENT} { begin_token(yytext); }
94+
95+
{ENTITY} { begin_token(yytext); return tENTITY; }
96+
{IS} { begin_token(yytext); return tIS; }
97+
{END} { begin_token(yytext); return tEND; }
98+
{GENERIC} { begin_token(yytext); return tGENERIC; }
99+
{PORT} { begin_token(yytext); return tPORT; }
100+
{CONSTANT} { begin_token(yytext); return tCONSTANT; }
101+
{COMPONENT} { begin_token(yytext); return tCOMPONENT; }
102+
{CONFIGURATION} { begin_token(yytext); return tCONFIGURATION; }
103+
{ARCHITECTURE} { begin_token(yytext); return tARCHITECTURE; }
104+
{OF} { begin_token(yytext); return tOF; }
105+
{BEGIN} { begin_token(yytext); return tBEGIN; }
106+
{AND} { begin_token(yytext); return tAND; }
107+
{OR} { begin_token(yytext); return tOR; }
108+
{XOR} { begin_token(yytext); return tXOR; }
109+
{XNOR} { begin_token(yytext); return tXNOR; }
110+
{NAND} { begin_token(yytext); return tNAND; }
111+
{ABS} { begin_token(yytext); return tABS; }
112+
{NOT} { begin_token(yytext); return tNOT; }
113+
{ALL} { begin_token(yytext); return tALL; }
114+
{IN} { begin_token(yytext); return tIN; }
115+
{OUT} { begin_token(yytext); return tOUT; }
116+
{BUFFER} { begin_token(yytext); return tBUFFER; }
117+
{BUS} { begin_token(yytext); return tBUS; }
118+
{UNAFFECTED} { begin_token(yytext); return tUNAFFECTED; }
119+
{SIGNAL} { begin_token(yytext); return tSIGNAL; }
120+
{PROCESS} { begin_token(yytext); return tPROCESS; }
121+
{WAIT} { begin_token(yytext); return tWAIT; }
122+
{REPORT} { begin_token(yytext); return tREPORT; }
123+
124+
"(" { begin_token(yytext); return tLPAREN; }
125+
")" { begin_token(yytext); return tRPAREN; }
126+
";" { begin_token(yytext); return tSEMI; }
127+
":=" { begin_token(yytext); return tASSIGN; }
128+
":" { begin_token(yytext); return tCOLON; }
129+
"**" { begin_token(yytext); return tPOWER; }
130+
"," { begin_token(yytext); return tCOMMA; }
131+
"<=" { begin_token(yytext); return tLE; }
132+
{INT} { begin_token(yytext); return tINT; }
133+
{STRING} { begin_token(yytext); return tSTRING; }
134+
{CHAR} { begin_token(yytext); return tCHAR; }
135+
{ID} { begin_token(yytext); lvals.sval = strdup(yytext); return tID; }
136+
[ \t\r\n] { begin_token(yytext); }
137+
<<EOF>> { begin_token(yytext); return 0; }
138+
. { begin_token(yytext); return tERROR; }
139+
%%
140+

src/lib.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _LIB_H
2+
#define _LIB_H
3+
4+
#include <stdio.h>
5+
6+
typedef struct lib *lib_t;
7+
8+
lib_t find_lib(const char *name);
9+
lib_t make_lib(const char *name);
10+
FILE *lib_fopen(lib_t lib, const char *name, const char *mode);
11+
12+
#endif // _LIB_H

src/nhdl.c

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int main(int argc, char **argv)
2+
{
3+
return 0;
4+
}

src/tree.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef _TREE_H
2+
#define _TREE_H
3+
4+
#include "lib.h"
5+
6+
typedef enum tree_kind {
7+
T_ENTITY
8+
} tree_kind_t;
9+
10+
typedef struct tree *tree_t;
11+
12+
tree_t make_tree(tree_kind_t kind);
13+
14+
void tree_freeze(void);
15+
void tree_store(lib_t lib, tree_t tree);
16+
tree_t tree_load(lib_t lib, ident_t ident);
17+
18+
#endif // _TREE_H

test/Makefile.am

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
check_PROGRAMS = test_lib
2+
TESTS = $(check_PROGRAMS)
3+
4+
AM_CFLAGS = -I $(top_srcdir)/src
5+
6+
test_lib_SOURCES = test_lib.c

test/test_lib.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "lib.h"
2+
3+
#include <check.h>
4+
5+
START_TEST(test_name)
6+
{
7+
8+
}
9+
END_TEST
10+
11+
12+
int main(void)
13+
{
14+
return 1;
15+
}
16+

0 commit comments

Comments
 (0)