Inline::Nouse - An Inline.pm interpreter for the Nouse language


Inline-Nouse documentation Contained in the Inline-Nouse distribution.

Index


Code Index:

NAME

Top

Inline::Nouse - An Inline.pm interpreter for the Nouse language

SYNOPSIS

Top

  use Inline 'Nouse' => 'function hello { #r<a>z+x>y^y+z>c>z>t:4+z#0^f>z>0?z^0+z>z+9<x#1+z:3>w>z#r+i^0>c>z>0 }';

  # prints "hello world"
  &hello;

DESCRIPTION

Top

This module allows Nouse subs to be used directly within perl. For more usage information, see Inline::Interp and Language::Nouse, on which this module is based.

AUTHOR

Top

Copyright (C) 2003, Cal Henderson <cal@iamcal.com>

SEE ALSO

Top

Inline

Inline::Interp

Language::Nouse

http://www.geocities.com/qpliu/nouse/nouse.html


Inline-Nouse documentation Contained in the Inline-Nouse distribution.

package Inline::Nouse;

$VERSION = '0.03';

require Inline;
require Inline::Interp;
require Language::Nouse;

@ISA = qw(Inline Inline::Interp);

use strict;
use Carp;

my $g_io;

sub register {
	return {
		language => 'nouse',
		aliases => ['Nouse', 'nouse'],
		type => 'interpreted',
		suffix => 'ns',
	};
}

sub do_load {
	my ($funcs, $code) = @_;

	while($code =~ m/function(\s+)([a-z0-9_]+)(\s*){(.*?)}/isg){
		Inline::Interp::add_func($funcs, $2, $4);
	}
}

sub load {
	Inline::Interp::load(@_);
}

sub get_char {
	return Inline::Interp::input_char($g_io);
}

sub put_char {
	my ($out) = @_;
	Inline::Interp::output_char($g_io, $out);
}

sub do_run {
	my ($code, $io) = @_;

	$g_io = $io;

	my $interp = new Language::Nouse;
	$interp->load_linenoise($code);
	$interp->set_get(\&get_char);
	$interp->set_put(\&put_char);

	$interp->run();
}

1;

__END__