-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grammar/parser: make the grammar use ParserFactory to create Parsers
Signed-off-by: Tibor Benke <ihrwein@gmail.com>
- Loading branch information
Showing
3 changed files
with
99 additions
and
82 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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
mod pattern_parser; | ||
pub use self::pattern_parser::pattern; | ||
pub use self::pattern_parser::ParseError; | ||
|
||
pub type ConcreteParserFactory = ::matcher::trie::parser_factory::TrieParserFactory; | ||
use matcher::compiled_pattern::CompiledPattern; | ||
use parsers::ParserFactory; | ||
use self::pattern_parser::ParseResult; | ||
|
||
mod pattern_parser; | ||
|
||
pub fn pattern_with_factory<F: ParserFactory>(input: &str) -> ParseResult<CompiledPattern> { | ||
self::pattern_parser::pattern::<F>(input) | ||
} | ||
|
||
/* | ||
When you regenerate the grammar, don't forget to insert the F generic type parameter with | ||
the following command: | ||
rm -f pattern_parser.rs; cat pattern_parser.rs.IN | sed "s/\(fn [a-zA-Z0-9_]*<'input\)/\1, F: ParserFactory/" | sed "s/\(parse[a-zA-Z0-9_]*\)(/\1::<F>(/" >> pattern_parser.rs | ||
The first sed add the F: ParserFactory generic type parameter to every function definition. | ||
The second sed threads this F parameter through the call sites as well. | ||
*/ | ||
pub fn pattern(input: &str) -> ParseResult<CompiledPattern> { | ||
use ::matcher::trie::parser_factory::TrieParserFactory; | ||
self::pattern_parser::pattern::<TrieParserFactory>(input) | ||
} |
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
Oops, something went wrong.