Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
More build process cleanups. Add :PIR{{...}} modifier for inlined PIR
Browse files Browse the repository at this point in the history
in regexes.
  • Loading branch information
pmichaud committed Oct 26, 2009
1 parent 63139fe commit 1a369e2
Show file tree
Hide file tree
Showing 6 changed files with 4,963 additions and 4,792 deletions.
21 changes: 12 additions & 9 deletions build/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ P6GRAMMAR_PBC = P6Grammar.pbc
P6GRAMMAR_G = gen/p6grammar-grammar.pir
P6GRAMMAR_A = gen/p6grammar-actions.pir

STAGE0_PBCS = $(STAGE0)/$(P6REGEX_PBC) $(STAGE0)/$(P6GRAMMAR_PBC)
STAGE1_PBCS = $(STAGE1)/$(P6REGEX_PBC) $(STAGE1)/$(P6GRAMMAR_PBC)

HLLGRAMMAR_PBC = HLLGrammar.pbc

CLEANUPS = \
Expand Down Expand Up @@ -113,8 +116,8 @@ $(STAGE0)/$(P6GRAMMAR_PBC): $(STAGE0)/$(P6REGEX_PBC) src/stage0/P6Grammar-s0.pir

$(STAGE1): $(STAGE1)/$(P6REGEX_PBC) $(STAGE1)/$(P6GRAMMAR_PBC)

$(STAGE1)/$(P6REGEX_PBC): $(STAGE0)/$(P6GRAMMAR_PBC) $(P6REGEX_SOURCES)
$(RM) $(P6REGEX_PBC) $(P6GRAMMAR_PBC)
$(STAGE1)/$(P6REGEX_PBC): $(STAGE0_PBCS) $(P6REGEX_SOURCES)
$(RM) $(P6REGEX_PBC)
$(MKPATH) $(STAGE1)/gen
$(PARROT) --library=$(STAGE0) $(STAGE0)/$(P6GRAMMAR_PBC) \
--target=pir --output=$(STAGE1)/$(P6REGEX_G) \
Expand All @@ -125,8 +128,8 @@ $(STAGE1)/$(P6REGEX_PBC): $(STAGE0)/$(P6GRAMMAR_PBC) $(P6REGEX_SOURCES)
$(PARROT) --include=$(STAGE1) -o $(STAGE1)/$(P6REGEX_PBC) \
src/Regex/P6Regex.pir

$(STAGE1)/$(P6GRAMMAR_PBC): $(STAGE0)/$(P6GRAMMAR_PBC) $(P6GRAMMAR_SOURCES)
$(RM) $(P6REGEX_PBC) $(P6GRAMMAR_PBC)
$(STAGE1)/$(P6GRAMMAR_PBC): $(STAGE0_PBCS) $(P6GRAMMAR_SOURCES)
$(RM) $(P6REGEX_PBC)
$(MKPATH) $(STAGE1)/gen
$(PARROT) --library=$(STAGE0) $(STAGE0)/$(P6GRAMMAR_PBC) \
--target=pir --output=$(STAGE1)/$(P6GRAMMAR_G) \
Expand All @@ -139,8 +142,8 @@ $(STAGE1)/$(P6GRAMMAR_PBC): $(STAGE0)/$(P6GRAMMAR_PBC) $(P6GRAMMAR_SOURCES)

$(STAGE2): $(STAGE2)/$(P6REGEX_PBC) $(STAGE2)/$(P6GRAMMAR_PBC)

$(STAGE2)/$(P6REGEX_PBC): $(STAGE1)/$(P6GRAMMAR_PBC) $(P6REGEX_SOURCES)
$(RM) $(P6REGEX_PBC) $(P6GRAMMAR_PBC)
$(STAGE2)/$(P6REGEX_PBC): $(STAGE1_PBCS) $(P6REGEX_SOURCES)
$(RM) $(P6REGEX_PBC)
$(MKPATH) $(STAGE2)/gen
$(PARROT) --library=$(STAGE1) $(STAGE1)/$(P6GRAMMAR_PBC) \
--target=pir --output=$(STAGE2)/$(P6REGEX_G) \
Expand All @@ -151,8 +154,8 @@ $(STAGE2)/$(P6REGEX_PBC): $(STAGE1)/$(P6GRAMMAR_PBC) $(P6REGEX_SOURCES)
$(PARROT) --include=$(STAGE2) -o $(STAGE2)/$(P6REGEX_PBC) \
src/Regex/P6Regex.pir

$(STAGE2)/$(P6GRAMMAR_PBC): $(STAGE1)/$(P6GRAMMAR_PBC) $(P6GRAMMAR_SOURCES)
$(RM) $(P6REGEX_PBC) $(P6GRAMMAR_PBC)
$(STAGE2)/$(P6GRAMMAR_PBC): $(STAGE1_PBCS) $(P6GRAMMAR_SOURCES)
$(RM) $(P6REGEX_PBC)
$(MKPATH) $(STAGE2)/gen
$(PARROT) --library=$(STAGE1) $(STAGE1)/$(P6GRAMMAR_PBC) \
--target=pir --output=$(STAGE2)/$(P6GRAMMAR_G) \
Expand Down Expand Up @@ -195,7 +198,7 @@ bootstrap: p6grammar
./p6grammar --target=pir src/Regex/P6Regex/Grammar.pm >p6regex-grammar.pir
./p6grammar --target=pir src/Regex/P6Grammar/Grammar.pm >p6grammar-grammar.pir

bootstrap-files: src/gen/p6regex-grammar.pir src/gen/p6grammar-grammar.pir
bootstrap-files: $(STAGE2)/$(P6REGEX_PBC) $(STAGE2)/$(P6GRAMMAR_PBC)
$(PERL) build/gen_bootstrap.pl src/Regex/P6Regex.pir >src/stage0/P6Regex-s0.pir
$(PERL) build/gen_bootstrap.pl src/Regex/P6Grammar.pir >src/stage0/P6Grammar-s0.pir

Expand Down
4 changes: 4 additions & 0 deletions build/gen_bootstrap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ sub make_bootstrap {
print "### $_";
make_bootstrap($1);
}
elsif (m{^\.include '(gen/[^']*)'}) {
print "### $_";
make_bootstrap("src/stage2/$1");
}
else { print; }
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Regex/P6Regex/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ method metachar:sym<var>($/) {
make $past;
}

method metachar:sym<PIR>($/) {
make PAST::Regex.new(
PAST::Op.new( :inline(~$<pir>), :pasttype('inline'), ),
:pasttype('pastnode'), :node($/)
);
}


method backslash:sym<w>($/) {
my $subtype := ~$<sym> eq 'n' ?? 'nl' !! ~$<sym>;
my $past := PAST::Regex.new( :pasttype('charclass'), :subtype($subtype), :node($/) );
Expand Down
4 changes: 4 additions & 0 deletions src/Regex/P6Regex/Grammar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ grammar Regex::P6Regex::Grammar;
[ <.ws> '=' <.ws> <quantified_atom> ]?
}

token metachar:sym<PIR> {
':PIR{{' $<pir>=[.*?] '}}'
}

proto token backslash { <...> }
token backslash:sym<w> { $<sym>=[<[dswnDSWN]>] }
token backslash:sym<b> { $<sym>=[<[bB]>] }
Expand Down
Loading

0 comments on commit 1a369e2

Please sign in to comment.