1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-06 03:17:33 +02:00

Got rid of the requirement to have a "package" directive. Fixed a grammar error

found in the process. Also taught the regression test system a new trick: the
path to "fped" can be passed in the environment variable FPED. E.g.,
FPED=fped.r5943 make test

- fped.c (usage, main): duplicating the -T option produces a dump to stdout
  before exiting (like %dump would)
- test/Common: new command fped_dump to invoked fped with a second -T option
- test/Common: if the environment variable FPED is set, use its content to
  invoke fped (default is ../fped)
- test/Common: if the environment variable CWD_PREFIX is set, prepend it to
  $FPED if the latter is a relative path 
- Makefile (test, tests): set CWD_PREFIX to .., so that the path given in FPED
  is valid at the point of invocation
- fpd.y: revised grammar to make "package" optional
- fpd.y: measurements were syntactically allowed inside non-root frame
  (test/structure)
- test/structure: test various combinations of the grammatical file structure
- test/tsort: removed all the now unnecessary "package" directives



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5944 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2010-04-26 23:11:22 +00:00
parent bc27b094af
commit 39fef16d1c
7 changed files with 147 additions and 26 deletions

View File

@ -162,7 +162,7 @@ test tests: all
LANG= sh -c \
'passed=0 && cd test && \
for n in [a-z]*; do \
SCRIPT=$$n . ./$$n; done; \
SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
echo "Passed all $$passed tests"'
valgrind:

7
README
View File

@ -148,6 +148,8 @@ unit mm
unit mil
unit auto
If the "unit" directive is omitted, fped defaults to millimeters.
When saving a footprint definition, the default unit is set to the
unit set in the GUI.
@ -301,8 +303,9 @@ meas a b 0.2 mm
Package name
- - - - - -
The package name is a string of printable ASCII characters, including
spaces.
The package name is a non-empty string of printable ASCII characters,
including spaces. If the "package" directive is omitted, fped defaults
to using the name "_".
package "<name>"

23
fpd.y
View File

@ -342,7 +342,10 @@ all:
;
fpd:
| frame_defs part_name opt_unit frame_items
frame_defs part_name opt_unit opt_frame_items opt_measurements
| frame_defs unit opt_frame_items opt_measurements
| frame_defs frame_items opt_measurements
| frame_defs opt_measurements
;
part_name:
@ -364,7 +367,11 @@ part_name:
;
opt_unit:
| TOK_UNIT ID
| unit
;
unit:
TOK_UNIT ID
{
if (!strcmp($2, "mm"))
curr_unit = curr_unit_mm;
@ -400,14 +407,18 @@ frame_def:
frames = curr_frame;
last_frame = curr_frame;
}
frame_items '}'
opt_frame_items '}'
{
set_frame(root_frame);
}
;
opt_frame_items:
| frame_items
;
frame_items:
| measurements
frame_item
| frame_item frame_items
;
@ -763,6 +774,10 @@ pad_type:
}
;
opt_measurements:
| measurements
;
measurements:
meas
{

7
fped.c
View File

@ -65,11 +65,12 @@ static void load_file(const char *name)
static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-k] [-p|-P] [-T] [cpp_option ...] [in_file [out_file]]\n\n"
"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
" -k write KiCad output, then exit\n"
" -p write Postscript output, then exit\n"
" -P write Postscript output (full page), then exit\n"
" -T test mode. Load file, then exit\n"
" -T -T test mode. Load file, dump to stdout, then exit\n"
" cpp_option -Idir, -Dname[=value], or -Uname\n"
, name);
exit(1);
@ -85,6 +86,7 @@ int main(int argc, char **argv)
char opt[] = "-?";
int error;
int batch = 0;
int test_mode = 0;
int batch_write_kicad = 0;
int batch_write_ps = 0, batch_write_ps_fullpage = 0;
int c;
@ -102,6 +104,7 @@ int main(int argc, char **argv)
break;
case 'T':
batch = 1;
test_mode++;
break;
case 'D':
case 'U':
@ -167,6 +170,8 @@ int main(int argc, char **argv)
if (error)
return error;
}
if (test_mode > 1)
dump(stdout);
purge();
inst_revert();

