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