[svn:parrot] r42896 - trunk/tools/dev

fperrad at svn.parrot.org fperrad at svn.parrot.org
Fri Dec 4 21:40:53 UTC 2009


Author: fperrad
Date: Fri Dec  4 21:40:52 2009
New Revision: 42896
URL: https://trac.parrot.org/parrot/changeset/42896

Log:
[languages] remove Configure.pir/Makefile.in,
replace PGE/NQP templates by NQP-RX templates (see 42889)

Modified:
   trunk/tools/dev/mk_language_shell.pl

Modified: trunk/tools/dev/mk_language_shell.pl
==============================================================================
--- trunk/tools/dev/mk_language_shell.pl	Fri Dec  4 21:04:02 2009	(r42895)
+++ trunk/tools/dev/mk_language_shell.pl	Fri Dec  4 21:40:52 2009	(r42896)
@@ -29,22 +29,18 @@
 files and directories (relative to C<path>, which defaults
 to F<xyz> if an explicit C<path> isn't given):
 
-    Makefile.in
+    PARROT_REVISION
     README
-    Configure.pir
     setup.pir
     xyz.pir
     doc/running.pod
     doc/Xyz.pod
-    dynext/.ignore
-    src/builtins.pir
-    src/builtins/say.pir
-    src/parser/grammar.pg
-    src/parser/grammar-oper.pg
-    src/parser/actions.pm
-    src/pmc/Makefile.in
+    src/Xyz.pir
+    src/Xyz/Grammar.pm
+    src/Xyz/Actions.pm
+    src/Xyz/Compiler.pm
+    src/Xyz/Runtime.pm
     src/pmc/xyz.pmc
-    src/ops/Makefile.in
     src/ops/xyz.ops
     src/xyz.pir
     t/00-sanity.t
@@ -56,12 +52,6 @@
 If all goes well, after creating the language shell one can simply
 change to the language directory and type
 
-    $ parrot Configure.pir
-    $ make
-    $ make test
-
-or
-
     $ parrot setup.pir
     $ parrot setup.pir test
 
@@ -190,71 +180,6 @@
     $ parrot setup.pir
     $ parrot setup.pir test
 
-or
-
-    $ parrot Configure.pir
-    $ make
-    $ make test
-
-__Configure.pir__
-#!/usr/bin/env parrot
-# @Id@
-
-.include 'sysinfo.pasm'
-.include 'iglobals.pasm'
-
-.sub 'main' :main
-    load_bytecode 'Configure/genfile.pbc'
-
-    # Wave to the friendly users
-    print "Hello, I'm Configure. My job is to poke and prod\n"
-    print "your system to figure out how to build @lang at .\n"
-
-    .local pmc config
-    $P0 = getinterp
-    config = $P0[.IGLOBALS_CONFIG_HASH]
-    .local string OS
-    OS = sysinfo .SYSINFO_PARROT_OS
-
-    # Here, do the job
-    push_eh _handler
-    genfile('Makefile.in', 'Makefile', config)
- at no_ops@    genfile('src/ops/Makefile.in', 'src/ops/Makefile', config)
- at no_pmc@    genfile('src/pmc/Makefile.in', 'src/pmc/Makefile', config)
-    pop_eh
-
-    # Give the user a hint of next action
-    .local string make
-    make = config['make']
-    print "Configure completed for platform '"
-    print OS
-    print "'.\n"
-    print "You can now type '"
-    print make
-    print "' to build @lclang at .\n"
-    print "You may also type '"
-    print make
-    print " test' to run the @lclang@ test suite.\n"
-    print "\nHappy Hacking.\n"
-    end
-
-  _handler:
-    .local pmc e
-    .local string msg
-    .get_results (e)
-    printerr "\n"
-    msg = e
-    printerr msg
-    printerr "\n"
-    end
-.end
-
-# Local Variables:
-#   mode: pir
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
-
 __setup.pir__
 #!/usr/bin/env parrot
 # @Id@
@@ -280,6 +205,27 @@
     $S0 = shift args
     load_bytecode 'distutils.pbc'
 
+    .local int reqsvn
+    $P0 = open 'PARROT_REVISION', 'r'
+    $S0 = readline $P0
+    reqsvn = $S0
+    close $P0
+
+    .local pmc config
+    config = get_config()
+    $I0 = config['revision']
+    unless reqsvn > $I0 goto L1
+    $S1 = "Parrot revision r"
+    $S0 = reqsvn
+    $S1 .= $S0
+    $S1 .= " required (currently r"
+    $S0 = $I0
+    $S1 .= $S0
+    $S1 .= ")\n"
+    printerr $S1
+    end
+  L1:
+
     $P0 = new 'Hash'
     $P0['name'] = '@lang@'
     $P0['abstract'] = 'the @lang@ compiler'
@@ -296,30 +242,28 @@
 @no_pmc@    $P0['dynpmc'] = $P2
 
     $P4 = new 'Hash'
-    $P5 = split ' ', 'src/parser/grammar.pg src/parser/grammar-oper.pg'
-    $P4['src/gen_grammar.pir'] = $P5
-    $P0['pir_pge'] = $P4
-
-    $P6 = new 'Hash'
-    $P6['src/gen_actions.pir'] = 'src/parser/actions.pm'
-    $P0['pir_nqp'] = $P6
+    $P4['src/gen_actions.pir'] = 'src/@lang@/Actions.pm'
+    $P4['src/gen_compiler.pir'] = 'src/@lang@/Compiler.pm'
+    $P4['src/gen_grammar.pir'] = 'src/@lang@/Grammar.pm'
+    $P4['src/gen_runtime.pir'] = 'src/@lang@/Runtime.pm'
+    $P0['pir_nqp-rx'] = $P4
 
-    $P7 = new 'Hash'
-    $P8 = split "\n", <<'SOURCES'
+    $P5 = new 'Hash'
+    $P6 = split "\n", <<'SOURCES'
 src/@lclang at .pir
-src/gen_grammar.pir
 src/gen_actions.pir
-src/builtins.pir
-src/builtins/say.pir
+src/gen_compiler.pir
+src/gen_grammar.pir
+src/gen_runtime.pir
 SOURCES
-    $S0 = pop $P8
-    $P7['@lclang@/@lclang at .pbc'] = $P8
-    $P7['@lclang at .pbc'] = '@lclang at .pir'
-    $P0['pbc_pir'] = $P7
-
-    $P9 = new 'Hash'
-    $P9['parrot- at lclang@'] = '@lclang at .pbc'
-    $P0['installable_pbc'] = $P9
+    $S0 = pop $P6
+    $P5['@lclang@/@lclang at .pbc'] = $P6
+    $P5['@lclang at .pbc'] = '@lclang at .pir'
+    $P0['pbc_pir'] = $P5
+
+    $P7 = new 'Hash'
+    $P7['parrot- at lclang@'] = '@lclang at .pbc'
+    $P0['installable_pbc'] = $P7
 
     # test
     $S0 = get_parrot()
@@ -341,391 +285,6 @@
 
 __PARROT_REVISION__
 @rev@
-__src/ops/Makefile.in__
-## @Id@
-
-# values from parrot_config
-VERSION_DIR   := @versiondir@
-INCLUDE_DIR   := @includedir@$(VERSION_DIR)
-LIB_DIR       := @libdir@$(VERSION_DIR)
-STAGING_DIR   := ../../dynext
-#INSTALL_DIR   := $(LIB_DIR)/languages/@lclang@/dynext
-INSTALL_DIR   := $(LIB_DIR)/dynext
-
-# Set up extensions
-LOAD_EXT      := @load_ext@
-O             := @o@
-
-# Setup some commands
-PERL          := @perl@
-RM_F          := @rm_f@
-MKPATH        := @mkpath@
-CHMOD         := @chmod@
-CP            := @cp@
-CC            := @cc@ -c
-LD            := @ld@
-LDFLAGS       := @ldflags@ @ld_debug@ @rpath_blib@ @linkflags@
-LD_LOAD_FLAGS := @ld_load_flags@
-CFLAGS        := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
-CC_OUT        := @cc_o_out@
-LD_OUT        := @ld_out@
-LIBPARROT     := @inst_libparrot_ldflags@
-PARROT        := $(BIN_DIR)/parrot at exe@
-
-OPS2C           := $(PERL) $(LIB_DIR)/tools/build/ops2c.pl
-
-INCLUDES        := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/pmc
-LINKARGS        := $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
-
-OPS_FILE := @lclang at .ops
-
-CLEANUPS := \
-  "*$(LOAD_EXT)" \
-  "*$(O)" \
-  "*.c" \
-  "*.h" \
-  "$(STAGING_DIR)/@lclang at _ops*$(LOAD_EXT)"
-
-
-all: staging
-
-generate: $(OPS_FILE)
-	$(OPS2C) C --dynamic $(OPS_FILE)
-	$(OPS2C) CSwitch --dynamic $(OPS_FILE)
-#IF(cg_flag):	$(OPS2C) CGoto --dynamic $(OPS_FILE)
-#IF(cg_flag):	$(OPS2C) CGP --dynamic $(OPS_FILE)
-
-compile: generate
-	$(CC) $(CC_OUT)@lclang at _ops$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops.c
-	$(CC) $(CC_OUT)@lclang at _ops_switch$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_switch.c
-#IF(cg_flag):	$(CC) $(CC_OUT)@lclang at _ops_cg$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_cg.c
-#IF(cg_flag):	$(CC) $(CC_OUT)@lclang at _ops_cgp$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_cgp.c
-
-linklibs: compile
-	$(LD) $(LD_OUT)@lclang at _ops$(LOAD_EXT) @lclang at _ops$(O) $(LINKARGS)
-	$(LD) $(LD_OUT)@lclang at _ops_switch$(LOAD_EXT) @lclang at _ops_switch$(O) $(LINKARGS)
-#IF(cg_flag):	$(LD) $(LD_OUT)@lclang at _ops_cg$(LOAD_EXT) @lclang at _ops_cg$(O) $(LINKARGS)
-#IF(cg_flag):	$(LD) $(LD_OUT)@lclang at _ops_cgp$(LOAD_EXT) @lclang at _ops_cgp$(O) $(LINKARGS)
-
-staging: linklibs
-#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
-	$(CP) "*$(LOAD_EXT)" $(STAGING_DIR)
-
-install:
-#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
-	$(MKPATH) $(INSTALL_DIR)
-	$(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
-
-uninstall:
-	$(RM_F) "$(INSTALL_DIR)/@lclang at _ops*$(LOAD_EXT)"
-
-Makefile: Makefile.in
-	cd ../.. && $(PARROT) Configure.pir
-
-clean:
-	$(RM_F) $(CLEANUPS)
-
-realclean:
-	$(RM_F) $(CLEANUPS) Makefile
-
-# Local variables:
-#   mode: makefile
-# End:
-# vim: ft=make:
-
-__src/pmc/Makefile.in__
-## @Id@
-
-# values from parrot_config
-VERSION_DIR   := @versiondir@
-INCLUDE_DIR   := @includedir@$(VERSION_DIR)
-LIB_DIR       := @libdir@$(VERSION_DIR)
-SRC_DIR       := @srcdir@$(VERSION_DIR)
-TOOLS_DIR     := @libdir@$(VERSION_DIR)/tools/lib
-STAGING_DIR   := ../../dynext
-#INSTALL_DIR   := $(LIB_DIR)/languages/@lclang@/dynext
-INSTALL_DIR   := $(LIB_DIR)/dynext
-
-# Set up extensions
-LOAD_EXT      := @load_ext@
-O             := @o@
-
-# Setup some commands
-PERL          := @perl@
-RM_F          := @rm_f@
-MKPATH        := @mkpath@
-CHMOD         := @chmod@
-CP            := @cp@
-CC            := @cc@ -c
-LD            := @ld@
-LDFLAGS       := @ldflags@ @ld_debug@
-LD_LOAD_FLAGS := @ld_load_flags@
-CFLAGS        := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
-CC_OUT        := @cc_o_out@
-LD_OUT        := @ld_out@
-LIBPARROT     := @inst_libparrot_ldflags@
-PARROT        := $(BIN_DIR)/parrot at exe@
-
-PMC2C_INCLUDES  := --include $(SRC_DIR) --include $(SRC_DIR)/pmc
-PMC2C           := $(PERL) $(LIB_DIR)/tools/build/pmc2c.pl
-PMC2CD          := $(PMC2C) --dump $(PMC2C_INCLUDES)
-PMC2CC          := $(PMC2C) --c $(PMC2C_INCLUDES)
-
-INCLUDES        := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/pmc
-LINKARGS        := $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
-
- at uclang@_GROUP := @lclang at _group
-
-PMC_SOURCES := \
-  @lclang at .pmc
-
-OBJS := \
-  lib-$(@uclang at _GROUP)$(O) \
-  @lclang@$(O)
-
-CLEANUPS := \
-  "*$(LOAD_EXT)" \
-  "*$(O)" \
-  "*.c" \
-  "*.h" \
-  "*.dump" \
-#IF(win32):  "*.exp" \
-#IF(win32):  "*.ilk" \
-#IF(win32):  "*.manifext" \
-#IF(win32):  "*.pdb" \
-#IF(win32):  "*.lib" \
-  $(STAGING_DIR)/$(@uclang at _GROUP)$(LOAD_EXT)
-
-
-all: staging
-
-generate: $(PMC_SOURCES)
-	$(PMC2CD) @lclang at .pmc
-	$(PMC2CC) @lclang at .pmc
-	$(PMC2C) --library $(@uclang at _GROUP) --c $(PMC_SOURCES)
-
-compile: generate
-	$(CC) $(CC_OUT)@lclang@$(O) $(INCLUDES) $(CFLAGS) @lclang at .c
-	$(CC) $(CC_OUT)lib-$(@uclang at _GROUP)$(O) $(INCLUDES) $(CFLAGS) $(@uclang at _GROUP).c
-
-linklibs: compile
-	$(LD) $(LD_OUT)$(@uclang at _GROUP)$(LOAD_EXT) $(OBJS) $(LINKARGS)
-
-staging: linklibs
-#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
-	$(CP) "*$(LOAD_EXT)" $(STAGING_DIR)
-
-install:
-#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
-	$(MKPATH) $(INSTALL_DIR)
-	$(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
-
-uninstall:
-	$(RM_F) $(INSTALL_DIR)/$(@uclang at _GROUP)$(LOAD_EXT)
-
-Makefile: Makefile.in
-	cd ../.. && $(PARROT) Configure.pir
-
-clean:
-	$(RM_F) $(CLEANUPS)
-
-realclean:
-	$(RM_F) $(CLEANUPS) Makefile
-
-# Local variables:
-#   mode: makefile
-# End:
-# vim: ft=make:
-
-__Makefile.in__
-## @Id@
-
-## arguments we want to run parrot with
-PARROT_ARGS   :=
-
-## configuration settings
-VERSION       := @versiondir@
-BIN_DIR       := @bindir@
-LIB_DIR       := @libdir@$(VERSION)
-DOC_DIR       := @docdir@$(VERSION)
-MANDIR        := @mandir@$(VERSION)
-
-# Set up extensions
-LOAD_EXT      := @load_ext@
-O             := @o@
-
-# Various paths
-PERL6GRAMMAR  := $(LIB_DIR)/library/PGE/Perl6Grammar.pbc
-NQP           := $(LIB_DIR)/languages/nqp/nqp.pbc
-PCT           := $(LIB_DIR)/library/PCT.pbc
-PMC_DIR       := src/pmc
-OPS_DIR       := src/ops
-
-## Setup some commands
-MAKE          := @make_c@
-PERL          := @perl@
-CAT           := @cat@
-CHMOD         := @chmod@
-CP            := @cp@
-MKPATH        := @mkpath@
-RM_F          := @rm_f@
-RM_RF         := @rm_rf@
-POD2MAN       := pod2man
-PARROT        := $(BIN_DIR)/parrot at exe@
-PBC_TO_EXE    := $(BIN_DIR)/pbc_to_exe at exe@
-#IF(darwin):
-#IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
-#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
-
- at UCLANG@_GROUP := $(PMC_DIR)/@lclang at _group$(LOAD_EXT)
- at UCLANG@_OPS := $(OPS_DIR)/@lclang at _ops$(LOAD_EXT)
-
- at no_pmc@PMC_DEPS := src/pmc/Makefile.in $(PMC_DIR)/@lclang at .pmc
- at no_ops@OPS_DEPS := src/ops/Makefile.in $(OPS_DIR)/@lclang at .ops
-
-SOURCES := \
-  src/@lclang at .pir \
-  src/gen_grammar.pir \
-  src/gen_actions.pir \
-  src/builtins.pir \
-  src/builtins/say.pir
-
-DOCS := README
-
-BUILD_CLEANUPS := \
-  @lclang at .pbc \
-  @lclang@/@lclang at .pbc \
-  "src/gen_*.pir" \
-  "*.c" \
-  "*$(O)" \
-#IF(win32):  parrot- at lclang@.exe \
-#IF(win32):  parrot- at lclang@.iss \
-#IF(win32):  "setup-parrot-*.exe" \
-  installable_ at lclang@@exe@
-
-TEST_CLEANUPS :=
-
-# the default target
-build: \
-  $(@UCLANG at _OPS) \
-  $(@UCLANG at _GROUP) \
-  @lclang@/@lclang at .pbc \
-  @lclang at .pbc
-
-all: build installable
-
- at lclang@.pbc: @lclang at .pir
-	$(PARROT) $(PARROT_ARGS) -o @lclang at .pbc @lclang at .pir
-
- at lclang@/@lclang at .pbc: $(SOURCES)
-	$(PARROT) $(PARROT_ARGS) -o @lclang@/@lclang at .pbc src/@lclang at .pir
-
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-oper.pg
-	$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
-	    --output=src/gen_grammar.pir \
-	    src/parser/grammar.pg \
-	    src/parser/grammar-oper.pg
-
-src/gen_actions.pir: $(NQP) src/parser/actions.pm
-	$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
-	    --target=pir src/parser/actions.pm
-
-$(@UCLANG at _GROUP): $(PMC_DEPS)
- at no_pmc@	$(MAKE) $(PMC_DIR)
-
-$(@UCLANG at _OPS): $(OPS_DEPS)
- at no_ops@	$(MAKE) $(OPS_DIR)
-
-installable: installable_ at lclang@@exe@
-
-installable_ at lclang@@exe@: @lclang at .pbc
-	$(PBC_TO_EXE) @lclang at .pbc --install
-
-Makefile: Makefile.in
-	$(PARROT) Configure.pir
-
-# This is a listing of all targets, that are meant to be called by users
-help:
-	@echo ""
-	@echo "Following targets are available for the user:"
-	@echo ""
-	@echo "  build:             @lclang at .pbc"
-	@echo "                     This is the default."
-	@echo "  @lclang@@exe@      Self-hosting binary not to be installed."
-	@echo "  all:               @lclang at .pbc @lclang@@exe@ installable"
-	@echo "  installable:       Create libs and self-hosting binaries to be installed."
-	@echo "  install:           Install the installable targets and docs."
-	@echo ""
-	@echo "Testing:"
-	@echo "  test:              Run the test suite."
-	@echo "  test-installable:  Test self-hosting targets."
-	@echo "  testclean:         Clean up test results."
-	@echo ""
-	@echo "Cleaning:"
-	@echo "  clean:             Basic cleaning up."
-	@echo "  realclean:         Removes also files generated by 'Configure.pl'"
-	@echo "  distclean:         Removes also anything built, in theory"
-	@echo ""
-	@echo "Misc:"
-	@echo "  help:              Print this help message."
-	@echo ""
-
-test: build
-	prove --exec="$(PARROT) @lclang at .pbc" t/*.t
-
-# basic run for missing libs
-test-installable: installable
-	echo "1" | ./installable_ at lclang@@exe@
-
-install: installable
- at no_ops@	$(MAKE) $(OPS_DIR) install
- at no_pmc@	$(MAKE) $(PMC_DIR) install
-	$(CP) installable_ at lclang@@exe@ $(BIN_DIR)/parrot- at lclang@@exe@
-	$(CHMOD) 0755 $(BIN_DIR)/parrot- at lclang@@exe@
-	-$(MKPATH) $(LIB_DIR)/languages/@lclang@
-	$(CP) @lclang@/@lclang at .pbc $(LIB_DIR)/languages/@lclang@/@lclang at .pbc
- at no_doc@	-$(MKPATH) $(MANDIR)/man1
- at no_doc@	$(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot- at lclang@.1
- at no_doc@	-$(MKPATH) $(DOC_DIR)/languages/@lclang@
- at no_doc@	$(CP) $(DOCS) $(DOC_DIR)/languages/@lclang@
-
-uninstall:
- at no_ops@	$(MAKE) $(OPS_DIR) uninstall
- at no_pmc@	$(MAKE) $(PMC_DIR) uninstall
-	$(RM_F) $(BIN_DIR)/parrot- at lclang@@exe@
-	$(RM_RF) $(LIB_DIR)/languages/@lclang@
- at no_doc@	$(RM_F) $(MANDIR)/man1/parrot- at lclang@.1
- at no_doc@	$(RM_RF) $(DOC_DIR)/languages/@lclang@
-
-win32-inno-installer: installable
- at no_doc@	-$(MKPATH) man/man1
- at no_doc@	$(POD2MAN) doc/running.pod > man/man1/parrot- at lclang@.1
- at no_doc@	-$(MKPATH) man/html
- at no_doc@	pod2html --infile doc/running.pod --outfile man/html/parrot- at lclang@.html
-	$(CP) installable_ at lclang@@exe@ parrot- at lclang@.exe
-	$(PERL) -I$(LIB_DIR)/tools/lib $(LIB_DIR)/tools/dev/mk_inno_language.pl @lclang@
-	iscc parrot- at lclang@.iss
-
-testclean:
-	$(RM_F) $(TEST_CLEANUPS)
-
-clean:
- at no_ops@	$(MAKE) $(OPS_DIR) clean
- at no_pmc@	$(MAKE) $(PMC_DIR) clean
-	$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS)
-
-realclean:
- at no_ops@	$(MAKE) $(OPS_DIR) realclean
- at no_pmc@	$(MAKE) $(PMC_DIR) realclean
-	$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile
-
-distclean: realclean
-
-# Local variables:
-#   mode: makefile
-# End:
-# vim: ft=make:
-
 __doc/@lang at .pod__
 # @Id@
 
@@ -839,23 +398,25 @@
 
 =cut
 
-.namespace [ '@lang@::Compiler' ]
-
+.HLL '@lclang@'
 @no_pmc at .loadlib '@lclang at _group'
 
-.sub 'onload' :anon :load :init
-    load_bytecode 'PCT.pbc'
+.namespace []
+
+.sub '' :anon :load
+    load_bytecode 'HLL.pbc'
 
-    $P0 = get_hll_global ['PCT'], 'HLLCompiler'
-    $P1 = $P0.'new'()
-    $P1.'language'('@lang@')
-    $P1.'parsegrammar'('@lang@::Grammar')
-    $P1.'parseactions'('@lang@::Grammar::Actions')
+    .local pmc hllns, parrotns, imports
+    hllns = get_hll_namespace
+    parrotns = get_root_namespace ['parrot']
+    imports = split ' ', 'PAST PCT HLL Regex Hash'
+    parrotns.'export_to'(hllns, imports)
 .end
 
-.include 'src/builtins.pir'
 .include 'src/gen_grammar.pir'
 .include 'src/gen_actions.pir'
+.include 'src/gen_compiler.pir'
+.include 'src/gen_runtime.pir'
 
 =back
 
@@ -867,163 +428,121 @@
 # End:
 # vim: expandtab shiftwidth=4 ft=pir:
 
-__src/parser/grammar.pg__
-# @Id@
-
+__src/@lang@/Grammar.pm__
 =begin overview
 
-This is the grammar for @lang@ written as a sequence of Perl 6 rules.
+This is the grammar for @lang@ in Perl 6 rules.
 
 =end overview
 
-grammar @lang@::Grammar is PCT::Grammar;
+grammar @lang@::Grammar is HLL::Grammar;
 
-rule TOP {
-    <statement>*
-    [ $ || <panic: 'Syntax error'> ]
-    {*}
+token TOP {
+    <statementlist>
+    [ $ || <.panic: "Syntax error"> ]
 }
 
-##  this <ws> rule treats # as "comment to eol"
-##  you may want to replace it with something appropriate
+## Lexer items
+
+# This <ws> rule treats # as "comment to eol".
 token ws {
     <!ww>
     [ '#' \N* \n? | \s+ ]*
 }
 
-rule statement {
-    'say' <expression> [ ',' <expression> ]* ';'
-    {*}
-}
-
-rule value {
-    | <integer> {*}                              #= integer
-    | <quote> {*}                                #= quote
-}
+## Statements
 
-token integer { \d+ {*} }
+rule statementlist { [ <statement> | <?> ] ** ';' }
 
-token quote {
-    [ \' <string_literal: '\'' > \' | \" <string_literal: '"' > \" ]
-    {*}
+rule statement {
+    | <statement_control>
+    | <EXPR>
 }
 
-##  terms
-token term {
-    | <value> {*}                                #= value
-}
+proto token statement_control { <...> }
+rule statement_control:sym<say>   { <sym> [ <EXPR> ] ** ','  }
+rule statement_control:sym<print> { <sym> [ <EXPR> ] ** ','  }
 
-rule expression is optable { ... }
+## Terms
 
-__src/parser/grammar-oper.pg__
-# @Id@
+token term:sym<integer> { <integer> }
+token term:sym<quote> { <quote> }
 
-##  expressions and operators
-proto 'term:'     is precedence('=')     is parsed(&term)      { ... }
+proto token quote { <...> }
+token quote:sym<'> { <?[']> <quote_EXPR: ':q'> }
+token quote:sym<"> { <?["]> <quote_EXPR: ':qq'> }
 
-## multiplicative operators
-proto infix:<*>   is looser(term:)       is pirop('mul')     { ... }
-proto infix:</>   is equiv(infix:<*>)    is pirop('div')     { ... }
-
-## additive operators
-proto infix:<+>   is looser(infix:<*>)   is pirop('add')     { ... }
-proto infix:<->   is equiv(infix:<+>)    is pirop('sub')     { ... }
+## Operators
 
-__src/parser/actions.pm__
-# @Id@
-
-=begin comments
-
- at lang@::Grammar::Actions - ast transformations for @lang@
+INIT {
+    @lang@::Grammar.O(':prec<u>, :assoc<left>',  '%multiplicative');
+    @lang@::Grammar.O(':prec<t>, :assoc<left>',  '%additive');
+}
 
-This file contains the methods that are used by the parse grammar
-to build the PAST representation of an @lang@ program.
-Each method below corresponds to a rule in F<src/parser/grammar.pg>,
-and is invoked at the point where C<{*}> appears in the rule,
-with the current match object as the first argument.  If the
-line containing C<{*}> also has a C<#= key> comment, then the
-value of the comment is passed as the second argument to the method.
+token circumfix:sym<( )> { '(' <.ws> <EXPR> ')' }
 
-=end comments
+token infix:sym<*>  { <sym> <O('%multiplicative, :pirop<mul>')> }
+token infix:sym</>  { <sym> <O('%multiplicative, :pirop<div>')> }
 
-class @lang@::Grammar::Actions;
+token infix:sym<+>  { <sym> <O('%additive, :pirop<add>')> }
+token infix:sym<->  { <sym> <O('%additive, :pirop<sub>')> }
+__src/@lang@/Actions.pm__
+class @lang@::Actions is HLL::Actions;
 
 method TOP($/) {
-    my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ) );
-    for $<statement> {
-        $past.push( $( $_ ) );
-    }
-    make $past;
+    make PAST::Block.new( $<statementlist>.ast , :hll<@lclang@>, :node($/) );
 }
 
-
-method statement($/) {
-    my $past := PAST::Op.new( :name('say'), :pasttype('call'), :node( $/ ) );
-    for $<expression> {
-        $past.push( $( $_ ) );
-    }
+method statementlist($/) {
+    my $past := PAST::Stmts.new( :node($/) );
+    for $<statement> { $past.push( $_.ast ); }
     make $past;
 }
 
-##  expression:
-##    This is one of the more complex transformations, because
-##    our grammar is using the operator precedence parser here.
-##    As each node in the expression tree is reduced by the
-##    parser, it invokes this method with the operator node as
-##    the match object and a $key of 'reduce'.  We then build
-##    a PAST::Op node using the information provided by the
-##    operator node.  (Any traits for the node are held in $<top>.)
-##    Finally, when the entire expression is parsed, this method
-##    is invoked with the expression in $<expr> and a $key of 'end'.
-method expression($/, $key) {
-    if ($key eq 'end') {
-        make $($<expr>);
-    }
-    else {
-        my $past := PAST::Op.new( :name($<type>),
-                                  :pasttype($<top><pasttype>),
-                                  :pirop($<top><pirop>),
-                                  :lvalue($<top><lvalue>),
-                                  :node($/)
-                                );
-        for @($/) {
-            $past.push( $($_) );
-        }
-        make $past;
-    }
+method statement($/) {
+    make $<statement_control> ?? $<statement_control>.ast !! $<EXPR>.ast;
 }
 
-
-##  term:
-##    Like 'statement' above, the $key has been set to let us know
-##    which term subrule was matched.
-method term($/, $key) {
-    make $( $/{$key} );
+method statement_control:sym<say>($/) {
+    my $past := PAST::Op.new( :name<say>, :pasttype<call>, :node($/) );
+    for $<EXPR> { $past.push( $_.ast ); }
+    make $past;
 }
 
-
-method value($/, $key) {
-    make $( $/{$key} );
+method statement_control:sym<print>($/) {
+    my $past := PAST::Op.new( :name<print>, :pasttype<call>, :node($/) );
+    for $<EXPR> { $past.push( $_.ast ); }
+    make $past;
 }
 
+method term:sym<integer>($/) { make $<integer>.ast; }
+method term:sym<quote>($/) { make $<quote>.ast; }
 
-method integer($/) {
-    make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node($/) );
-}
+method quote:sym<'>($/) { make $<quote_EXPR>.ast; }
+method quote:sym<">($/) { make $<quote_EXPR>.ast; }
 
+method circumfix:sym<( )>($/) { make $<EXPR>.ast; }
 
-method quote($/) {
-    make PAST::Val.new( :value( $($<string_literal>) ), :node($/) );
-}
+__src/@lang@/Compiler.pm__
+class @lang@::Compiler is HLL::Compiler;
 
+INIT {
+    @lang@::Compiler.language('@lang@');
+    @lang@::Compiler.parsegrammar(@lang@::Grammar);
+    @lang@::Compiler.parseactions(@lang@::Actions);
+}
+__src/@lang@/Runtime.pm__
+# language-specific runtime functions go here
 
-# Local Variables:
-#   mode: cperl
-#   cperl-indent-level: 4
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
+sub print(*@args) {
+    pir::print(pir::join('', @args));
+    1;
+}
 
+sub say(*@args) {
+    pir::say(pir::join('', @args));
+    1;
+}
 __src/pmc/@lclang at .pmc__
 /*
 Copyright (C) 20xx, Parrot Foundation.
@@ -1239,48 +758,6 @@
  * End:
  * vim: expandtab shiftwidth=4:
  */
-__src/builtins.pir__
-# @Id@
-
-.include 'src/builtins/say.pir'
-
-# Local Variables:
-#   mode: pir
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
-
-__src/builtins/say.pir__
-# @Id@
-
-=head1
-
-say.pir -- simple implementation of a say function
-
-=cut
-
-.namespace []
-
-.sub 'say'
-    .param pmc args            :slurpy
-    .local pmc it
-    it = iter args
-  iter_loop:
-    unless it goto iter_end
-    $P0 = shift it
-    print $P0
-    goto iter_loop
-  iter_end:
-    print "\n"
-    .return ()
-.end
-
-
-# Local Variables:
-#   mode: pir
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
 
 __t/00-sanity.t__
 # This just checks that the basic parsing and call to builtin say() works.


More information about the parrot-commits mailing list