cvsuser 05/02/19 02:57:30
Modified: config/gen/makefiles m4.in
languages/m4 BUGS ChangeLog README VERSION
languages/m4/doc features.pod freezing.pod
languages/m4/examples eval.imc
languages/m4/src builtin.imc eval.c freeze.imc input.imc
m4.imc macro.imc output.imc
languages/m4/t/basic 003_getopt.t 012_eval.t
languages/m4/t/regex 002_tokens.t
src call_list.txt
t/pmc resizablepmcarray.t
Log:
This is an update of Parrot m4, that should make it work with the CVS HEAD
sources again. There are no new feature nor tests.
Changes:
- use Hash PMC instead of PerlHash PMC
- Added 'push_string' to ResizablePMCArray
- Use Integer PMC instead of PerlInt PMC
- The NCI function pcre_compile needs signature "ptip3P" instead of "ptiB3P"
- The Eval PMC generated in eval.c now returns with the "returncc" op
Revision Changes Path
1.9 +12 -17 parrot/config/gen/makefiles/m4.in
Index: m4.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/makefiles/m4.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- m4.in 8 Oct 2004 07:08:31 -0000 1.8
+++ m4.in 19 Feb 2005 10:57:22 -0000 1.9
@@no-spam -1,27 +1,22 @@no-spam
-# $Id: m4.in,v 1.8 2004/10/08 07:08:31 sfink Exp $
+# $Id: m4.in,v 1.9 2005/02/19 10:57:22 bernhard Exp $
# Setup of some commands
-LN_SF = ln -s -f
-PARROT = ..${slash}..${slash}parrot${exe}
-PERL = ${perl}
-RM_RF = ${rm_rf}
+LN_SF = ln -s -f
+PARROT = ..${slash}..${slash}parrot${exe}
+PERL = ${perl}
+RM_RF = ${rm_rf}
# Compile commands and flags
-CC = ${cc}
-CFLAGS = ${ccflags} -I../../include
-CC_SHARED = ${cc_shared} # e.g. -fpic
-DEBUG = ${cc_debug}
-WARN = ${ccwarn}
-
-# Linker command and flags
-LINK = ${link}
-LINKFLAGS = ${linkflags}
+CC = ${cc}
+CFLAGS = ${ccflags} -I../../include
+CC_SHARED = ${cc_shared} # e.g. -fpic
+DEBUG = ${cc_debug}
+WARN = ${ccwarn}
# Shared-library building
-LD = ${ld}
-LDFLAGS = ${ldflags}
+LD = ${ld}
+LDFLAGS = ${ldflags}
LD_SHARE_FLAGS = ${ld_share_flags} # e.g. -shared
-LD_LOAD_FLAGS = ${ld_load_flags}
# some constants
M4_EVAL_COMPILER_SO = ../../runtime/parrot/dynext/m4_eval_compiler.so
1.5 +2 -2 parrot/languages/m4/BUGS
Index: BUGS
===================================================================
RCS file: /cvs/public/parrot/languages/m4/BUGS,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BUGS 2 Nov 2004 09:16:05 -0000 1.4
+++ BUGS 19 Feb 2005 10:57:23 -0000 1.5
@@no-spam -1,8 +1,8 @@no-spam
-# $Id: BUGS,v 1.4 2004/11/02 09:16:05 leo Exp $
+# $Id: BUGS,v 1.5 2005/02/19 10:57:23 bernhard Exp $
Parrot m4 is in early stages of development, so most features
don't work yet.
Half of the tests will fail, if GNU m4 is not in $ENV{PATH} as 'm4'.
-See also the Parrot Request Tracker at http://bugs6.perl.org.
+See also the Parrot Issue Tracker at http://bugs6.perl.org.
1.9 +11 -1 parrot/languages/m4/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/public/parrot/languages/m4/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ChangeLog 17 Nov 2004 09:24:47 -0000 1.8
+++ ChangeLog 19 Feb 2005 10:57:23 -0000 1.9
@@no-spam -1,4 +1,14 @@no-spam
-# $Id: ChangeLog,v 1.8 2004/11/17 09:24:47 leo Exp $
+# $Id: ChangeLog,v 1.9 2005/02/19 10:57:23 bernhard Exp $
+
+2005-01-29 Bernhard Schmalhofer
+ * yank it up to revision 0.0.11
+ * Use Integer PMC instead of PerlInt PMC
+ * BUGFIX: Used incorrect signature for pcre_compile
+ * BUGFIX: Non-existing Hash keys no lnager return PerlUndef
+ * BUGFIX: Return with 'returncc' in Sub generated in eval.c
+
+2004-11-16 Bernhard Schmalhofer
+ * Use the Hash PMC insted of the PerlHash PMC
2004-11-16 Bernhard Schmalhofer
* yank it up to revision 0.0.10
1.4 +2 -2 parrot/languages/m4/README
Index: README
===================================================================
RCS file: /cvs/public/parrot/languages/m4/README,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- README 20 Apr 2004 08:36:26 -0000 1.3
+++ README 19 Feb 2005 10:57:23 -0000 1.4
@@no-spam -1,4 +1,4 @@no-spam
-# $Id: README,v 1.3 2004/04/20 08:36:26 leo Exp $
+# $Id: README,v 1.4 2005/02/19 10:57:23 bernhard Exp $
This is a Parrot m4, a Parrot port of GNU m4.
@@no-spam -16,7 +16,7 @@no-spam
AUTHOR:
-Bernhard Schmalhofer <Bernhard.Schmalhofer!no_spam!gmx.de>
+Bernhard Schmalhofer - <Bernhard.Schmalhofer@no-spam>
1.5 +2 -2 parrot/languages/m4/VERSION
Index: VERSION
===================================================================
RCS file: /cvs/public/parrot/languages/m4/VERSION,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- VERSION 2 Nov 2004 09:16:05 -0000 1.4
+++ VERSION 19 Feb 2005 10:57:23 -0000 1.5
@@no-spam -1,3 +1,3 @@no-spam
-# $Id: VERSION,v 1.4 2004/11/02 09:16:05 leo Exp $
+# $Id: VERSION,v 1.5 2005/02/19 10:57:23 bernhard Exp $
-0.0.9
+0.0.11
1.5 +3 -1 parrot/languages/m4/doc/features.pod
Index: features.pod
===================================================================
RCS file: /cvs/public/parrot/languages/m4/doc/features.pod,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- features.pod 2 Nov 2004 09:16:07 -0000 1.4
+++ features.pod 19 Feb 2005 10:57:24 -0000 1.5
@@no-spam -1,4 +1,4 @@no-spam
-# $Id: features.pod,v 1.4 2004/11/02 09:16:07 leo Exp $
+# $Id: features.pod,v 1.5 2005/02/19 10:57:24 bernhard Exp $
=head1 TITLE
@@no-spam -58,6 +58,8 @@no-spam
=head1 SEE ALSO
+TODO.pod
+
=head2 AUTHORS
=cut
1.3 +4 -4 parrot/languages/m4/doc/freezing.pod
Index: freezing.pod
===================================================================
RCS file: /cvs/public/parrot/languages/m4/doc/freezing.pod,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- freezing.pod 26 Jan 2004 10:14:19 -0000 1.2
+++ freezing.pod 19 Feb 2005 10:57:24 -0000 1.3
@@no-spam -1,12 +1,12 @@no-spam
-# $Id: freezing.pod,v 1.2 2004/01/26 10:14:19 leo Exp $
+# $Id: freezing.pod,v 1.3 2005/02/19 10:57:24 bernhard Exp $
-=head1 TITLE
+=head1 NAME
-Saving and restoring the state of Parrot m4
+freeing.pod - Saving and restoring the state of Parrot m4
=head1 Why?
-Performance
+Performance. Exchange with other m4 implementations.
=head1 How?
1.4 +19 -11 parrot/languages/m4/examples/eval.imc
Index: eval.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/examples/eval.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- eval.imc 23 Sep 2004 08:38:02 -0000 1.3
+++ eval.imc 19 Feb 2005 10:57:25 -0000 1.4
@@no-spam -1,6 +1,5 @@no-spam
-# $Id: eval.imc,v 1.3 2004/09/23 08:38:02 leo Exp $
+# $Id: eval.imc,v 1.4 2005/02/19 10:57:25 bernhard Exp $
-# See examples/compiler/Makefile for how to generate the needed shared lib
=head1 NAME
@@no-spam -9,32 +8,41 @@no-spam
=head1 DESCRIPTION
Just a sample.
+See languages/m4/Makefile on how to generate the needed shared lib.
=cut
-.sub _main
+.sub example @no-spam
- # load shared lib
- # There is a init-function in the shared lib,
- # which registers the new compiler
- print "Loading shared library, let the library register the compiler\n"
+ print "Trying to load shared library 'm4_eval_compiler'.\n"
+ print "Let the init function of the library register the compiler.\n"
.local pmc m4_eval_compiler_lib
m4_eval_compiler_lib = loadlib "m4_eval_compiler"
+ if m4_eval_compiler_lib goto GET_COMPILER
+ printerr "Could not load 'm4_eval_compiler'.\n"
+ end
- # get compiler
- print "Getting the compiler\n"
+GET_COMPILER:
+ print "Trying to get the registered compiler.\n"
.local pmc m4_eval_compiler
m4_eval_compiler = compreg "m4_eval_compiler"
+ if m4_eval_compiler goto COMPILE_CODE
+ printerr "Could not get the compiler.\n"
+ end
- # compile code and run it
+COMPILE_CODE:
.local string expression
expression = '1 + 1 * 117'
print "Evaluating expression: "
print expression
print "\n"
.local pmc compiled_code
- compiled_code = compile m4_eval_compiler, expression
+ compile compiled_code, m4_eval_compiler, expression
+ if compiled_code goto INVOKE_COMPILED_CODE
+ printerr "Could not get the compiler.\n"
+ end
+INVOKE_COMPILED_CODE:
print "Invoking compiled code, and receive returned expression\n"
.local int evaluated_expression
( evaluated_expression ) = compiled_code()
1.10 +91 -89 parrot/languages/m4/src/builtin.imc
Index: builtin.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/builtin.imc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- builtin.imc 16 Dec 2004 19:22:43 -0000 1.9
+++ builtin.imc 19 Feb 2005 10:57:26 -0000 1.10
@@no-spam -1,3 +1,5 @@no-spam
+# $Id: builtin.imc,v 1.10 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
builtin.imc - builtin and user defined macros
@@no-spam -5,7 +7,7 @@no-spam
=head2 DESCRIPTION
Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: builtin.imc,v 1.9 2004/12/16 19:22:43 chromatic Exp $
+CVS Info: $Id: builtin.imc,v 1.10 2005/02/19 10:57:26 bernhard Exp $
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
@@no-spam -15,18 +17,18 @@no-spam
=cut
# Some named constants
-.include '../../runtime/parrot/include/iterator.pasm'
+.include 'include/iterator.pasm'
=head1 SUBROUTINES
-=head2 void builtin_tab_init( PerlHash state )
+=head2 void builtin_tab_init( Hash state )
Initialise all builtin and predefined macros.
=cut
.sub builtin_tab_init
- .param PerlHash state
+ .param Hash state
.local pmc builtin_tab, builtin, func
@@no-spam -37,7 +39,7 @@no-spam
# name GNUext macros blind function */
# { "__file__", TRUE, FALSE, FALSE, m4___file__ },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = '__file__'
.const .Sub func_m4___file__ = "m4___file__"
builtin['func'] = func_m4___file__
@@no-spam -45,56 +47,56 @@no-spam
builtin_tab['__file__'] = builtin
# { "__line__", TRUE, FALSE, FALSE, m4___line__ },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = '__line__'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['__line__'] = builtin
# { "builtin", TRUE, FALSE, TRUE, m4_builtin },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'builtin'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['builtin'] = builtin
# { "changecom", FALSE, FALSE, FALSE, m4_changecom },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'changecom'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['changecom'] = builtin
# { "changequote", FALSE, FALSE, FALSE, m4_changequote },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'changequote'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['changequote'] = builtin
# { "changeword", TRUE, FALSE, FALSE, m4_changeword },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'changeword'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['changeword'] = builtin
# { "debugmode", TRUE, FALSE, FALSE, m4_debugmode },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'debugmode'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['debugmode'] = builtin
# { "debugfile", TRUE, FALSE, FALSE, m4_debugfile },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'debugfile'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['debugfile'] = builtin
# { "decr", FALSE, FALSE, TRUE, m4_decr },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'decr'
.const .Sub func_m4_decr = "m4_decr"
builtin['func'] = func_m4_decr
@@no-spam -102,7 +104,7 @@no-spam
builtin_tab['decr'] = builtin
# { "define", FALSE, TRUE, TRUE, m4_define },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'define'
.const .Sub func_m4_define = "m4_define"
builtin['func'] = func_m4_define
@@no-spam -110,42 +112,42 @@no-spam
builtin_tab['define'] = builtin
# { "defn", FALSE, FALSE, TRUE, m4_defn },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'defn'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['defn'] = builtin
# { "divert", FALSE, FALSE, FALSE, m4_divert },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'divert'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['divert'] = builtin
# { "divnum", FALSE, FALSE, FALSE, m4_divnum },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'divnum'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['divnum'] = builtin
# { "dnl", FALSE, FALSE, FALSE, m4_dnl },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'dnl'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['dnl'] = builtin
# { "dumpdef", FALSE, FALSE, FALSE, m4_dumpdef },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'dumpdef'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['dumpdef'] = builtin
# { "errprint", FALSE, FALSE, FALSE, m4_errprint },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'errprint'
.const .Sub func_m4_errprint = "m4_errprint"
builtin['func'] = func_m4_errprint
@@no-spam -153,14 +155,14 @@no-spam
builtin_tab['errprint'] = builtin
# { "esyscmd", TRUE, FALSE, TRUE, m4_esyscmd },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'esyscmd'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['esyscmd'] = builtin
# { "eval", FALSE, FALSE, TRUE, m4_eval },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'eval'
.const .Sub func_m4_eval = "m4_eval"
builtin['func'] = func_m4_eval
@@no-spam -168,7 +170,7 @@no-spam
builtin_tab['eval'] = builtin
# { "format", TRUE, FALSE, FALSE, m4_format },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'format'
.const .Sub func_m4_format = "m4_format"
builtin['func'] = func_m4_format
@@no-spam -176,7 +178,7 @@no-spam
builtin_tab['format'] = builtin
# { "ifdef", FALSE, FALSE, TRUE, m4_ifdef },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'ifdef'
.const .Sub func_m4_ifdef = "m4_ifdef"
builtin['func'] = func_m4_ifdef
@@no-spam -184,7 +186,7 @@no-spam
builtin_tab['ifdef'] = builtin
# { "ifelse", FALSE, FALSE, TRUE, m4_ifelse },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'ifelse'
.const .Sub func_m4_ifelse = "m4_ifelse"
builtin['func'] = func_m4_ifelse
@@no-spam -192,14 +194,14 @@no-spam
builtin_tab['ifelse'] = builtin
# { "include", FALSE, FALSE, TRUE, m4_include },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'include'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['include'] = builtin
# { "incr", FALSE, FALSE, TRUE, m4_incr },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'incr'
.const .Sub func_m4_incr = "m4_incr"
builtin['func'] = func_m4_incr
@@no-spam -207,7 +209,7 @@no-spam
builtin_tab['incr'] = builtin
# { "index", FALSE, FALSE, TRUE, m4_index },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'index'
.const .Sub func_m4_index = "m4_index"
builtin['func'] = func_m4_index
@@no-spam -215,14 +217,14 @@no-spam
builtin_tab['index'] = builtin
# { "indir", TRUE, FALSE, FALSE, m4_indir },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'indir'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['indir'] = builtin
# { "len", FALSE, FALSE, TRUE, m4_len },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'len'
.const .Sub func_m4_len = "m4_len"
builtin['func'] = func_m4_len
@@no-spam -230,70 +232,70 @@no-spam
builtin_tab['len'] = builtin
# { "m4exit", FALSE, FALSE, FALSE, m4_m4exit },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'm4exit'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['m4exit'] = builtin
# { "m4wrap", FALSE, FALSE, FALSE, m4_m4wrap },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'm4wrap'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['m4wrap'] = builtin
# { "maketemp", FALSE, FALSE, TRUE, m4_maketemp },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'maketemp'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['maketemp'] = builtin
# { "patsubst", TRUE, FALSE, TRUE, m4_patsubst },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'patsubst'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['patsubst'] = builtin
# { "popdef", FALSE, FALSE, TRUE, m4_popdef },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'popdef'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['popdef'] = builtin
# { "pushdef", FALSE, TRUE, TRUE, m4_pushdef },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'pushdef'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['pushdef'] = builtin
# { "regexp", TRUE, FALSE, TRUE, m4_regexp },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'regexp'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['regexp'] = builtin
# { "shift", FALSE, FALSE, FALSE, m4_shift },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'shift'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['shift'] = builtin
# { "sinclude", FALSE, FALSE, TRUE, m4_sinclude },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'sinclude'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['sinclude'] = builtin
# { "substr", FALSE, FALSE, TRUE, m4_substr },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'substr'
.const .Sub func_m4_substr = "m4_substr"
builtin['func'] = func_m4_substr
@@no-spam -301,7 +303,7 @@no-spam
builtin_tab['substr'] = builtin
# { "syscmd", FALSE, FALSE, TRUE, m4_syscmd },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'syscmd'
.const .Sub func_m4_syscmd = "m4_syscmd"
builtin['func'] = func_m4_syscmd
@@no-spam -309,7 +311,7 @@no-spam
builtin_tab['syscmd'] = builtin
# { "sysval", FALSE, FALSE, FALSE, m4_sysval },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'sysval'
.const .Sub func_m4_sysval = "m4_sysval"
builtin['func'] = func_m4_sysval
@@no-spam -317,28 +319,28 @@no-spam
builtin_tab['sysval'] = builtin
# { "traceoff", FALSE, FALSE, FALSE, m4_traceoff },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'traceoff'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['traceoff'] = builtin
# { "traceon", FALSE, FALSE, FALSE, m4_traceon },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'traceon'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
builtin_tab['traceon'] = builtin
# { "translit", FALSE, FALSE, TRUE, m4_translit },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'translit'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 1
builtin_tab['translit'] = builtin
# { "undefine", FALSE, FALSE, TRUE, m4_undefine },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'undefine'
.const .Sub func_m4_undefine = "m4_undefine"
builtin['func'] = func_m4_undefine
@@no-spam -346,7 +348,7 @@no-spam
builtin_tab['undefine'] = builtin
# { "undivert", FALSE, FALSE, FALSE, m4_undivert },
- builtin = new PerlHash
+ builtin = new Hash
builtin['name'] = 'undivert'
builtin['func'] = func_m4_not_implemented
builtin['blind_no_args'] = 0
@@no-spam -355,14 +357,14 @@no-spam
.end
-=head2 void builtin_init( PerlHash state )
+=head2 void builtin_init( Hash state )
Initialise all builtin and predefined macros.
=cut
.sub builtin_init
- .param PerlHash state
+ .param Hash state
.local pmc iterator, builtin, builtin_tab
.local string name
@@no-spam -385,23 +387,23 @@no-spam
.end
-=head2 void define_builtin( PerlHash state, string name, string bp )
+=head2 void define_builtin( Hash state, string name, string bp )
Install a builtin macro with name 'name', bound to the function 'bp'.
=cut
.sub define_builtin
- .param PerlHash state
+ .param Hash state
.param string name
- .param PerlHash builtin
+ .param Hash builtin
.local pmc symtab
symtab = state['symtab']
# Now store the passed symbol
.local pmc symbol
- symbol = new PerlHash
+ symbol = new Hash
symbol['name'] = name
symbol['type'] = 'TOKEN_FUNC'
@@no-spam -421,7 +423,7 @@no-spam
.end
-=head2 void define_user_macro( PerlHash state, string name, string text )
+=head2 void define_user_macro( Hash state, string name, string text )
Define a predefined or user-defined macro, with name 'name', and expansion 'text'.
This function is also called from main().
@@no-spam -429,7 +431,7 @@no-spam
=cut
.sub define_user_macro
- .param PerlHash state
+ .param Hash state
.param string name
.param string text
@@no-spam -438,7 +440,7 @@no-spam
# Now store the passed symbol
.local pmc symbol
- symbol = new PerlHash
+ symbol = new Hash
symbol['name'] = name
symbol['text'] = text
symbol['type'] = 'TOKEN_TEXT'
@@no-spam -457,7 +459,7 @@no-spam
=cut
.sub define_macro
- .param PerlHash state
+ .param Hash state
.param string name
.param string text
@@no-spam -475,7 +477,7 @@no-spam
=cut
.sub m4___file__
- .param PerlHash state
+ .param Hash state
.local string current_file
current_file = state['current_file']
@@no-spam -491,8 +493,8 @@no-spam
=cut
.sub m4_decr
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local int arg0
arg0 = arguments[0]
@@no-spam -514,8 +516,8 @@no-spam
=cut
.sub m4_define
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
# right now we handle only TOKEN_TEXT
@@no-spam -537,8 +539,8 @@no-spam
=cut
.sub m4_errprint
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
# right now we handle only TOKEN_TEXT
@@no-spam -571,8 +573,8 @@no-spam
=cut
.sub m4_eval
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
# get compiler
.local pmc m4_eval_compiler
@@no-spam -599,8 +601,8 @@no-spam
=cut
.sub m4_format
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0
arg0 = shift arguments
@@no-spam -619,8 +621,8 @@no-spam
=cut
.sub m4_ifdef
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0
arg0 = arguments[0]
@@no-spam -651,8 +653,8 @@no-spam
=cut
.sub m4_ifelse
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string ret
ret = ''
@@no-spam -687,8 +689,8 @@no-spam
=cut
.sub m4_incr
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local int arg0
arg0 = arguments[0]
@@no-spam -709,8 +711,8 @@no-spam
=cut
.sub m4_index
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0, arg1
arg0 = arguments[0]
@@no-spam -734,8 +736,8 @@no-spam
=cut
.sub m4_len
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0
arg0 = arguments[0]
@@no-spam -761,8 +763,8 @@no-spam
.sub m4_substr
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string ret
@@no-spam -798,8 +800,8 @@no-spam
=cut
.sub m4_syscmd
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0
arg0 = arguments[0]
@@no-spam -812,7 +814,7 @@no-spam
# Store it as a global for m4_sysval
.local pmc exit_status_as_pmc
- exit_status_as_pmc = new PerlInt
+ exit_status_as_pmc = new Integer
exit_status_as_pmc = exit_status
store_global 'exit_status', exit_status_as_pmc
@@no-spam -827,8 +829,8 @@no-spam
=cut
.sub m4_sysval
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
# Retrieve it as a global set by m4_sysval
.local pmc exit_status_as_pmc
@@no-spam -848,8 +850,8 @@no-spam
=cut
.sub m4_undefine
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.local string arg0
arg0 = arguments[0]
@@no-spam -870,8 +872,8 @@no-spam
=cut
.sub m4_not_implemented
- .param PerlHash state
- .param PerlArray arguments
+ .param Hash state
+ .param pmc arguments
.return ( 'not implemented yet' )
.end
1.9 +20 -20 parrot/languages/m4/src/eval.c
Index: eval.c
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/eval.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- eval.c 23 Nov 2004 08:32:05 -0000 1.8
+++ eval.c 19 Feb 2005 10:57:26 -0000 1.9
@@no-spam -1,4 +1,4 @@no-spam
-/* $Id: eval.c,v 1.8 2004/11/23 08:32:05 leo Exp $ */
+/* $Id: eval.c,v 1.9 2005/02/19 10:57:26 bernhard Exp $ */
/* GNU m4 -- A simple macro processor
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
@@no-spam -84,7 +84,7 @@no-spam
static eval_error unary_term( eval_token, eval_t * );
static eval_error simple_term( eval_token, eval_t * );
boolean evaluate (const char *, eval_t *);
-PMC * m4_eval_compiler(Parrot_Interp interpreter, const char *);
+PMC * m4_eval_compiler(Parrot_Interp, const char *);
void Parrot_lib_m4_eval_compiler_init(Parrot_Interp , PMC* );
/*--------------------.
@@no-spam -792,9 +792,9 @@no-spam
*/
void
-Parrot_lib_m4_eval_compiler_init(Parrot_Interp interpreter, PMC* lib)
+Parrot_lib_m4_eval_compiler_init(Parrot_Interp interp, PMC* lib)
{
- Parrot_compreg(interpreter, const_string(interpreter, "m4_eval_compiler"), m4_eval_compiler);
+ Parrot_compreg(interp, const_string(interp, "m4_eval_compiler"), m4_eval_compiler);
}
@@no-spam -826,7 +826,7 @@no-spam
* simple compiler - no error checking
*/
PMC *
-m4_eval_compiler( Parrot_Interp interpreter, const char *program )
+m4_eval_compiler( Parrot_Interp interp, const char *program )
{
eval_t value; /* will be returned to caller */
@@no-spam -844,8 +844,8 @@no-spam
/*
* need a packfile segment
*/
- cur_cs = (struct PackFile_ByteCode*)PackFile_Segment_new_seg(&interpreter->code->directory, PF_BYTEC_SEG, "m4_eval_bc", 1);
- old_cs = Parrot_switch_to_cs(interpreter, cur_cs, 0);
+ cur_cs = (struct PackFile_ByteCode*)PackFile_Segment_new_seg(&interp->code->directory, PF_BYTEC_SEG, "m4_eval_bc", 1);
+ old_cs = Parrot_switch_to_cs(interp, cur_cs, 0);
/*
* alloc byte code mem
*/
@@no-spam -856,46 +856,46 @@no-spam
* Generate some bytecode
*/
pc = cur_cs->base.data;
- /* first integer return value */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ /* set the single integer return value */
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 5;
*pc++ = value;
/* promise to fill in the counters */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 0;
*pc++ = 1;
/* one integer return value */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 1;
*pc++ = 1;
/* no string return values */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 2;
*pc++ = 0;
/* no PMC return values */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 3;
*pc++ = 0;
/* no numeric return values */
- *pc++ = interpreter->op_lib->op_code("set_i_ic", 1);
+ *pc++ = interp->op_lib->op_code("set_i_ic", 1);
*pc++ = 4;
*pc++ = 0;
- /* do something else now */
- *pc++ = interpreter->op_lib->op_code("invoke_p", 1);
- *pc++ = 1;
+ /* invoke the return continuation */
+ *pc++ = interp->op_lib->op_code("returncc", 1);
if (old_cs) {
/* restore old byte_code, */
- (void)Parrot_switch_to_cs(interpreter, old_cs, 0);
+ (void)Parrot_switch_to_cs(interp, old_cs, 0);
}
/*
* create sub PMC
*/
- sub = pmc_new(interpreter, enum_class_Eval);
+ sub = pmc_new(interp, enum_class_Eval);
sub_data = PMC_sub(sub);
sub_data->seg = cur_cs;
sub_data->address = cur_cs->base.data;
sub_data->end = cur_cs->base.data + cur_cs->base.size;
- sub_data->name = string_from_cstring(interpreter, "m4 eval", 0);
+ sub_data->name = string_from_cstring(interp, "m4 eval", 0);
+
return sub;
}
1.6 +8 -6 parrot/languages/m4/src/freeze.imc
Index: freeze.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/freeze.imc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- freeze.imc 2 Nov 2004 09:16:09 -0000 1.5
+++ freeze.imc 19 Feb 2005 10:57:26 -0000 1.6
@@no-spam -1,3 +1,5 @@no-spam
+# $Id: freeze.imc,v 1.6 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
freeze.imc - reading and writing of state files
@@no-spam -5,7 +7,7 @@no-spam
=head1 DESCRIPTION
Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: freeze.imc,v 1.5 2004/11/02 09:16:09 leo Exp $
+CVS Info: $Id: freeze.imc,v 1.6 2005/02/19 10:57:26 bernhard Exp $
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
@@no-spam -19,20 +21,20 @@no-spam
=head1 SUBROUTINES
-=head2 void produce_frozen_state( PerlHash state, string frozen_file )
+=head2 void produce_frozen_state( Hash state, string frozen_file )
Dump a state file.
=cut
.sub produce_frozen_state
- .param PerlHash state
+ .param Hash state
.param string frozen_file
.local pmc symtab
symtab = state['symtab']
- .local PerlHash symbol
+ .local Hash symbol
.local int len
.local string name
.local string text
@@no-spam -64,7 +66,7 @@no-spam
.end
-=head2 void reload_frozen_state( PerlHash state, string frozen_file )
+=head2 void reload_frozen_state( Hash state, string frozen_file )
Read a frozen file
@@no-spam -77,7 +79,7 @@no-spam
=cut
.sub reload_frozen_state
- .param PerlHash state
+ .param Hash state
.param string frozen_file
# Read the file into the string file
1.9 +25 -15 parrot/languages/m4/src/input.imc
Index: input.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/input.imc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- input.imc 17 Nov 2004 09:24:48 -0000 1.8
+++ input.imc 19 Feb 2005 10:57:26 -0000 1.9
@@no-spam -1,3 +1,5 @@no-spam
+# $Id: input.imc,v 1.9 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
input.imc - Setting up input and reading input
@@no-spam -5,13 +7,13 @@no-spam
=head1 DESCRIPTION
Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: input.imc,v 1.8 2004/11/17 09:24:48 leo Exp $
+CVS Info: $Id: input.imc,v 1.9 2005/02/19 10:57:26 bernhard Exp $
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
=head1 SUBROUTINES
-=head2 void input_init( PerlHash state )
+=head2 void input_init( Hash state )
Initialise the input stack and various regexes.
@@no-spam -25,26 +27,26 @@no-spam
=cut
+.include "datatypes.pasm"
+
.sub input_init
- .param PerlHash state
+ .param Hash state
.local pmc empty_array
# setup of stacks
- empty_array = new PerlArray
+ empty_array = new ResizablePMCArray
state['token_stack'] = empty_array
empty_array = new PerlArray
state['input_stack'] = empty_array
- empty_array = new PerlArray
+ empty_array = new ResizablePMCArray
state['wrapup_stack'] = empty_array
# setup of regexes
# regular expressions are needed for finding words and quoted strings
.local pmc regex
- .local string err
- err = repeat ' ', 500
.local pmc erroffset
- erroffset = new PerlInt
+ erroffset = new Integer
erroffset = 0
.local pmc NULL
NULL = null
@@no-spam -52,11 +54,20 @@no-spam
.local pmc pcre_lib
pcre_lib = loadlib "libpcre"
+ .local pmc err_decl
+ .local pmc err
+ err_decl = new ResizablePMCArray
+ push err_decl, .DATATYPE_CSTR
+ push err_decl, 0
+ push err_decl, 0
+ err = new .ManagedStruct
+ assign err, err_decl
+
# pcre *pcre_compile( const char *pattern, int options,
# const char **errptr, int *erroffset,
# const unsigned char *tableptr
.local pmc pcre_compile
- pcre_compile = dlfunc pcre_lib, "pcre_compile", "ptiB3P"
+ pcre_compile = dlfunc pcre_lib, "pcre_compile", "ptip3P"
#int pcre_exec( const pcre *code, const pcre_extra *extra,
# const char *subject, int length, int startoffset,
@@no-spam -84,7 +95,7 @@no-spam
.end
-=head2 void push_file( PerlHash state, string filename )
+=head2 void push_file( Hash state, string filename )
Stores a filename on a stack
TODO: open these files and complain when they don't or pass filehandles
@@no-spam -92,7 +103,7 @@no-spam
=cut
.sub push_file
- .param PerlHash state
+ .param Hash state
.param string filename
# This is needed for m4___file__
@@no-spam -118,7 +129,7 @@no-spam
.local int stack_size
stack_size = input_stack
if stack_size > 0 goto NOT_FIRST_FILE
- input_block = new PerlHash
+ input_block = new Hash
input_block['type'] = 'INPUT_STRING'
input_block['string'] = input_string
push input_stack, input_block
@@no-spam -134,7 +145,7 @@no-spam
.end
-=head2 string next_token( PerlHash state )
+=head2 string next_token( Hash state )
Parse and return a single token from the input stream. A token can
either be TOKEN_EOF, if the input_stack is empty; it can be TOKEN_STRING
@@no-spam -149,7 +160,7 @@no-spam
=cut
.sub next_token
- .param PerlHash state
+ .param Hash state
.local pmc input_stack
input_stack = state['input_stack']
@@no-spam -218,7 +229,6 @@no-spam
.local pmc struct
struct = new SArray
struct = 3
- .include "../../runtime/parrot/include/datatypes.pasm"
struct[0] = .DATATYPE_INT
struct[1] = 2
struct[2] = 0
1.13 +53 -40 parrot/languages/m4/src/m4.imc
Index: m4.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/m4.imc,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- m4.imc 16 Dec 2004 19:22:43 -0000 1.12
+++ m4.imc 19 Feb 2005 10:57:26 -0000 1.13
@@no-spam -1,15 +1,46 @@no-spam
+# $Id: m4.imc,v 1.13 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
m4.imc - An implementation of GNU m4 in Parrot Immediate Representation
=head1 DESCRIPTION
-Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: m4.imc,v 1.12 2004/12/16 19:22:43 chromatic Exp $
+Copyright: 2004-2005 Bernhard Schmalhofer. All Rights Reserved.
+CVS Info: $Id: m4.imc,v 1.13 2005/02/19 10:57:26 bernhard Exp $
Overview: Main of Parrot m4.
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
+=cut
+
+# The needed subroutines are imported from files in 'src'
+# TODO: private namespaces for local subroutines in the included files
+#
+# The names of these source files should be consistent with 'GNU m4'.
+
+# subs for reading in input
+.include "src/input.imc"
+
+# subs for writing output
+.include "src/output.imc"
+
+# This contains the initialization and execution of the builtin macros.
+.include "src/builtin.imc"
+
+# A dummy implementation of Getopt::Long
+.include "library/Getopt/Long.imc"
+
+# This contains reading and writing of frozen files
+.include "src/freeze.imc"
+
+# Macros are expanded in there.
+.include "src/macro.imc"
+
+# Mainly for debug output
+# .include "library/dumper.imc"
+
+
=head1 SUBROUTINES
=head2 m4
@@no-spam -29,7 +60,7 @@no-spam
# The args are parsed with library/Getopt/Long.imc which should work
# somewhat like the Perl5 module Getopt::Long.
.local pmc opt_spec
- opt_spec = new PerlArray
+ opt_spec = new ResizableStringArray
# --version, boolean
push opt_spec, "version"
# --help, boolean
@@no-spam -87,7 +118,7 @@no-spam
# Was '--version' passed ?
is_defined = defined opt["version"]
unless is_defined goto NO_VERSION_FLAG
- print "Parrot m4 0.0.10\n"
+ print "Parrot m4 0.0.11\n"
end
NO_VERSION_FLAG:
@@no-spam -101,7 +132,7 @@no-spam
# TODO: In near future we propably should use objects here
# For now let's just just use a hash with all state information
.local pmc state
- state = new PerlHash
+ state = new Hash
# Artificial limit for macro expansion in macro.imc
# default setting of 'nesting_limit' max be overridden by
@@no-spam -127,7 +158,7 @@no-spam
NO_PREFIX_BUILTINS_FLAG:
# Was a yet unimplemented option passed?
- # TODO: put names of unimplemented options in an PerlArray
+ # TODO: put names of unimplemented options in an ResizableStringArray
.local string unimplemented_option
unimplemented_option = "traditional"
@@no-spam -215,7 +246,7 @@no-spam
# First we set up a table of all symbols, that is macros
.local pmc symtab
- #symtab = new PerlHash
+ #symtab = new Hash
symtab = new OrderedHash
state['symtab'] = symtab
@@no-spam -243,17 +274,21 @@no-spam
.local pmc builtin_tab
builtin_tab = new OrderedHash
state['builtin_tab'] = builtin_tab
+
builtin_tab_init( state )
- # Check whether the option --reload-state was passed
+ # Was '--reload-state' passed ?
+ is_defined = defined opt['reload-state']
+ unless is_defined goto NO_RELOAD_STATE_FLAG
+
.local string frozen_file
frozen_file = opt['reload-state']
.local int string_len
string_len = length frozen_file
- unless string_len > 0 goto BUILTIN_MACROS_INIT
+ unless string_len > 0 goto NO_RELOAD_STATE_FLAG
reload_frozen_state( state, frozen_file )
goto COMMANDLINE_MACROS_INIT
-BUILTIN_MACROS_INIT:
+NO_RELOAD_STATE_FLAG:
builtin_init( state )
COMMANDLINE_MACROS_INIT:
@@no-spam -281,18 +316,22 @@no-spam
HANDLE_WRAPUP_TEXT:
# TODO: handle wrapup text, whatever that is
-CHECK_FROZEN_FLAG:
+ # Was '--freeze-state' passed ?
+ is_defined = defined opt['freeze-state']
+ unless is_defined goto NO_FREEZE_STATE_FLAG
+
.local string freeze_file
freeze_file = opt["freeze-state"]
string_len = length freeze_file
- unless string_len > 0 goto MAKE_DIVERSION
+ unless string_len > 0 goto NO_FREEZE_STATE_FLAG
produce_frozen_state( state, freeze_file )
goto FINISH_PROGRAM
-MAKE_DIVERSION:
+
+NO_FREEZE_STATE_FLAG:
# TODO: make_diversion, undiver_all, whatever that does
FINISH_PROGRAM:
- end
+
.end
@@no-spam -327,29 +366,3 @@no-spam
.end
-
-# The needed subroutines are imported from files in 'src'
-# TODO: private namespaces for local subroutines in the included files
-#
-# The names of these source files should be consistent with 'GNU m4'.
-
-# subs for reading in input
-.include "src/input.imc"
-
-# subs for writing output
-.include "src/output.imc"
-
-# This contains the initialization and execution of the builtin macros.
-.include "src/builtin.imc"
-
-# A dummy implementation of Getopt::Long
-.include "library/Getopt/Long.imc"
-
-# This contains reading and writing of frozen files
-.include "src/freeze.imc"
-
-# Macros are expanded in there.
-.include "src/macro.imc"
-
-# Mainly for debug output
-.include "library/dumper.imc"
1.7 +21 -21 parrot/languages/m4/src/macro.imc
Index: macro.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/macro.imc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- macro.imc 17 Nov 2004 09:24:48 -0000 1.6
+++ macro.imc 19 Feb 2005 10:57:26 -0000 1.7
@@no-spam -1,3 +1,5 @@no-spam
+# $Id: macro.imc,v 1.7 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
src/macro.imc - does macro substitution
@@no-spam -5,13 +7,13 @@no-spam
=head1 DESCRIPTION
Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: macro.imc,v 1.6 2004/11/17 09:24:48 leo Exp $
+CVS Info: $Id: macro.imc,v 1.7 2005/02/19 10:57:26 bernhard Exp $
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
=head1 SUBROUTINES
-=head2 void expand_input( PerlHash state )
+=head2 void expand_input( Hash state )
Loop through some input files.
TODO: read files in next_token()
@@no-spam -19,7 +21,7 @@no-spam
=cut
.sub expand_input
- .param PerlHash state
+ .param Hash state
.local string token_data, token_type # current token data and type
@@no-spam -33,7 +35,7 @@no-spam
.end
-=head2 void expand_token( PerlHash state, string token_type, string token_data )
+=head2 void expand_token( Hash state, string token_type, string token_data )
Expand one token, according to its type. Potential macro names
(TOKEN_WORD) are looked up in the symbol table, to see if they have a
@@no-spam -43,7 +45,7 @@no-spam
=cut
.sub expand_token
- .param PerlHash state
+ .param Hash state
.param string token_type
.param string token_data
@@no-spam -73,10 +75,6 @@no-spam
# Most macros needs a parameter list, but e.g. __file__ has not args
.local int blind_no_args
blind_no_args = symbol['blind_no_args']
- #print token_data
- #print symbol_type
- #print blind_no_args
- #print "\n"
unless blind_no_args goto EXPAND_MACRO
.local string input_string
input_string = state['input_stack';0;'string']
@@no-spam -103,21 +101,22 @@no-spam
.end
-=head2 string processed_token expand_macro( PerlHash state, PerlHash symbol )
+=head2 string processed_token expand_macro( Hash state, Hash symbol )
-The macro expansion is handled by expand_macro(). It parses the
-arguments, using collect_arguments(), and builds a PerlArray containing
-the arguments. The arguments themselves are stored on a local obstack.
-Expand_macro() uses call_macro() to do the call of the macro.
+The macro expansion is handled by expand_macro().
+It parses the arguments in collect_arguments() and
+builds a PerlArray containing the arguments.
+The arguments themselves are stored on a local obstack.
+expand_macro() uses call_macro() to do the call of the macro.
-Expand_macro() is potentially recursive, since it calls expand_argument(),
+expand_macro() is potentially recursive, since it calls expand_argument(),
which might call expand_token (), which might call expand_macro().
=cut
.sub expand_macro
- .param PerlHash state
- .param PerlHash symbol
+ .param Hash state
+ .param Hash symbol
.local int expansion_level
expansion_level = state['expansion_level']
@@no-spam -159,9 +158,9 @@no-spam
=cut
.sub call_macro
- .param PerlHash state
+ .param Hash state
.param pmc symbol
- .param PerlArray arguments
+ .param pmc arguments
.local string symbol_type, symbol_name
symbol_type = symbol['type']
@@no-spam -199,8 +198,8 @@no-spam
=cut
.sub collect_arguments
- .param PerlHash state
- .param PerlArray arguments
+ .param pmc state
+ .param pmc arguments
# The macro name has already been read in, thus we need to match
# something like "('furcht', 'Hallo Welt')"
@@no-spam -225,6 +224,7 @@no-spam
EXPAND_ARG:
# find a string before ')'
index_closing = index input_string, ')', start_index
+
if index_closing == -1 goto NO_MORE_ARGS
if num_args == 0 goto SKIP_SKIP_COMMA
index_comma = index input_string, ',', start_index
1.5 +5 -3 parrot/languages/m4/src/output.imc
Index: output.imc
===================================================================
RCS file: /cvs/public/parrot/languages/m4/src/output.imc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- output.imc 2 Nov 2004 09:16:09 -0000 1.4
+++ output.imc 19 Feb 2005 10:57:26 -0000 1.5
@@no-spam -1,3 +1,5 @@no-spam
+# $Id: output.imc,v 1.5 2005/02/19 10:57:26 bernhard Exp $
+
=head1 NAME
output.imc - handle output for Parrot m4
@@no-spam -5,14 +7,14 @@no-spam
=head1 DESCRIPTION
Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved.
-CVS Info: $Id: output.imc,v 1.4 2004/11/02 09:16:09 leo Exp $
+CVS Info: $Id: output.imc,v 1.5 2005/02/19 10:57:26 bernhard Exp $
Overview: output
History: Ported from GNU m4 1.4
References: http://www.gnu.org/software/m4/m4.html
=head1 SUBROUTINES
-=head2 void shipout_text( PerlHash state )
+=head2 void shipout_text( Hash state )
Does only a simple print rightnow.
@@no-spam -21,7 +23,7 @@no-spam
=cut
.sub shipout_text
- .param PerlHash state
+ .param Hash state
.param string text
print text
1.10 +2 -2 parrot/languages/m4/t/basic/003_getopt.t
Index: 003_getopt.t
===================================================================
RCS file: /cvs/public/parrot/languages/m4/t/basic/003_getopt.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- 003_getopt.t 17 Nov 2004 09:24:49 -0000 1.9
+++ 003_getopt.t 19 Feb 2005 10:57:27 -0000 1.10
@@no-spam -1,4 +1,4 @@no-spam
-# $Id: 003_getopt.t,v 1.9 2004/11/17 09:24:49 leo Exp $
+# $Id: 003_getopt.t,v 1.10 2005/02/19 10:57:27 bernhard Exp $
# pragmata
use strict;
@@no-spam -32,7 +32,7 @@no-spam
#--------------------------------------------
$real_out = `$parrot_m4 --version 2>&1`;
is( $real_out, << 'END_OUT', '--version' );
-Parrot m4 0.0.10
+Parrot m4 0.0.11
END_OUT
1.5 +4 -3 parrot/languages/m4/t/basic/012_eval.t
Index: 012_eval.t
===================================================================
RCS file: /cvs/public/parrot/languages/m4/t/basic/012_eval.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- 012_eval.t 23 Sep 2004 08:38:04 -0000 1.4
+++ 012_eval.t 19 Feb 2005 10:57:27 -0000 1.5
@@no-spam -1,4 +1,4 @@no-spam
-# $Id: 012_eval.t,v 1.4 2004/09/23 08:38:04 leo Exp $
+# $Id: 012_eval.t,v 1.5 2005/02/19 10:57:27 bernhard Exp $
use strict;
@@no-spam -9,8 +9,9 @@no-spam
$real_out = `$parrot languages/m4/examples/eval.imc 2>&1`;
is( $real_out, << 'END_OUT', 'single expression' );
-Loading shared library, let the library register the compiler
-Getting the compiler
+Trying to load shared library 'm4_eval_compiler'.
+Let the init function of the library register the compiler.
+Trying to get the registered compiler.
Evaluating expression: 1 + 1 * 117
Invoking compiled code, and receive returned expression
evaluated: 118
1.4 +112 -7 parrot/languages/m4/t/regex/002_tokens.t
Index: 002_tokens.t
===================================================================
RCS file: /cvs/public/parrot/languages/m4/t/regex/002_tokens.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 002_tokens.t 3 Jun 2004 07:35:34 -0000 1.3
+++ 002_tokens.t 19 Feb 2005 10:57:28 -0000 1.4
@@no-spam -1,11 +1,12 @@no-spam
-# $Id: 002_tokens.t,v 1.3 2004/06/03 07:35:34 leo Exp $
+# $Id: 002_tokens.t,v 1.4 2005/02/19 10:57:28 bernhard Exp $
use strict;
use Parrot::Test tests => 5;
+use Parrot::Test::PGE;
# Assemble PIR for simple pattern matching
-sub get_pir
+sub get_pir_pcre
{
my ( $string, $token ) = @no-spam
@@no-spam -61,9 +62,103 @@no-spam
}
}
+# Assemble PIR for simple pattern matching
+sub get_pir_pge
+{
+ my ( $string, $token ) = @no-spam
+
+ my %regex = ( word => q{^(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z)(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|0|1|2|3|4|5|6|7|8|9)*},
+ quoted_string => q{^`[^`]*'},
+ simple => q{^[^`#_a-zA-Z]},
+ comment => q{^#[^\n]*\n},
+ );
+ return << "END_PIR";
+.sub pge
+ .param string target
+ .param string pattern
+
+ print "pattern: "
+ print pattern
+ print "\\n"
+ print "target: "
+ print target
+ print "\\n"
+
+ .local pmc pge_compile
+ find_global pge_compile, "PGE", "_pge_compile" # get the compiler
+
+ .local pmc rulesub
+ rulesub = pge_compile(pattern) # compile it to rulesub
+
+ .local pmc match
+ match = rulesub(target) # execute rule on target string
+
+match_loop:
+ unless match goto match_fail # if match fails stop
+ print "match succeeded\\n"
+
+ match."_print"() # display captures
+
+ match."_next"() # find the next match
+ goto match_loop
+
+match_fail:
+ print "match failed\\n"
+ .return()
+.end
+.include "library/pcre.imc"
+.sub _main \@no-spam
+ load_bytecode "pge.pir"
+ pge( "$string", "$regex{$token}" )
+ print "\\n"
+ .local pmc lib
+ .PCRE_INIT(lib)
+ .local string error
+ .local int errptr
+ .local pmc code
+ .local string pat
+ pat = "$regex{$token}"
+ .PCRE_COMPILE(pat, 0, code, error, errptr)
+ \$I0 = defined code
+ unless \$I0 goto match_err
+
+ .local int ok
+ .local pmc result
+ .local string s
+ s = "$string"
+ .PCRE_MATCH(code, s, 0, 0, ok, result)
+ if ok < 0 goto nomatch
+ print ok
+ print " match(es):\\n"
+ .local int i
+ i = 0
+ .local string match
+ .local string s
+lp: .PCRE_DOLLAR(s, ok, result, i, match)
+ print match
+ print "\\n"
+ inc i
+ if i < ok goto lp
+ end
+nomatch:
+ print "no match\\n"
+ end
+match_err:
+ print "error in regex: "
+ print "at: '"
+ length \$I0, pat
+ \$I0 = \$I0 - errptr
+ substr \$S0, pat, errptr, \$I0
+ print \$S0
+ print "'\\n"
+ exit 1
+.end
+END_PIR
+}
+
{
- my $code = get_pir( 'foo', 'name' );
+ my $code = get_pir_pcre( 'foo', 'name' );
pir_output_is( $code, << 'OUTPUT', "'foo' is a name" );
1 match(es):
@@no-spam -71,7 +166,7 @@no-spam
OUTPUT
}
{
- my $code = get_pir( '_tmp', 'name' );
+ my $code = get_pir_pcre( '_tmp', 'name' );
pir_output_is( $code, << 'OUTPUT', "'_tmp' is a name" );
1 match(es):
@@no-spam -79,7 +174,7 @@no-spam
OUTPUT
}
{
- my $code = get_pir( 'name2', 'name' );
+ my $code = get_pir_pcre( 'name2', 'name' );
pir_output_is( $code, << 'OUTPUT', "'name2' is a name" );
1 match(es):
@@no-spam -87,7 +182,7 @@no-spam
OUTPUT
}
{
- my $code = get_pir( "`quoted'", 'quoted' );
+ my $code = get_pir_pcre( "`quoted'", 'quoted' );
pir_output_is( $code, << 'OUTPUT', "'`quoted'' is a quoted string" );
1 match(es):
@@no-spam -95,10 +190,20 @@no-spam
OUTPUT
}
{
- my $code = get_pir( "`'", 'quoted' );
+ my $code = get_pir_pcre( "`'", 'quoted' );
pir_output_is( $code, << 'OUTPUT', "'`'' is a quoted string" );
1 match(es):
`'
OUTPUT
}
+
+# TODO: Test wether non-quoted are not recognised
+
+# TODO: Test wether comments are recognised
+
+# TODO: Test wether non-comments are not recognised
+
+# TODO: Test wether simple tokens are recognised
+
+# TODO: Test wether non-simple tokens are not recognised
1.56 +2 -1 parrot/src/call_list.txt
Index: call_list.txt
===================================================================
RCS file: /cvs/public/parrot/src/call_list.txt,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- call_list.txt 27 Jan 2005 07:59:59 -0000 1.55
+++ call_list.txt 19 Feb 2005 10:57:29 -0000 1.56
@@no-spam -1,5 +1,5 @@no-spam
# Copyright: 2002-2005 The Perl Foundation. All Rights Reserved.
-# $Id: call_list.txt,v 1.55 2005/01/27 07:59:59 leo Exp $
+# $Id: call_list.txt,v 1.56 2005/02/19 10:57:29 bernhard Exp $
# Function signature declarations for NCI
@@no-spam -247,6 +247,7 @@no-spam
# The following are used by library/pcre.imc
p tiB3P
+p tip3P
i pPtiiipi
i tpiibi
1.10 +28 -2 parrot/t/pmc/resizablepmcarray.t
Index: resizablepmcarray.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/resizablepmcarray.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- resizablepmcarray.t 27 Jan 2005 08:00:00 -0000 1.9
+++ resizablepmcarray.t 19 Feb 2005 10:57:30 -0000 1.10
@@no-spam -1,7 +1,7 @@no-spam
#! perl -w
# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved.
-# $Id: resizablepmcarray.t,v 1.9 2005/01/27 08:00:00 leo Exp $
+# $Id: resizablepmcarray.t,v 1.10 2005/02/19 10:57:30 bernhard Exp $
=head1 NAME
@@no-spam -18,7 +18,7 @@no-spam
=cut
-use Parrot::Test tests => 17;
+use Parrot::Test tests => 18;
use Test::More;
my $fp_equality_macro = <<'ENDOFMACRO';
@@no-spam -480,3 +480,29 @@no-spam
10001
123
OUTPUT
+
+output_is(<< 'CODE', << 'OUTPUT', "push string");
+##PIR##
+.sub test @no-spam
+ .local pmc pmc_arr, pmc_9999
+ .local string string_10000
+ pmc_arr = new ResizablePMCArray
+ pmc_9999 = new Float
+ pmc_9999 = 10000.10000
+ string_10000 = '123asdf'
+ pmc_arr[9999] = pmc_9999
+ push pmc_arr, string_10000
+ .local int elements
+ elements = pmc_arr
+ print elements
+ print "\n"
+ .local pmc last
+ last = pmc_arr[10000]
+ print last
+ print "\n"
+ end
+.end
+CODE
+10001
+123asdf
+OUTPUT