forked from pmichaud/pmtcl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:partcl/partcl-nqp
- Loading branch information
Showing
4 changed files
with
196 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
Partcl - a NQP-based implementation of Tcl | ||
partcl-nqp | ||
|
||
This is a proof of concept to reimplement partcl (tcl on parrot) using | ||
the latest compiler tools available for parrot. | ||
Tcl 8.5 on the parrot VM. This does not use the tcl C library, but is a from- | ||
scratch implementation using the Parrot Compiler Toolkit. | ||
|
||
"nqp" in the name comes from the "nqp-rx" toolkit. NQP is Not Quite Perl 6, | ||
and is a mini language that is much higher level than PIR. It also provides | ||
a nice interface to writing mini languages, making it much easier to implement | ||
the various mini languages inside tcl (globbing, regexen, binary) | ||
|
||
See docs/todo.pod for a list of known issues. | ||
|
||
See docs/overview.pod for information on how this version works. | ||
|
||
See http://github.com/partcl/partcl for the original non-PCT version that | ||
is more complete, but is only maintained to keep current with parrot changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,175 @@ | ||
our sub namespace(*@args) { | ||
if +@args < 1 { | ||
Namespace::dispatch_command(|@args); | ||
} | ||
|
||
module Namespace; | ||
|
||
our %Arg_limits; | ||
our %funcs; | ||
our %Auto_vivify; | ||
|
||
INIT { | ||
|
||
## Negative limit in "max" position => unlimited. | ||
%funcs<children> := Namespace::children; | ||
%Arg_limits<children> := [ 0, 2, "?name? ?pattern?" ]; | ||
|
||
%funcs<code> := Namespace::code; | ||
%Arg_limits<code> := [ 1, 1, "script" ]; | ||
|
||
%funcs<current> := Namespace::current; | ||
%Arg_limits<current> := [ 0, 0, "" ]; | ||
|
||
%funcs<delete> := Namespace::delete; | ||
%Arg_limits<delete> := [ 0, -1, "" ]; | ||
|
||
%funcs<ensemble> := Namespace::ensemble; | ||
%Arg_limits<ensemble> := [ 1, 0, "subcommand ?arg...?" ]; | ||
|
||
%funcs<eval> := Namespace::eval; | ||
%Arg_limits<eval> := [ 2, -1, "name arg ?arg...?" ]; | ||
|
||
%funcs<exists> := Namespace::exists; | ||
%Arg_limits<exists> := [ 1, 1, "name" ]; | ||
|
||
%funcs<export> := Namespace::export; | ||
%Arg_limits<export> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<forget> := Namespace::forget; | ||
%Arg_limits<forget> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<import> := Namespace::import; | ||
%Arg_limits<import> := [ 0, -1, "namespace" ]; | ||
|
||
%funcs<inscope> := Namespace::inscope; | ||
%Arg_limits<inscope> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<origin> := Namespace::origin; | ||
%Arg_limits<origin> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<parent> := Namespace::parent; | ||
%Arg_limits<parent> := [ 0, 1, "?name?" ]; | ||
|
||
%funcs<path> := Namespace::path; | ||
%Arg_limits<path> := [ 0, 1, "namespaceList" ]; | ||
|
||
%funcs<qualifiers> := Namespace::qualifiers; | ||
%Arg_limits<qualifiers> := [ 1, 1, "string" ]; | ||
|
||
%funcs<tail> := Namespace::tail; | ||
%Arg_limits<tail> := [ 1, 1, "string" ]; | ||
|
||
%funcs<upvar> := Namespace::upvar; | ||
%Arg_limits<upvar> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<unknown> := Namespace::unknown; | ||
%Arg_limits<unknown> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<unknown> := Namespace::unknown; | ||
%Arg_limits<unknown> := [ 0, 0, "namespace" ]; | ||
|
||
%funcs<which> := Namespace::which; | ||
%Arg_limits<which> := [ 0, 0, "namespace" ]; | ||
} | ||
|
||
# Parses optional -args, and generates "wrong#args" errors | ||
# Dispatches to fairly normal NQP subs for the detailed work. | ||
our sub dispatch_command(*@args) { | ||
my $num_args := +@args -1 ; # need option | ||
|
||
if $num_args < 0 { | ||
error('wrong # args: should be "namespace subcommand ?arg ...?"'); | ||
} | ||
|
||
my @opts := <children code current delete ensemble eval exists export forget import inscope origin parent path qualifiers tail unknown upvar which>; | ||
my $cmd := _tcl::select_option(@opts, @args.shift() ); | ||
|
||
if $cmd eq 'children' { | ||
return ''; | ||
} elsif $cmd eq 'code' { | ||
return ''; | ||
} elsif $cmd eq 'current' { | ||
return ''; | ||
} elsif $cmd eq 'delete' { | ||
return ''; | ||
} elsif $cmd eq 'ensemble' { | ||
return ''; | ||
} elsif $cmd eq 'eval' { | ||
return ''; | ||
} elsif $cmd eq 'exists' { | ||
return ''; | ||
} elsif $cmd eq 'export' { | ||
return ''; | ||
} elsif $cmd eq 'forget' { | ||
return ''; | ||
} elsif $cmd eq 'import' { | ||
return ''; | ||
} elsif $cmd eq 'inscope' { | ||
return ''; | ||
} elsif $cmd eq 'origin' { | ||
return ''; | ||
} elsif $cmd eq 'parent' { | ||
return ''; | ||
} elsif $cmd eq 'path' { | ||
return ''; | ||
} elsif $cmd eq 'qualifiers' { | ||
return ''; | ||
} elsif $cmd eq 'tail' { | ||
return ''; | ||
} elsif $cmd eq 'upvar' { | ||
return ''; | ||
} elsif $cmd eq 'unknkown' { | ||
return ''; | ||
} elsif $cmd eq 'which' { | ||
return ''; | ||
my $cmd := _tcl::select_option(@opts, @args.shift, 'option'); | ||
|
||
my @limits := %Arg_limits{$cmd}; | ||
|
||
if (@limits[1] >= 0 && $num_args > @limits[1]) || $num_args < @limits[0] { | ||
my $msg := @limits[2]; | ||
$msg := " $msg" unless $msg eq ''; | ||
error("wrong # args: should be \"namespace $cmd$msg\"") | ||
} | ||
|
||
my &subcommand := %funcs{$cmd}; | ||
&subcommand(|@args); | ||
} | ||
|
||
my sub children(*@args) { | ||
''; | ||
} | ||
|
||
my sub code(*@args) { | ||
''; | ||
} | ||
|
||
my sub current(*@args) { | ||
''; | ||
} | ||
|
||
my sub delete(*@args) { | ||
''; | ||
} | ||
|
||
my sub ensemble(*@args) { | ||
''; | ||
} | ||
|
||
my sub eval(*@args) { | ||
''; | ||
} | ||
|
||
my sub exists(*@args) { | ||
''; | ||
} | ||
|
||
my sub export(*@args) { | ||
''; | ||
} | ||
|
||
my sub forget(*@args) { | ||
''; | ||
} | ||
|
||
my sub import(*@args) { | ||
''; | ||
} | ||
|
||
my sub inscope(*@args) { | ||
''; | ||
} | ||
|
||
my sub origin(*@args) { | ||
''; | ||
} | ||
|
||
my sub parent(*@args) { | ||
''; | ||
} | ||
|
||
my sub path(*@args) { | ||
''; | ||
} | ||
|
||
my sub qualifiers(*@args) { | ||
''; | ||
} | ||
|
||
my sub tail(*@args) { | ||
''; | ||
} | ||
|
||
my sub upvar(*@args) { | ||
''; | ||
} | ||
|
||
my sub unknown(*@args) { | ||
''; | ||
} | ||
|
||
my sub which(*@args) { | ||
''; | ||
} | ||
|
||
# vim: filetype=perl6: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters