Coder Social home page Coder Social logo

nqp-rx's Introduction

DEPRECATION NOTICE

These days, NQP-rx is unmaintained; active development happens in nqp at https://github.com/perl6/nqp/. This repository only serves as a historical document, and/or an implicit lesson in compiler design.

NQP-rx - Not Quite Perl (6)

NQP-rx is Copyright (C) 2009 by The Perl Foundation. See LICENSE for licensing details.

This is "Not Quite Perl" -- a compiler for quickly generating PIR routines from Perl6-like code. The key feature of NQP-rx is that it's designed to be a very small compiler (as compared with, say, perl6 or Rakudo) and is focused on being a high-level way to create transformers for Parrot (especially hll compilers). In addition, unlike Rakudo, NQP-rx attempts to restrict itself to generating code that can run in Parrot without the existence of any NQP-specific runtime libraries.

Building from source

NQP-rx comes bundled with Parrot, so if you have a recent Parrot distribution you likely also have a copy of NQP-rx. Inside of a Parrot installation NQP-rx is known as parrot-nqp.

To build NQP-rx from source, you'll just need a make utility and Perl 5.8 or newer. To automatically obtain and build Parrot you may also need a subversion (svn) client.

To obtain NQP-rx directly from its repository:

$ git clone git://github.com/perl6/nqp-rx.git

If you don't have git installed, you can get a tarball or zip of NQP from github by visiting http://github.com/perl6/nqp-rx/tree/master and clicking "Download". Then unpack the tarball or zip.

Once you have a copy of NQP-rx, build it as follows:

$ cd nqp-rx
$ perl Configure.pl --gen-parrot
$ make

This will create a "nqp" or "nqp.exe" executable in the current (nqp-rx) directory. Programs can then be run from the build directory using a command like:

$ ./nqp hello.pl

The --gen-parrot option above tells Configure.pl to automatically download and build the most appropriate version of Parrot into a local "parrot/" subdirectory, install that Parrot into the "parrot_install/" subdirectory, and use that for building NQP-rx. It's okay to use the --gen-parrot option on later invocations of Configure.pl; the configure system will re-build Parrot only if a newer version is needed for whatever version of Rakudo you're working with.

You can use --parrot-config=/path/to/parrot_config instead of --gen-parrot to use an already installed Parrot for building NQP. This installed Parrot must include its development environment; typically this is done via Parrot's make install target or by installing prebuilt parrot-devel and/or libparrot-dev packages. The version of the already installed Parrot must satisfy a minimum specified by the NQP-rx being built -- Configure.pl will verify this for you. Released versions of NQP-rx always build against the latest release of Parrot; checkouts of the HEAD revision from github often require a version of Parrot that is newer than the most recent Parrot monthly release.

Once built, NQP-rx's make install target will install NQP-rx and its libraries into the Parrot installation that was used to create it. Until this step is performed, the "nqp" executable created by make above can only be reliably run from the root of NQP-rx's build directory. After make install is performed the executable can be run from any directory (as long as the Parrot installation that was used to create it remains intact).

If the NQP-rx compiler is invoked without an explicit script to run, it enters a small interactive mode that allows statements to be executed from the command line.

Differences from previous version of NQP

* Sub declarations are now lexical ("my") by default, use "our sub xyz() { ... }" if you want package-scoped subroutines.

* The PIR q<...>; construct is gone. Use Q:PIR or pir::opcode(...) instead.

* The mainline code of modules is no longer tagged as ":load :init" by default. Use INIT { ... } for any code that you want to be run automatically at startup.

* Cuddled else's are no longer valid Perl 6, 'else' requires a space after it.

* Double-quoted strings now interpolate $-variables.

nqp-rx's People

Contributors

bacek avatar bkeeler avatar coke avatar cotto avatar jnthn avatar leto avatar moritz avatar perlpilot avatar plobsing avatar pmichaud avatar snarkyboojum avatar sorear avatar tene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nqp-rx's Issues

"next()" Creates bad PIR

http://gist.github.com/455249

In this gist, the keyword "next" is called like a function with "next()". I'm not sure if this would be valid Perl6 or not, but the generated PIR has this snippet:

set $I13, .CONTROL_LOOP_NEXT
die 0, $I13
$P14 = ()

This is a PIR parse error and Parrot barfs over it.

nom branch: fails to build if an installed version is available

In the nom branch, build fails when an installed version of nqp is available. Steps to reproduce:

$ perl Configure.pl --gen-parrot
$ make install
$ make clean
$ make

That last step fails with

cd src/ops && /home/moritz/p6/nqp-rx/parrot_install/bin/ops2c C --dynamic nqp.ops
Null PMC access in find_method('new_type')
current instr.: 'parrot;Regex;Cursor;' pc -1 ((unknown file):-1)
called from Sub '' pc 0 (src/HLL.pir:17)
... call repeated 1 times
make: *** [src/ops/nqp_ops.so] Error 1

Allow interpolated strings in .panics

For example:

token list {
    \s*
    [
    | <EXPR=.braced_word>
        [ $<extra>=(\S+) <.panic: "list element in braces followed by \"$<extra>\" instead of space" > ]?
    | <EXPR=.list_word>
    ] ** [\s+]
}

<![...]> does not match at end of string

< pmichaud> rakudo:  say ?("abc" ~~ / 'abc' <![ ( \\ ' \- ]> /)
<+p6eval> rakudo 2c8bb8: OUTPUT«0?»
< pmichaud> looks like a bug with <![...]>
< moritz_> should <![...]> be the same as <!before <[...]> > ?
< pmichaud> essentially, yes.
< pmichaud> it's a zero-width negated match
< pmichaud> rakudo:  say ?("abc" ~~ / 'abc' <!before <[ ( \\ ' \- ]> >/)
<+p6eval> rakudo 2c8bb8: OUTPUT«1?»
< moritz_> pmichaud: want me to submit a bug report for the regex thing?
< pmichaud> moritz_: sure, it's an nqp-rx bug.  I've found the bug, I'm
            trying to figure out how to fix it.

Better PIR sub names

Is it possible to get better names for the generated PIR subs? Something like "_block128" is probably very easy to produce in terms of code generation, but it makes for hell when we're trying to do PIR-level debugging on the generated code. Something like "_block128" would be ideal, if possible.

pre-increment as expression not handled correctly

In the version of -rx shipped with parrot 2.2, an expression like:

while (++$pos < $string_len)

generates PIR like:

find_lex $P804, "$pos"
inc $P804
set $N805, 
find_lex $P806, "$string_len"

Note the incomplete "set" statement on line 3.

Floats with zero decimal part become ints

Literal floats with zero decimal part become ints in PIR. For example PAST::Val.new(:value(1.0)) becomes $P16."new"(1 :named("value")) (SHA: 699da41). This works as a test:

sub are_floats_floats($x) {
    if !pir::isa($x, 'Float') {
        print('not ');
    }
    say('ok 1 - Float argument # TODO: PAST::Compiler bug');
}
are_floats_floats(1.0);

Array attributes silently don't work

class A {
    has @!x;
    method pushx($a) {
        pir::push(@!x, $a);
        say(pir::join('|', @!x));
    }
}

A.new.pushx('42');

# output: an empty line. Should be 42\n, IMHO

That's the same both in master and nom branch. Needs fixing :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.