View File

@ -17,7 +17,7 @@ fped()
echo -n "$1: " 1>&2
shift
cat >_in
$VALGRIND ../fped -T _in "$@" >_out 2>&1 || {
$VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
echo FAILED "($SCRIPT)" 1>&2
cat _out
rm -f _in _out
@ -27,12 +27,18 @@ fped()
}
fped_dump()
{
fped "$@" -T
}
fped_fail()
{
echo -n "$1: " 1>&2
shift
cat >_in
$VALGRIND ../fped -T _in "$@" >_out 2>&1 && {
$VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && {
echo FAILED "($SCRIPT)" 1>&2
cat _out
rm -f _in _out
@ -54,3 +60,8 @@ expect()
rm -f _out _diff
passed=`expr ${passed:-0} + 1`
}
if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then
FPED="$CWD_PREFIX/$FPED"
fi

103
test/structure Executable file
View File

@ -0,0 +1,103 @@
#!/bin/sh
. ./Common
###############################################################################
fped_dump "structure: empty file" <<EOF
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
package "_"
unit mm
EOF
#------------------------------------------------------------------------------
fped_dump "structure: just an empty frame definition" <<EOF
frame foo {
}
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
frame foo {
}
package "_"
unit mm
EOF
#------------------------------------------------------------------------------
fped_dump "structure: just the package name" <<EOF
package "hello"
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
package "hello"
unit mm
EOF
#------------------------------------------------------------------------------
fped_dump "structure: just the unit" <<EOF
unit mil
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
package "_"
unit mil
EOF
#------------------------------------------------------------------------------
fped_dump "structure: just one root frame item" <<EOF
vec @(1mm, 1mm)
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
package "_"
unit mm
__0: vec @(1mm, 1mm)
EOF
#------------------------------------------------------------------------------
fped_dump "structure: frame plus measurement" <<EOF
frame f {
a: vec @(0mm, 0mm)
b: vec @(1mm, 1mm)
}
meas f.a -> f.b
EOF
expect <<EOF
/* MACHINE-GENERATED ! */
frame f {
a: vec @(0mm, 0mm)
b: vec @(1mm, 1mm)
}
package "_"
unit mm
meas f.a -> f.b
EOF
#------------------------------------------------------------------------------
fped_fail "structure: measurement in frame" <<EOF
frame f {
a: vec @(0mm, 0mm)
b: vec @(1mm, 1mm)
meas f.a -> f.b
}
EOF
expect <<EOF
4: syntax error near "meas"
EOF
###############################################################################

View File

@ -4,8 +4,6 @@
###############################################################################
fped "tsort: total order" <<EOF
package "_"
%tsort {
a b
a c
@ -25,8 +23,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: partial order change (1)" <<EOF
package "_"
%tsort {
a b
a c
@ -44,8 +40,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: partial order change (2)" <<EOF
package "_"
%tsort {
b c
c d
@ -62,8 +56,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: old order differs from resolution order" <<EOF
package "_"
%tsort {
+a +b +c +d
a c
@ -81,8 +73,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: order change due to priority" <<EOF
package "_"
%tsort {
a b
a c 1
@ -99,8 +89,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: priority accumulation without decay" <<EOF
package "_"
%tsort {
+a +b +c +d
a b 1
@ -117,8 +105,6 @@ EOF
#------------------------------------------------------------------------------
fped "tsort: priority accumulation with decay" <<EOF
package "_"
%tsort {
+a -b +c +d
a b 1
@ -135,8 +121,6 @@ EOF
#------------------------------------------------------------------------------
fped_fail "tsort: cycle" <<EOF
package "_"
%tsort {
a b
b a