---
software/libfpvm/Makefile | 21 +---
software/libfpvm/fnp.ids | 284 --------------------------------------
software/libfpvm/fpvm-export.c | 67 ---------
software/libfpvm/idgen | 57 --------
software/libfpvm/parser.y | 169 ----------------------
software/libfpvm/parser_helper.c | 77 ----------
software/libfpvm/parser_helper.h | 26 ----
software/libfpvm/parser_itf.h | 33 -----
software/libfpvm/scanner.h | 46 ------
software/libfpvm/scanner.re | 122 ----------------
software/libfpvm/subdir.mak | 25 +---
software/libfpvm/unique.c | 137 ------------------
software/libfpvm/unique.h | 18 ---
13 files changed, 5 insertions(+), 1077 deletions(-)
delete mode 100644 software/libfpvm/fnp.ids
delete mode 100644 software/libfpvm/fpvm-export.c
delete mode 100755 software/libfpvm/idgen
delete mode 100644 software/libfpvm/parser.y
delete mode 100644 software/libfpvm/parser_helper.c
delete mode 100644 software/libfpvm/parser_helper.h
delete mode 100644 software/libfpvm/parser_itf.h
delete mode 100644 software/libfpvm/scanner.h
delete mode 100644 software/libfpvm/scanner.re
delete mode 100644 software/libfpvm/unique.c
delete mode 100644 software/libfpvm/unique.h
diff --git a/software/libfpvm/Makefile b/software/libfpvm/Makefile
index cb2a03e..926b3a0 100644
--- a/software/libfpvm/Makefile
+++ b/software/libfpvm/Makefile
@@ -2,26 +2,12 @@ MMDIR=../..
INCLUDES_NOLIBC=-DPRINTF_FLOAT
include $(MMDIR)/software/include.mak
-OBJECTS=fpvm.o parser_helper.o scanner.o parser.o gfpus.o lnfpus.o pfpu.o \
- unique.o fpvm-export.o
+OBJECTS=fpvm.o gfpus.o lnfpus.o pfpu.o
.PHONY: all clean depend install
all: libfpvm.a
-%.c: %.re
- re2c -o $@ $<
-
-scanner.c: parser.h
-
-parser.h: parser.c
-
-%.c: %.y
- lemon $<
-
-%.h %.inc: %.ids
- ./idgen $<
-
libfpvm.a: $(OBJECTS)
$(AR) clr libfpvm.a $(OBJECTS)
$(RANLIB) libfpvm.a
@@ -32,13 +18,12 @@ install: all
mkdir -p $(RTEMS_MAKEFILE_PATH)/lib/include/fpvm
cp ../include/fpvm/* $(RTEMS_MAKEFILE_PATH)/lib/include/fpvm
-depend: parser.c scanner.c
+depend:
makedepend -Y -- $(CFLAGS) -- *.c
clean:
- rm -f $(OBJECTS) scanner.c parser.c parser.h parser.out libfpvm.a
+ rm -f $(OBJECTS) libfpvm.a
rm -f .*~ *~ Makefile.bak
- rm -f fnp.h fnp.inc
# DO NOT DELETE
diff --git a/software/libfpvm/fnp.ids b/software/libfpvm/fnp.ids
deleted file mode 100644
index a310be1..0000000
--- a/software/libfpvm/fnp.ids
+++ /dev/null
@@ -1,284 +0,0 @@
-#
-# fnp.ids - Identifiers we already know Flickernoise will use
-#
-# We sort this list at compile time and can then perform a quick O(M*log N)
-# search on it, with M being the average length of an identifier and N the
-# number of identifiers in this list.
-#
-# User-defined identifiers and identifiers omitted from fnp.ids for any
-# other reason currently go to a linear list where they're searched in
-# O(M*N) time.
-#
-
-#
-# Built-in functions
-#
-
-above
-abs
-below
-cos
-equal
-f2i
-icos
-i2f
-if
-int
-invsqrt
-isin
-max
-min
-quake
-sin
-sqr
-sqrt
-tsign
-
-#
-#
-# Per-Frame Variables
-#
-
-sx
-sy
-cx
-cy
-rot
-dx
-dy
-zoom
-decay
-wave_mode
-wave_scale
-wave_additive
-wave_usedots
-wave_brighten
-wave_thick
-wave_x
-wave_y
-wave_r
-wave_g
-wave_b
-wave_a
-
-ob_size
-ob_r
-ob_g
-ob_b
-ob_a
-ib_size
-ib_r
-ib_g
-ib_b
-ib_a
-
-nMotionVectorsY
-mv_dx
-mv_dy
-mv_l
-mv_r
-mv_g
-mv_b
-mv_a
-
-bTexWrap
-
-time
-bass
-mid
-treb
-bass_att
-mid_att
-treb_att
-
-warp
-fWarpAnimSpeed
-fWarpScale
-
-q1
-q2
-q3
-q4
-q5
-q6
-q7
-q8
-
-fVideoEchoAlpha
-fVideoEchoZoom
-nVideoEchoOrientation
-
-dmx1
-dmx2
-dmx3
-dmx4
-dmx5
-dmx6
-dmx7
-dmx8
-
-idmx1
-idmx2
-idmx3
-idmx4
-idmx5
-idmx6
-idmx7
-idmx8
-
-osc1
-osc2
-osc3
-osc4
-
-midi1
-midi2
-midi3
-midi4
-midi5
-midi6
-midi7
-midi8
-
-video_a
-
-image1_a
-image1_x
-image1_y
-image1_zoom
-image2_a
-image2_x
-image2_y
-image2_zoom
-
-#
-# Aliases
-#
-
-fDecay
-nWaveMode
-fWaveScale
-bAdditiveWaves
-bWaveDots
-bMaximizeWaveColor
-bWaveThick
-fWaveAlpha
-
-#
-# Per-Vertex Variables
-#
-
-# System
-
-_texsize
-_hmeshsize
-_vmeshsize
-
-# MilkDrop
-
-sx
-sy
-cx
-cy
-rot
-dx
-dy
-zoom
-
-time
-bass
-mid
-treb
-bass_att
-mid_att
-treb_att
-
-warp
-fWarpAnimSpeed
-fWarpScale
-
-q1
-q2
-q3
-q4
-q5
-q6
-q7
-q8
-
-idmx1
-idmx2
-idmx3
-idmx4
-idmx5
-idmx6
-idmx7
-idmx8
-
-osc1
-osc2
-osc3
-osc4
-
-midi1
-midi2
-midi3
-midi4
-midi5
-midi6
-midi7
-midi8
-
-#
-# FPVM internal variables
-#
-
-_Xo
-_Yo
-_Xi
-_Yi
-
-#
-# PVV internal variables
-#
-
-# Initialization
-
-x
-y
-rad
-
-# Zoom
-
-_invzoom
-_xy
-_yz
-
-# Scale
-
-_xs
-_ys
-
-# Warp
-
-_warptime
-_invwarpscale
-_f0
-_f1
-_f2
-_f3
-_ox2
-_oy2
-_xw
-_yw
-
-# Rotate
-
-_cosr
-_sinr
-_u
-_v
-_xr
-_yr
-_xd
-_yd
diff --git a/software/libfpvm/fpvm-export.c b/software/libfpvm/fpvm-export.c
deleted file mode 100644
index bf1ca1f..0000000
--- a/software/libfpvm/fpvm-export.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-
-#include <fpvm/fpvm.h>
-#include <fpvm/ast.h>
-
-#include "unique.h"
-#include "parser_helper.h"
-
-
-/* @@@ move later */
-int fpvm_do_assign(struct fpvm_fragment *fragment, const char *dest,
- struct ast_node *n);
-void fpvm_do_init(struct fpvm_fragment *fragment, int vector_mode);
-
-
-void fpvm_init(struct fpvm_fragment *fragment, int vector_mode)
-{
- /*
- * We need to pass these through unique() because fpvm_assign does
- * the same. Once things are in Flickernoise, we can get rid of these
- * calls to unique().
- */
-
- _Xi = unique("_Xi");
- _Xo = unique("_Xo");
- _Yi = unique("_Yi");
- _Yo = unique("_Yo");
- fpvm_do_init(fragment, vector_mode);
-}
-
-
-int fpvm_assign(struct fpvm_fragment *fragment, const char *dest,
- const char *expr)
-{
- struct ast_node *n;
- int res;
-
- n = fpvm_parse(expr);
- if(n == NULL) {
- snprintf(fragment->last_error, FPVM_MAXERRLEN, "Parse error");
- return 0;
- }
-
- dest = unique(dest);
-
- res = fpvm_do_assign(fragment, dest, n);
- fpvm_parse_free(n);
-
- return res;
-}
diff --git a/software/libfpvm/idgen b/software/libfpvm/idgen
deleted file mode 100755
index 98069cc..0000000
--- a/software/libfpvm/idgen
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh -e
-#
-# idgen - Identifier table generator
-#
-# Copyright 2011 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, version 3 of the License.
-#
-
-
-usage()
-{
- echo "usage: $0 file" 1>&2
- exit 1
-}
-
-
-[ "$1" ] || usage
-[ "$2" ] && usage
-[ -r "$1" ] || { echo "$1: not found" 1&2; exit 1; }
-
-trap "echo $1.h $1.inc" 0
-
-f=`basename "$1" .ids`
-
-cat <<EOF >$f.h
-/* MACHINE-GENERATED. DO NOT EDIT ! */
-
-#ifndef IDS_H
-#define IDS_H
-
-extern const char *well_known[];
-
-EOF
-
-cat <<EOF >$f.inc
-/* MACHINE-GENERATED. DO NOT EDIT ! */
-
-EOF
-
-sed 's/#.*//;s/ //g;/^$/d' $1 | sort | uniq | {
- i=0
- while read n; do
- echo "#define ID_$n (well_known[$i])" >>$f.h
- echo "\"$n\"," >>$f.inc
- i=`expr $i + 1`
- done
-}
-
-cat <<EOF >>$f.h
-
-#endif /* !IDS_H */
-EOF
-
-trap 0
diff --git a/software/libfpvm/parser.y b/software/libfpvm/parser.y
deleted file mode 100644
index 6ed6b13..0000000
--- a/software/libfpvm/parser.y
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-%include {
- #include <assert.h>
- #include <string.h>
- #include <stdlib.h>
- #include <malloc.h>
- #include <math.h>
- #include "fpvm/ast.h"
- #include "parser_itf.h"
- #include "parser.h"
-
-
- const enum ast_op tok2op[] = {
- [TOK_IDENT] = op_ident,
- [TOK_CONSTANT] = op_constant,
- [TOK_PLUS] = op_plus,
- [TOK_MINUS] = op_minus,
- [TOK_MULTIPLY] = op_multiply,
- [TOK_DIVIDE] = op_divide,
- [TOK_PERCENT] = op_percent,
- [TOK_ABS] = op_abs,
- [TOK_ISIN] = op_isin,
- [TOK_ICOS] = op_icos,
- [TOK_SIN] = op_sin,
- [TOK_COS] = op_cos,
- [TOK_ABOVE] = op_above,
- [TOK_BELOW] = op_below,
- [TOK_EQUAL] = op_equal,
- [TOK_I2F] = op_i2f,
- [TOK_F2I] = op_f2i,
- [TOK_IF] = op_if,
- [TOK_TSIGN] = op_tsign,
- [TOK_QUAKE] = op_quake,
- [TOK_NOT] = op_not,
- [TOK_SQR] = op_sqr,
- [TOK_SQRT] = op_sqrt,
- [TOK_INVSQRT] = op_invsqrt,
- [TOK_MIN] = op_min,
- [TOK_MAX] = op_max,
- [TOK_INT] = op_int,
-
- };
-
- struct ast_node *node(int token, const char *id, struct ast_node *a,
- struct ast_node *b, struct ast_node *c)
- {
- struct ast_node *n;
-
- n = malloc(sizeof(struct ast_node));
- n->op = tok2op[token];
- n->label = id;
- n->contents.branches.a = a;
- n->contents.branches.b = b;
- n->contents.branches.c = c;
- return n;
- }
-}
-
-%start_symbol start
-%extra_argument {struct ast_node **parseout}
-%token_type {struct id *}
-
-%token_destructor { free($$); }
-
-%type start {struct ast_node *}
-%type node {struct ast_node *}
-%destructor node { free($$); }
-
-start(S) ::= node(N). {
- S = N;
- *parseout = S;
-}
-
-node(N) ::= TOK_CONSTANT(C). {
- N = node(TOK_CONSTANT, "", NULL, NULL, NULL);
- N->contents.constant = C->constant;
-}
-
-node(N) ::= ident(I). {
- N = node(I->token, I->label, NULL, NULL, NULL);
-}
-
-%left TOK_PLUS TOK_MINUS.
-%left TOK_MULTIPLY TOK_DIVIDE TOK_PERCENT.
-%left TOK_NOT.
-
-node(N) ::= node(A) TOK_PLUS node(B). {
- N = node(TOK_PLUS, "+", A, B, NULL);
-}
-
-node(N) ::= node(A) TOK_MINUS node(B). {
- N = node(TOK_MINUS, "-", A, B, NULL);
-}
-
-node(N) ::= node(A) TOK_MULTIPLY node(B). {
- N = node(TOK_MULTIPLY, "*", A, B, NULL);
-}
-
-node(N) ::= node(A) TOK_DIVIDE node(B). {
- N = node(TOK_DIVIDE, "/", A, B, NULL);
-}
-
-node(N) ::= node(A) TOK_PERCENT node(B). {
- N = node(TOK_PERCENT, "%", A, B, NULL);
-}
-
-node(N) ::= TOK_MINUS node(A). [TOK_NOT] {
- N = node(TOK_NOT, "!", A, NULL, NULL);
-}
-
-node(N) ::= unary(I) TOK_LPAREN node(A) TOK_RPAREN. {
- N = node(I->token, I->label, A, NULL, NULL);
-}
-
-node(N) ::= binary(I) TOK_LPAREN node(A) TOK_COMMA node(B) TOK_RPAREN. {
- N = node(I->token, I->label, A, B, NULL);
-}
-
-node(N) ::= ternary(I) TOK_LPAREN node(A) TOK_COMMA node(B) TOK_COMMA node(C)
- TOK_RPAREN. {
- N = node(I->token, I->label, A, B, C);
-}
-
-node(N) ::= TOK_LPAREN node(A) TOK_RPAREN. {
- N = A;
-}
-
-ident(O) ::= TOK_IDENT(I). { O = I; }
-ident(O) ::= unary(I). { O = I; }
-ident(O) ::= binary(I). { O = I; }
-ident(O) ::= ternary(I). { O = I; }
-
-unary(O) ::= TOK_ABS(I). { O = I; }
-unary(O) ::= TOK_COS(I). { O = I; }
-unary(O) ::= TOK_F2I(I). { O = I; }
-unary(O) ::= TOK_ICOS(I). { O = I; }
-unary(O) ::= TOK_I2F(I). { O = I; }
-unary(O) ::= TOK_INT(I). { O = I; }
-unary(O) ::= TOK_INVSQRT(I). { O = I; }
-unary(O) ::= TOK_ISIN(I). { O = I; }
-unary(O) ::= TOK_QUAKE(I). { O = I; }
-unary(O) ::= TOK_SIN(I). { O = I; }
-unary(O) ::= TOK_SQR(I). { O = I; }
-unary(O) ::= TOK_SQRT(I). { O = I; }
-
-binary(O) ::= TOK_ABOVE(I). { O = I; }
-binary(O) ::= TOK_BELOW(I). { O = I; }
-binary(O) ::= TOK_EQUAL(I). { O = I; }
-binary(O) ::= TOK_MAX(I). { O = I; }
-binary(O) ::= TOK_MIN(I). { O = I; }
-binary(O) ::= TOK_TSIGN(I). { O = I; }
-
-ternary(O) ::= TOK_IF(I). { O = I; }
diff --git a/software/libfpvm/parser_helper.c b/software/libfpvm/parser_helper.c
deleted file mode 100644
index 4092dc7..0000000
--- a/software/libfpvm/parser_helper.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <malloc.h>
-#include <fpvm/ast.h>
-
-#include "scanner.h"
-#include "parser_itf.h"
-#include "parser_helper.h"
-
-struct ast_node *fpvm_parse(const char *expr)
-{
- struct scanner *s;
- int tok;
- struct id *identifier;
- void *p;
- struct ast_node *ast;
-
- s = new_scanner((unsigned char *)expr);
- ast = NULL;
- p = ParseAlloc(malloc);
- tok = scan(s);
- while(tok != TOK_EOF) {
- identifier = malloc(sizeof(struct id));
- identifier->token = tok;
- if(tok == TOK_CONSTANT) {
- identifier->constant = get_constant(s);
- identifier->label = "";
- } else {
- identifier->label = get_token(s);
- }
- Parse(p, tok, identifier, &ast);
- if(tok == TOK_ERROR) {
- printf("FPVM: scan error\n");
- ParseFree(p, free);
- delete_scanner(s);
- return NULL;
- }
- tok = scan(s);
- }
- Parse(p, TOK_EOF, NULL, &ast);
- ParseFree(p, free);
- delete_scanner(s);
-
- if(ast == NULL) {
- printf("FPVM: parse error\n");
- return NULL;
- }
-
- return ast;
-}
-
-void fpvm_parse_free(struct ast_node *node)
-{
- if(node == NULL) return;
- if(node->label[0] != 0) {
- fpvm_parse_free(node->contents.branches.a);
- fpvm_parse_free(node->contents.branches.b);
- fpvm_parse_free(node->contents.branches.c);
- }
- free(node);
-}
diff --git a/software/libfpvm/parser_helper.h b/software/libfpvm/parser_helper.h
deleted file mode 100644
index d436312..0000000
--- a/software/libfpvm/parser_helper.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __PARSER_HELPER_H
-#define __PARSER_HELPER_H
-
-#include <fpvm/ast.h>
-
-struct ast_node *fpvm_parse(const char *expr);
-void fpvm_parse_free(struct ast_node *node);
-
-#endif /* __PARSER_HELPER_H */
diff --git a/software/libfpvm/parser_itf.h b/software/libfpvm/parser_itf.h
deleted file mode 100644
index 895da5f..0000000
--- a/software/libfpvm/parser_itf.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __PARSER_ITF_H
-#define __PARSER_ITF_H
-
-#define NDEBUG
-
-struct id {
- int token;
- const char *label;
- float constant;
-};
-
-void *ParseAlloc(void *(*mallocProc)(size_t));
-void ParseFree(void *p, void (*freeProc)(void*));
-void Parse(void *yyp, int yymajor, struct id *yyminor, struct ast_node **p);
-
-#endif /* __PARSER_ITF_H */
diff --git a/software/libfpvm/scanner.h b/software/libfpvm/scanner.h
deleted file mode 100644
index 627364a..0000000
--- a/software/libfpvm/scanner.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __SCANNER_H
-#define __SCANNER_H
-
-#define TOK_ERROR (-1)
-#define TOK_EOF 0
-
-#include "parser.h"
-
-struct scanner {
- unsigned char *marker;
- unsigned char *old_cursor;
- unsigned char *cursor;
- unsigned char *limit;
-};
-
-struct scanner *new_scanner(unsigned char *input);
-void delete_scanner(struct scanner *s);
-
-/* get to the next token and return its type */
-int scan(struct scanner *s);
-
-/* get the unique string comprising the current token
- */
-const char *get_token(struct scanner *s);
-
-float get_constant(struct scanner *s);
-
-#endif /* __SCANNER_H */
-
diff --git a/software/libfpvm/scanner.re b/software/libfpvm/scanner.re
deleted file mode 100644
index 1362ab4..0000000
--- a/software/libfpvm/scanner.re
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#include "unique.h"
-#include "scanner.h"
-
-#define YYCTYPE unsigned char
-#define YYCURSOR s->cursor
-#define YYLIMIT s->limit
-
-/* refilling not supported */
-#define YYMARKER s->marker
-#define YYFILL(n)
-
-struct scanner *new_scanner(unsigned char *input)
-{
- struct scanner *s;
-
- s = malloc(sizeof(struct scanner));
- if(s == NULL) return NULL;
-
- s->marker = input;
- s->old_cursor = input;
- s->cursor = input;
- s->limit = input + strlen((char *)input);
-
- return s;
-}
-
-void delete_scanner(struct scanner *s)
-{
- free(s);
-}
-
-int scan(struct scanner *s)
-{
- std:
- if(s->cursor == s->limit) return TOK_EOF;
- s->old_cursor = s->cursor;
-
- /*!re2c
- [\x20\r\t] { goto std; }
- [0-9]+ { return TOK_CONSTANT; }
- [0-9]* "." [0-9]* { return TOK_CONSTANT; }
-
- "above" { return TOK_ABOVE; }
- "abs" { return TOK_ABS; }
- "below" { return TOK_BELOW; }
- "cos" { return TOK_COS; }
- "equal" { return TOK_EQUAL; }
- "f2i" { return TOK_F2I; }
- "icos" { return TOK_ICOS; }
- "i2f" { return TOK_I2F; }
- "if" { return TOK_IF; }
- "int" { return TOK_INT; }
- "invsqrt" { return TOK_INVSQRT; }
- "isin" { return TOK_ISIN; }
- "max" { return TOK_MAX; }
- "min" { return TOK_MIN; }
- "quake" { return TOK_QUAKE; }
- "sin" { return TOK_SIN; }
- "sqr" { return TOK_SQR; }
- "sqrt" { return TOK_SQRT; }
- "tsign" { return TOK_TSIGN; }
-
- [a-zA-Z_0-9]+ { return TOK_IDENT; }
- "+" { return TOK_PLUS; }
- "-" { return TOK_MINUS; }
- "*" { return TOK_MULTIPLY; }
- "/" { return TOK_DIVIDE; }
- "%" { return TOK_PERCENT; }
- "(" { return TOK_LPAREN; }
- ")" { return TOK_RPAREN; }
- "," { return TOK_COMMA; }
- [\x00-\xff] { return TOK_ERROR; }
- */
-}
-
-const char *get_token(struct scanner *s)
-{
- return unique_n((const char *) s->old_cursor,
- s->cursor - s->old_cursor);
-}
-
-float get_constant(struct scanner *s)
-{
- const unsigned char *p;
- float v = 0;
- float m = 1;
-
- for(p = s->old_cursor; p != s->cursor; p++) {
- if(*p == '.')
- goto dot;
- v = v*10+(*p-'0');
- }
- return v;
-
-dot:
- for(p++; p != s->cursor; p++) {
- m /= 10;
- v += m*(*p-'0');
- }
- return v;
-}
diff --git a/software/libfpvm/subdir.mak b/software/libfpvm/subdir.mak
index af97ffc..f2d83c1 100644
--- a/software/libfpvm/subdir.mak
+++ b/software/libfpvm/subdir.mak
@@ -1,30 +1,10 @@
-OBJECTS=fpvm.o parser_helper.o scanner.o parser.o gfpus.o lnfpus.o pfpu.o \
- unique.o fpvm-export.o
+OBJECTS=fpvm.o gfpus.o lnfpus.o pfpu.o
all: libfpvm.a
-%.c: %.re
- re2c -o $@ $<
-
-../scanner.c: ../parser.h
-
-../parser.h: ../parser.c
-
-../parser_helper.c: ../parser.h
-
-../fpvm.c: ../parser.h
-
-../unique.c: fnp.inc
-
-%.c: %.y
- lemon $<
-
%.o: ../%.c
$(CC) $(CFLAGS) -I. -c -o $@ $<
-%.h %.inc: ../%.ids
- ../idgen $<
-
libfpvm.a: $(OBJECTS)
$(AR) clr libfpvm.a $(OBJECTS)
$(RANLIB) libfpvm.a
@@ -32,5 +12,4 @@ libfpvm.a: $(OBJECTS)
.PHONY: clean
clean:
- rm -f $(OBJECTS) ../scanner.c ../parser.c ../parser.h ../parser.out
libfpvm.a test .*~ *~ Makefile.bak
- rm -f fnp.h fnp.inc
+ rm -f $(OBJECTS) libfpvm.a test .*~ *~ Makefile.bak
diff --git a/software/libfpvm/unique.c b/software/libfpvm/unique.c
deleted file mode 100644
index c571f6d..0000000
--- a/software/libfpvm/unique.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * unique.c - Unique string store
- *
- * Copyright 2011 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, version 3 of the License.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "unique.h"
-
-
-#define INITIAL_ALLOC 64
-
-
-struct key_n {
- const char *s;
- int n;
-};
-
-const char *well_known[] = {
-#include "fnp.inc"
-};
-
-static const char **vars = NULL;
-static int num_vars = 0, allocated = 0;
-
-
-/*
- * "a" is not NUL-terminated and its length "a" is determined by "n".
- * "b" is NUL-terminated.
- */
-
-static int strcmp_n(const char *a, const char *b, int n)
-{
- int diff;
-
- diff = strncmp(a, b, n);
- if (diff)
- return diff;
- /* handle implicit NUL in string "a" */
- return -b[n];
-}
-
-
-static char *strdup_n(const char *s, int n)
-{
- char *new;
-
- new = malloc(n+1);
- memcpy(new, s, n);
- new[n] = 0;
- return new;
-}
-
-
-static void grow_table(void)
-{
- if(num_vars != allocated)
- return;
-
- allocated = allocated ? allocated*2 : INITIAL_ALLOC;
- vars = realloc(vars, allocated*sizeof(*vars));
-}
-
-
-static int cmp(const void *a, const void *b)
-{
- return strcmp(a, *(const char **) b);
-}
-
-
-static int cmp_n(const void *a, const void *b)
-{
- const struct key_n *key = a;
-
- return strcmp_n(key->s, *(const char **) b, key->n);
-}
-
-
-const char *unique(const char *s)
-{
- const char **res;
- const char **walk;
-
- if(!isalnum(*s) && *s != '_')
- return s;
- res = bsearch(s, well_known, sizeof(well_known)/sizeof(*well_known),
- sizeof(s), cmp);
- if(res)
- return *res;
- for(walk = vars; walk != vars+num_vars; walk++)
- if(!strcmp(*walk, s))
- return *walk;
- grow_table();
- return vars[num_vars++] = strdup(s);
-}
-
-
-const char *unique_n(const char *s, int n)
-{
- struct key_n key = {
- .s = s,
- .n = n,
- };
- const char **res;
- const char **walk;
-
- if(!isalnum(*s) && *s != '_')
- return s;
- res = bsearch(&key, well_known, sizeof(well_known)/sizeof(*well_known),
- sizeof(s), cmp_n);
- if(res)
- return *res;
- for(walk = vars; walk != vars+num_vars; walk++)
- if(!strcmp_n(s, *walk, n))
- return *walk;
- grow_table();
- return vars[num_vars++] = strdup_n(s, n);
-}
-
-
-void unique_free(void)
-{
- int i;
-
- for(i = 0; i != num_vars; i++)
- free((void *) vars[i]);
- free(vars);
- num_vars = allocated = 0;
-}
diff --git a/software/libfpvm/unique.h b/software/libfpvm/unique.h
deleted file mode 100644
index ff069ac..0000000
--- a/software/libfpvm/unique.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * unique.h - Unique string store
- *
- * Copyright 2011 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, version 3 of the License.
- */
-
-#ifndef UNIQUE_H
-#define UNIQUE_H
-
-const char *unique(const char *s);
-const char *unique_n(const char *s, int n);
-void unique_free(void);
-
-#endif /* !UNIQUE_H */
--
1.7.1
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode