| 1 | module main |
| 2 | |
| 3 | struct ComparisonCase { |
| 4 | name string |
| 5 | source string |
| 6 | expected_tokens int // includes Vile's EOF |
| 7 | expected_forms int // Blip top-level forms |
| 8 | } |
| 9 | |
| 10 | // Restrict the corpus to syntax both projects support. In particular, bounded |
| 11 | // decimal integers avoid silently benchmarking Blip's symbol fallback for a |
| 12 | // huge integer that it cannot represent. |
| 13 | fn comparison_cases(size int) []ComparisonCase { |
| 14 | integers := '123 -456 7890 0\n' |
| 15 | integer_repeats := size / integers.len + 1 |
| 16 | form := '(define (square x) (+ (* x x) 123))\n' |
| 17 | form_repeats := size / form.len + 1 |
| 18 | quoted := "'(alpha 123 (beta gamma))\n" |
| 19 | quoted_repeats := size / quoted.len + 1 |
| 20 | identifiers := 'alpha betaGamma list->vector a.b c@d set! <= call/cc x9\n' |
| 21 | identifier_repeats := size / identifiers.len + 1 |
| 22 | varied_identifier := 'Ab9!\$%&*/:<=>?^_~+-.@' |
| 23 | return [ |
| 24 | ComparisonCase{'identifier', 'a'.repeat(size), 2, 1}, |
| 25 | ComparisonCase{'varied-id', varied_identifier.repeat(size / varied_identifier.len + 1), 2, 1}, |
| 26 | ComparisonCase{'short-ids', identifiers.repeat(identifier_repeats), 9 * identifier_repeats + 1, 9 * identifier_repeats}, |
| 27 | ComparisonCase{'integers', integers.repeat(integer_repeats), 4 * integer_repeats + 1, 4 * integer_repeats}, |
| 28 | ComparisonCase{'string', '"' + 'x'.repeat(size) + '"', 2, 1}, |
| 29 | ComparisonCase{'comment', ';' + 'x'.repeat(size) + '\n', 1, 0}, |
| 30 | ComparisonCase{'mixed', form.repeat(form_repeats), 16 * form_repeats + 1, form_repeats}, |
| 31 | ComparisonCase{'quoted', quoted.repeat(quoted_repeats), 9 * quoted_repeats + 1, quoted_repeats}, |
| 32 | ] |
| 33 | } |
| 34 | |