[cig-commits] r6988 - cs/spike/trunk

leif at geodynamics.org leif at geodynamics.org
Mon May 28 18:22:04 PDT 2007


Author: leif
Date: 2007-05-28 18:22:04 -0700 (Mon, 28 May 2007)
New Revision: 6988

Modified:
   cs/spike/trunk/Makefile.am
   cs/spike/trunk/configure.ac
   cs/spike/trunk/cspk.cc
   cs/spike/trunk/gram.y
   cs/spike/trunk/scan.l
Log:
Got build working again.

Modified: cs/spike/trunk/Makefile.am
===================================================================
--- cs/spike/trunk/Makefile.am	2007-05-29 00:24:45 UTC (rev 6987)
+++ cs/spike/trunk/Makefile.am	2007-05-29 01:22:04 UTC (rev 6988)
@@ -1,18 +1,15 @@
 ## Process this file with automake to produce Makefile.in
 
-
 ACLOCAL_AMFLAGS = -I ./m4
-SUBDIRS = elsa spike
+SUBDIRS = elsa
 
+bin_PROGRAMS = cspk mkpyxm
 
-bin_PROGRAMS = mkpyxm pyspike
-bin_SCRIPTS = spikec
-
 INCLUDES =
 
+
 # ~~~ mkpyxm ~~~
 
-
 INCLUDES += -Ielsa/elsa -Ielsa/elkhound -Ielsa/ast -Ielsa/smbase
 mkpyxm_SOURCES = mkpyxm.cc
 mkpyxm_LDADD = \
@@ -24,85 +21,23 @@
 
 # ~~~ spike ~~~
 
-
-abs_top_srcdir = @abs_top_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_builddir = @abs_builddir@
-instINTERPRETER = $(bindir)/pyspike
-instPYTHONPATH = $(pythondir):$(pyexecdir):$(PYTHONPATH)
-noinstINTERPRETER = $(abs_builddir)/pyspike
-noinstPYTHONPATH = $(abs_top_srcdir)/spike:$(PYTHONPATH)
-
-
-# spike (top-level Python script)
-
-do_build = sed -e s%[@]INTERPRETER[@]%$(noinstINTERPRETER)%g -e s%[@]PYTHONPATH[@]%$(noinstPYTHONPATH)%g
-do_install = sed -e s%[@]INTERPRETER[@]%$(instINTERPRETER)%g -e s%[@]PYTHONPATH[@]%$(instPYTHONPATH)%g
-spikec: $(srcdir)/spike/bin/spikec.in Makefile
-	$(do_build) < $(srcdir)/spike/bin/spikec.in > $@ || (rm -f $@ && exit 1)
-	chmod +x $@
-install-binSCRIPTS: $(bin_SCRIPTS)
-	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
-	@list='$(bin_SCRIPTS)'; for p in $$list; do \
-	  if test -f "$$p.in"; then d=; else d="$(srcdir)/spike/bin/"; fi; \
-	  if test -f $$d$$p.in; then \
-	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
-	    echo " $(do_install) '$$d$$p.in' > '$(DESTDIR)$(bindir)/$$f'"; \
-	    $(do_install) "$$d$$p.in" > "$(DESTDIR)$(bindir)/$$f"; \
-	    echo " chmod +x '$(DESTDIR)$(bindir)/$$f'"; \
-	    chmod +x "$(DESTDIR)$(bindir)/$$f"; \
-	  else :; fi; \
-	done
-
-
-# pyspike (parser + embedded Python interpreter)
-
-INCLUDES += -I$(srcdir)/spike/Spike/Compiler -I$(PYTHON_INCDIR)
 AM_YFLAGS = -dv
 
-pyspike_SOURCES = \
-	spike/Spike/Compiler/gram.y \
-	spike/Spike/Compiler/scan.l \
-	spike/Spike/Compiler/main.c \
-	parser.c \
-	$(EMPTY_MACRO)
+cspk_SOURCES = \
+	cspk.cc \
+	gram.y \
+	scan.l \
+	$(empty)
 
-$(srcdir)/spike/Spike/Compiler/gram.y: parser.h
-
-parser.h: parser.c
-
-parser.c: $(srcdir)/spike/Spike/Compiler/parser.pyx
-	pyrexc $< -o parser.c
-
-pyspike$(EXEEXT): $(pyspike_OBJECTS) $(pyspike_DEPENDENCIES) 
-	@rm -f pyspike$(EXEEXT)
-	$(LINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) \
-		$(pyspike_LDFLAGS) $(pyspike_OBJECTS) $(pyspike_LDADD) \
-		$(PYTHON_BLDLIBRARY) \
-		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
-		$(LIBS) \
-		$(PYTHON_LDLAST)
-
-
 EXTRA_DIST = \
 	gram.h \
-	parser.c \
-	parser.h \
-	spike/spikec.py \
-	spike/bin/spikec.in \
-	$(EMPTY_MACRO)
+	$(empty)
 
-
 CLEANFILES = \
 	scan.c \
 	gram.c \
 	gram.output \
-	parser.h \
-	parser.pxi \
-	parser.c \
-	spikec \
-	$(EMPTY_MACRO)
+	$(empty)
 
 
 ## end of Makefile.am

Modified: cs/spike/trunk/configure.ac
===================================================================
--- cs/spike/trunk/configure.ac	2007-05-29 00:24:45 UTC (rev 6987)
+++ cs/spike/trunk/configure.ac	2007-05-29 01:22:04 UTC (rev 6988)
@@ -3,18 +3,13 @@
 dnl
 
 AC_PREREQ(2.59)
