|
| 1 | +package Gherkin::MarkdownTokenMatcher; |
| 2 | + |
| 3 | +use strict; |
| 4 | +use warnings; |
| 5 | + |
| 6 | +use base 'Gherkin::TokenMatcher'; |
| 7 | + |
| 8 | +1; |
| 9 | + |
| 10 | + |
| 11 | +__END__ |
| 12 | +
|
| 13 | +
|
| 14 | +=head1 NAME |
| 15 | +
|
| 16 | +Gherkin::MarkdownTokenMatcher - Line token matching for the Gherkin parser |
| 17 | +
|
| 18 | +=head1 SYNOPSIS |
| 19 | +
|
| 20 | + use Gherkin::MarkdownTokenMatcher; |
| 21 | + use Gherkin::Dialect; |
| 22 | +
|
| 23 | + # Instantiate a token matcher with the default language 'Emoji' |
| 24 | + my $matcher = Gherkin::MarkdownTokenMatcher->new( { |
| 25 | + dialect => Gherkin::Dialect->new( { dialect => 'em'} ) |
| 26 | + } ); |
| 27 | +
|
| 28 | +=head1 DESCRIPTION |
| 29 | +
|
| 30 | +This is an alternate token matcher for Markdown with Gherkin (MDG). |
| 31 | +
|
| 32 | +The Gherkin language has a line-based structure. The parser knows about state, |
| 33 | +but defers identifying the type of line tokens to the token matcher. The |
| 34 | +matcher knows how to identify line tokens based on the grammar's keywords. |
| 35 | +Although the matcher knows how to identify line tokens based on the keywords, |
| 36 | +it depends on L<Gherkin::Dialect> to provide the actual keyword texts. |
| 37 | +
|
| 38 | +=head1 METHODS |
| 39 | +
|
| 40 | +=head2 new( [$options] ) |
| 41 | +
|
| 42 | +Constructor. |
| 43 | +
|
| 44 | +C<$options> is a hashref with the following keys: |
| 45 | +
|
| 46 | +=over |
| 47 | +
|
| 48 | +=item C<dialect> |
| 49 | +
|
| 50 | +An instance of L<Gherkin::Dialect> to provide the keyword texts used to identify |
| 51 | +the type of line-token being matched. |
| 52 | +
|
| 53 | +=back |
| 54 | +
|
| 55 | +=head2 dialect_name |
| 56 | +
|
| 57 | +Returns the name of the current dialect selected from the C<dialect> instance. |
| 58 | +
|
| 59 | +=head2 change_dialect |
| 60 | +
|
| 61 | +Changes the selected dialect on the C<dialect> instance. Dialects are groups of |
| 62 | +keywords belonging together; this is how keyword translations are being handled. |
| 63 | +
|
| 64 | +=head2 reset |
| 65 | +
|
| 66 | +Changes the token scanner's state back to its initial state; used to restart |
| 67 | +scanning a document. Multiple documents may be parsed using a single token |
| 68 | +scanner with a C<reset> call in-between. |
| 69 | +
|
| 70 | +=head1 SEE ALSO |
| 71 | +
|
| 72 | +=over 8 |
| 73 | +
|
| 74 | +=item * L<Gherkin> |
| 75 | +
|
| 76 | +=item * L<Gherkin::Dialect> |
| 77 | +
|
| 78 | +=item * L<Gherkin::Parser> |
| 79 | +
|
| 80 | +=item * L<Gherkin::TokenMatcher> |
| 81 | +
|
| 82 | +=back |
| 83 | +
|
| 84 | +=head1 LICENSE |
| 85 | +
|
| 86 | +See L<Gherkin>. |
| 87 | +
|
| 88 | +=cut |
0 commit comments