|
777 | 777 | ((current-text) (if (string? atom) atom (format "~a" atom))
|
778 | 778 | pink-code-font
|
779 | 779 | (default-font-size)))))]
|
780 |
| - [(and (symbol? atom) |
781 |
| - (not (equal? atom '_)) |
782 |
| - (regexp-match #rx"^([^_^]*)_([^^]*)\\^?(.*)$" (symbol->string atom))) |
783 |
| - => |
784 |
| - (match-lambda |
785 |
| - [(list _ nt sub sup) |
786 |
| - (let* ([sub-pict (if (regexp-match? #rx"^′+$" sub) |
787 |
| - (basic-text sub (non-terminal-style)) |
788 |
| - (basic-text sub (non-terminal-subscript-style)))] |
789 |
| - [sup-pict (basic-text sup (non-terminal-superscript-style))] |
790 |
| - [sub+sup (lbl-superimpose sub-pict sup-pict)]) |
791 |
| - (list (non-terminal->token col span nt) |
792 |
| - (make-pict-token (+ col span) 0 sub+sup)))])] |
793 |
| - [(or (memq atom all-nts) |
794 |
| - (memq atom underscore-allowed)) |
795 |
| - (list (non-terminal->token col span (symbol->string atom)))] |
796 | 780 | [(symbol? atom)
|
797 |
| - (list (or (rewrite-atomic col span atom literal-style) |
798 |
| - (make-string-token col span (symbol->string atom) (literal-style))))] |
| 781 | + (define (not-nt) |
| 782 | + (list (or (rewrite-atomic col span atom literal-style) |
| 783 | + (make-string-token col span (symbol->string atom) (literal-style))))) |
| 784 | + (define nt-m (regexp-match #rx"^([^_]*)_(.*)$" (symbol->string atom))) |
| 785 | + (cond |
| 786 | + [nt-m |
| 787 | + (define nt-name (list-ref nt-m 1)) |
| 788 | + (define after-underscore (list-ref nt-m 2)) |
| 789 | + (define nt-name-sym (string->symbol nt-name)) |
| 790 | + (cond |
| 791 | + [(or (memq nt-name-sym all-nts) |
| 792 | + (memq nt-name-sym underscore-allowed)) |
| 793 | + (define subsup-m (regexp-match #rx"^([^^]*)\\^(.*)$" after-underscore)) |
| 794 | + (define-values (sub sup) |
| 795 | + (cond |
| 796 | + [subsup-m (values (list-ref subsup-m 1) (list-ref subsup-m 2))] |
| 797 | + [else (values after-underscore "")])) |
| 798 | + (define sub-pict (if (regexp-match? #rx"^′+$" sub) |
| 799 | + (basic-text sub (non-terminal-style)) |
| 800 | + (basic-text sub (non-terminal-subscript-style)))) |
| 801 | + (define sup-pict (basic-text sup (non-terminal-superscript-style))) |
| 802 | + (define sub+sup (lbl-superimpose sub-pict sup-pict)) |
| 803 | + (list (non-terminal->token col span nt-name) |
| 804 | + (make-pict-token (+ col span) 0 sub+sup))] |
| 805 | + [else |
| 806 | + (not-nt)])] |
| 807 | + [(or (memq atom all-nts) |
| 808 | + (memq atom underscore-allowed)) |
| 809 | + (list (non-terminal->token col span (symbol->string atom)))] |
| 810 | + [else |
| 811 | + (not-nt)])] |
799 | 812 | [(or (member atom '("(" ")" "[" "]" "{" "}"))
|
800 | 813 | ;; Typeset keywords in the same font as parentheses:
|
801 | 814 | (and (string? atom)
|
|
0 commit comments