Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added Niecza::Frontend::STD which will be responsible for the parsing
  • Loading branch information
pmurias committed Jan 2, 2011
1 parent d5ec680 commit 67a3e6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Niecza/Frontend/STD.pm
@@ -0,0 +1,21 @@
package Niecza::Frontend::STD;
use Moose;
use Niecza::Grammar ();
use Niecza::Actions ();
has lang=>(is=>'ro');
has UNITNAME=>(is=>'ro');
sub parse {
my ($self,$source,$filename) = @_;
local $::SETTING_UNIT;
local $::YOU_WERE_HERE;
local $::UNITNAME = $self->UNITNAME // 'MAIN';
$::UNITNAME =~ s/::/./g;
$STD::ALL = {};

if ($self->lang ne 'NULL') {
$::SETTING_UNIT = $self->lang;
}
my $ast = Niecza::Grammar->parse($source, setting => $self->lang,
actions => 'Niecza::Actions', filename=>$filename)->{_ast},
}
1;
9 changes: 9 additions & 0 deletions t/frontend-std.t
@@ -0,0 +1,9 @@
use v5.10;
use strict;
use warnings;
use Test::More;
use Niecza::Frontend::STD;
my $parser = Niecza::Frontend::STD->new(lang=>'CORE');
my $ast = $parser->parse('123');
isa_ok($ast,'Unit');
done_testing;

0 comments on commit 67a3e6f

Please sign in to comment.