github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.28k stars 4.25k forks source link

Scheme syntax is outdated #5612

Open jcubic opened 3 years ago

jcubic commented 3 years ago

Describe the bug

Scheme syntax highlighting doesn't handle #; syntax for S-Expression comment. And probably a lot of other new syntaxes. I think that the project sicp-lang/scheme.tmbundle (as the name of the org suggests) is really old, SICP was created in 1985, The latest spec of the Scheme langauge is from 2016.

Here is an example of a few modern syntaxes. expression comment, block comment, and symbol with parenthesis inside.

(let ((x #;(expression
             comment ")") 10)
      (|this is )))) symbol| 20))
   #|
    this is comment ))))
   |#
   (+ x |this is )))) symbol|))

You can execute this in a modern Scheme and it should evaluate to 30.

Expected behavior

I expect no errors from the modern Scheme.

Related discussion

Maybe it's worth finding something more up-to-date. I don't know if sicp-lang/scheme.tmbundle supports anything beyond SICP.

Additional notes

lildude commented 3 years ago

Maybe it's worth finding something more up-to-date.

As you are familiar with this language and the expected syntax highlighting, you're in the best position to find a more apt grammar and submit a PR to update Linguist to use it (see CONTRIBUTING.md).

Relabelling as this isn't a bug in Linguist.

Alhadis commented 3 years ago

Here is an example of a few modern syntaxes. expression comment, block comment, and symbol with parenthesis inside.

@jcubic Are you sure this is standard Scheme syntax, and not an implementation-defined extension? I only ask because I found no mention of #; in Scheme's formal grammar.

I know nothing of Scheme, so please correct me if I'm missing something.

jcubic commented 3 years ago

R7RS small is the current latest standard of Scheme, it was published in 2015 with errata that was integrated into a single document here https://standards.scheme.org/unofficial/errata-corrected-r7rs.pdf

All things I've mentioned in the original issue are included in the R7RS spec.

jcubic commented 10 months ago

What is the syntax that you use for the highlighting? I can see if I can create a proper one. Or fork the project you use, but I'm not sure which file do you use.

Also, note that even the old standard Scheme doesn't work right:

(car (cons 1 2))
;; ==> 1
(cdr (cons 1 2))

Only the first S-Expression is valid according to GitHub even though they are both correct.

lildude commented 10 months ago

What is the syntax that you use for the highlighting? I can see if I can create a proper one. Or fork the project you use, but I'm not sure which file do you use.

We use the grammar linked in https://github.com/github-linguist/linguist/blob/master/vendor/README.md

Also, note that even the old standard Scheme doesn't work right:

There is an ongoing issue with the upstream highlighting engine which is likely to be coming into play here. We're tracking it publically in https://github.com/github-linguist/linguist/issues/6668