Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See examples/mygrammar for a working example.
- Loading branch information
Carl Masak
committed
Apr 25, 2010
1 parent
c4fb5b3
commit c4696f5
Showing
6 changed files
with
66 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use v6; | ||
|
||
use GGE; | ||
|
||
my $debug = False; | ||
|
||
class MyGrammar is GGE::Grammar { | ||
GGE::Perl6Regex.new("<bar>", :$debug, :grammar<MyGrammar>, :name<TOP>); | ||
GGE::Perl6Regex.new("'OH HAI'", :$debug, :grammar<MyGrammar>, :name<bar>); | ||
} | ||
|
||
my GGE::Match $match | ||
= MyGrammar.parse('this string contains "OH HAI" as a substring', :$debug); | ||
|
||
say $match ?? $match.dump_str('mob', ' ', '') !! "No match\n"; |
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,2 +1,3 @@ | ||
use v6; | ||
use GGE::Perl6Regex; | ||
use GGE::Grammar; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use v6; | ||
|
||
use GGE::Match; | ||
|
||
class GGE::Grammar is GGE::Match { | ||
method parse($target, :$debug) { | ||
die "Cannot call .parse on a grammar with no TOP rule" | ||
unless self.can('TOP'); | ||
my $m = self.new($target); | ||
$m.TOP(:$debug); | ||
} | ||
} |
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