From d3ceee50430f77e2c3672f2ae925e29b28400186 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sat, 24 Sep 2016 00:02:18 +0800 Subject: [PATCH] Enhancing the doc --- doc/adding-tests.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/adding-tests.md b/doc/adding-tests.md index 769383d31..4da6d4093 100644 --- a/doc/adding-tests.md +++ b/doc/adding-tests.md @@ -63,7 +63,22 @@ TestTemplates ::= [ ... ``` -For every name mentioned, you will find a `.stg` file with the actual test. E.g., `Sets/StarSet.stg`: +For every name mentioned, you will find a `.stg` file with the actual test template. E.g., `Sets/StarSet.stg`. + +Each `.stg` file descripes the following mandatory elements for the test: + - the test type: "Parser" or "Lexer" + - some ANTLR options, such as "Debug" + - the grammar + - the start rule + - the input i.e. the text to parse + - the expected output + - the expected errors + +The grammar can itself contain template expressions such as . +The test generator replaces these with the corresponding values from the target language template (see below). +It then generates a unit test in which the grammar, the input and the expected output and errors are inlined. + +Here is an example test template: ``` TestType() ::= "Parser" @@ -92,6 +107,7 @@ a : ('a'|'b')* 'c' {} ; >> ``` + ### Cross-language actions embedded within grammars To get: