Grammar Testing
Unit testing is the best way I've found to really develop a grammar. It allows you to focus on very specific pieces of the grammar at a time, then later put it all together by parsing an entire document.
This library depends upon php-tests for testing.
Links:
- Writing a Grammar: docs/GrammarWriting.md
- Grammar Example: docs/GrammarExample.md
- Grammar Commands: docs/GrammarCommands.md
Howto
- Extend
\Tlf\Lexer\Test\Tester
which extends from\Tlf\Tester
or copy the methods from it & modify as needed for a different testing library. - Implement a
testGrammarName()
method that uses the test runner - Implement the data structure for defining the unit tests.
Example of 2.
:
Template 'methods.testPhpDirectives.definition' does not exist. {
Template 'methods.testPhpDirectives.body' does not exist.
}
Example of 3.
:
-- whatever goes here