Permalink
Browse files

added Niecza::Frontend::STD which will be responsible for the parsing

  • Loading branch information...
1 parent d5ec680 commit 67a3e6fff6a6767f955fda95a0e59cd0af1fbd2f @pmurias pmurias committed Jan 2, 2011
Showing with 30 additions and 0 deletions.
  1. +21 −0 src/Niecza/Frontend/STD.pm
  2. +9 −0 t/frontend-std.t
@@ -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;
View
@@ -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.