Skip to content

Commit

Permalink
Fix preprocessor documentation
Browse files Browse the repository at this point in the history
When we dropped YAML, this documentation became
obsolete. Fix it to match our changes to the labs
for internationalization.

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
  • Loading branch information
david-a-wheeler committed Feb 4, 2025
1 parent 9d44f23 commit 6df883b
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions docs/labs/create_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,33 +619,36 @@ requested, and the second is post-processed pattern that should result.
There's no need for a "failure" test suite here, because we
demand exact results for every test case.

Here is an example (expressed in YAML format):

~~~~yaml
preprocessing:
-
- |-
[\n\r]+
- ""
-
- |-
[ \t]+\\s\+[ \t]+
- "\\s+"
-
- |-
(\\s\*)?[ \t]+(\\s\*)?
- "\\s*"
preprocessingTests:
-
- |-
\s* console \. log \( (["'`])Hello,\x20world!\1 \) ; \s*
- |-
\s*console\s*\.\s*log\s*\(\s*(["'`])Hello,\x20world!\1\s*\)\s*;\s*
-
- |-
\s* foo \s+ bar \\string\\ \s*
- |-
\s*foo\s+bar\s*\\string\\\s*
Here is an example:

~~~~javascript
preprocessing: [
[
// Ignore newlines
String.raw`[\n\r]+`,
""
],
[
// Convert \s+ surrounded by tabs/spaces as \s+ (optimization)
String.raw`[ \t]+\\s\+[ \t]+`,
String.raw`\s+`
],
[
// Convert 1+ spaces/tabs, optionally surrounded by \s*, as \s*
String.raw`(\\s\*)?[ \t]+(\\s\*)?`,
String.raw`\s*`
]
],
preprocessingTests: [
[
String.raw`\s* console \. log \( (["'${BACKQUOTE}])Hello,\x20world!\1 \) ; \s*`,
String.raw`\s*console\s*\.\s*log\s*\(\s*(["'${BACKQUOTE}])Hello,\x20world!\1\s*\)\s*;\s*`
],
[
String.raw`\s* foo \s+ bar \\string\\ \s*`,
String.raw`\s*foo\s+bar\s*\\string\\\s*`
]
]
~~~~

Here is an explanation of each of these preprocessing elements
Expand Down

0 comments on commit 6df883b

Please sign in to comment.