jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
189 stars 61 forks source link

Scheme parser fails to recognize function definition #177

Open ceving opened 8 months ago

ceving commented 8 months ago

I am using skylighting 0.12.3.1.

I have the following example file:

(define-syntax grammar
  (syntax-rules (→)
    ((_ (left1 → right11 right12 ...)
        (left2 → right21 right22 ...)
        ...)
     (vector (production left1 → right11 right12 ...)
             (production left2 → right21 right22 ...)
             ...))))
(define grammar-production vector-ref)
(define (grammar-production-number g p)
  (let ((l (vector-length g)))
    (let loop ((i 0))
      (if (>= i l)
          #f
          (if (equal? (grammar-production g i) p)
              i
              (loop (+ i 1)))))))

I run the following command:

skylighting -f native -s scheme test.scm

The first define works fine although I do not understand, why the white-space is part of FunctionTok:

, [ ( NormalTok , "(" )
  , ( ExtensionTok , "define" )
  , ( FunctionTok , " grammar-production " )
  , ( KeywordTok , "vector-ref" )
  , ( NormalTok , ")" )
  ]

But the second definition does not work:

, [ ( NormalTok , "(" )
  , ( ExtensionTok , "define" )
  , ( FunctionTok , " " )
  , ( NormalTok , "(grammar-production-number g p)" )
  ]

The FunktionTok contains just the white-space.

ceving commented 8 months ago

Seems to be an upstream bug: https://bugs.kde.org/show_bug.cgi?id=476879

jgm commented 8 months ago

Let us know when it's fixed upstream.