-AC_INIT([babel], [0.1.0], [cig-cs at geodynamics.org], [babel])
-AC_CONFIG_AUX_DIR([./aux-config])
-AC_CONFIG_SRCDIR([mkpyxm.cc])
+AC_INIT([spike], [0.1.0], [cig-cs at geodynamics.org])
+AC_CONFIG_SRCDIR([cspk.cc])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign])
 
 # 'configure' options
-AC_ARG_VAR(PYTHON, [Python interpreter])
-AC_ARG_VAR(PYTHONPATH, [Python module search path])
-AM_PATH_PYTHON([2.3])
-CIT_PYTHON_SYSCONFIG
 
 # Checks for programs.
 AC_PROG_CC
@@ -30,8 +25,7 @@
 # Checks for library functions.
 
 AC_CONFIG_FILES([Makefile
-                 elsa/Makefile
-                 spike/Makefile])
+                 elsa/Makefile])
 
 AC_CONFIG_SUBDIRS([elsa])
 

Modified: cs/spike/trunk/cspk.cc
===================================================================
--- cs/spike/trunk/cspk.cc	2007-05-29 00:24:45 UTC (rev 6987)
+++ cs/spike/trunk/cspk.cc	2007-05-29 01:22:04 UTC (rev 6988)
@@ -1,32 +1,29 @@
 
 #include <stdio.h>
-#include <Python.h>
 
-PyMODINIT_FUNC initparser(void);
+extern "C" int yyparse();
 
-struct _inittab inittab[] = {
-    { "parser", initparser },
-    { 0, 0 }
-};
-
-
-int yyparse();
-
 #ifdef YYDEBUG
-extern int yydebug;
+extern "C" int yydebug;
 #endif
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
 #ifdef YYDEBUG
     yydebug = 1;
 #endif
-    /* add our extension modules */
-    if (PyImport_ExtendInittab(inittab) == -1) {
-        fprintf(stderr, "%s: PyImport_ExtendInittab failed! Exiting...\n", argv[0]);
-        return 1;
-    }
-    return Py_Main(argc, argv);
+    yyparse();
+    return 0;
 }
 
+extern "C" {
+    extern int yylineno;
+    extern int column;
+}
+
+extern "C"
+void yyerror(char *s) {
+    fprintf(stderr, "%s:%d:%d: error %s\n",
+            "<unknown>", yylineno, column, s);
+}
+
 /* end of file */

Modified: cs/spike/trunk/gram.y
===================================================================
--- cs/spike/trunk/gram.y	2007-05-29 00:24:45 UTC (rev 6987)
+++ cs/spike/trunk/gram.y	2007-05-29 01:22:04 UTC (rev 6988)
@@ -1,13 +1,10 @@
 %{
 
-#include <Python.h>
-#undef DL_IMPORT
-#define DL_IMPORT(RTYPE) RTYPE
-#include "parser.h"
+#if 0
+#include "ast.h"
+#endif
 
-#define YYSTYPE PyObject *
-    
-#define CHECK(x) if (!(x)) { PyErr_Print(); Py_Exit(1); }
+#define CHECK(x)
 
 %}
 
@@ -449,8 +446,8 @@
 	;
 
 file
-	: external_definition         { external_definition($1); }
-	| file external_definition    { external_definition($2); }
+	: external_definition         { ; }
+	| file external_definition    { ; }
 	;
 
 external_definition
@@ -459,8 +456,8 @@
 	;
 
 function_definition
-	: declarator { push_scope(); } function_body    { pop_scope(); CHECK($$ = function_definition(Py_None, $1, $3)); }
-	| declaration_specifiers declarator { push_scope(); } function_body    { pop_scope(); CHECK($$ = function_definition($1, $2, $4)); }
+	: declarator function_body    { CHECK($$ = function_definition(Py_None, $1, $2)); }
+	| declaration_specifiers declarator function_body    { CHECK($$ = function_definition($1, $2, $3)); }
 	;
 
 function_body

Modified: cs/spike/trunk/scan.l
===================================================================
--- cs/spike/trunk/scan.l	2007-05-29 00:24:45 UTC (rev 6987)
+++ cs/spike/trunk/scan.l	2007-05-29 01:22:04 UTC (rev 6988)
@@ -9,16 +9,16 @@
 
 %{
 
-#define YYSTYPE PyObject *
-
 #include <stdio.h>
-#include <Python.h>
-#undef DL_IMPORT
-#define DL_IMPORT(RTYPE) RTYPE
 #include "gram.h"
-#include "parser.h"
 
+#if 0
+#include "ast.h"
+#define YYSTYPE Token
 #define TOKEN(t) get_token(); return t
+#else
+#define TOKEN(t) return t
+#endif
 
 void count();
 void comment();
@@ -165,13 +165,16 @@
 
 void get_token()
 {
+#if 0
     count();
     yylval = token(yytext, yylineno, column);
+#endif
 }
 
 int get_name_token()
 {
-    int is_type_name;
-    yylval = name_token(yytext, yylineno, column, &is_type_name);
-    return is_type_name ? TYPE_NAME : IDENTIFIER;
+    if (isupper(yytext[0])) {
+        return TYPE_NAME;
+    }
+    return IDENTIFIER;
 }



More information about the cig-commits mailing list