google / google/codeworld

Auto-fit syntax to the grammar before building

Offen
#890 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
discussion
Vorherrschende Sprache
Haskell
Sterne
1.3k
Forks
201
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

One of the advantages of block-based languages is that there are no (or few?) syntax errors. Can we get somewhere close to this in CodeWorld?

The following clip from Desmos shows how, when parentheses are unbalanced, Desmos inserts the close-parentheses that are missing in a grayed-out font, and interprets the expression as if they were already there.

![9772171e-ff49-44db-bac7-557738d97222](https://user-images.githubusercontent.com/544744/55412831-204ca680-5536-11e9-80ae-fe6283d42e93.gif)

If you disagree with the automatic choices, then sure, you can go type the extra parentheses where they belong. But if you leave them out, it doesn't interfere with running the program.

At one point, I'd enabled CodeMirror's feature where typing the open parenthesis automatically added a close-parenthesis to the document; that did not work very well at all! So I believe it's important that these parentheses are phantoms, which don't exist in the document, but rather are only shown in gray and added at build time. They only remain so long as they are needed to make the syntax correct, and they go away on their own when an explicit close-parenthesis is typed.

Parentheses are just one kind of syntax error Taking this further, one could imagine other tweaks that could be added on this basis to programs which are otherwise syntax errors. The rules are the same: the fix is transient, not stored in the source code, but applied on the fly before building. The changes are only made if the original code is not syntactically correct. When actual code changes are made, the on-the-fly fixes are recalculated from the new code, so anything that was applied before goes away.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Das Issue nennt keine Dateien, Tests oder Einstiegspunkte; beginne damit, die Editor-Integration und den Build-Pfad zu lokalisieren, der ungültigen Quelltext vor der Kompilierung transformieren könnte. Vergleiche das gewünschte vorübergehende Verhalten grauer Klammern mit dem bestehenden Editor- und Compiler-Ablauf und definiere anschließend Tests für die Darstellung, die Neuberechnung nach Änderungen und erfolgreiche Builds.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
haskell
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.