-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make parser feedback easier to understand
* add en-informal and de-informal localization * replace expected token types with token values in parser errors * move keywords to localization data * fix parser ignoring trailing asterisc statements * move Exception class out of localization
- Loading branch information
Showing
20 changed files
with
438 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Kids friendly German localization variables. | ||
* Enable by setting locale: "de-informal" in config.js. | ||
*/ | ||
config({ | ||
simulation: { | ||
run: "Los!", | ||
}, | ||
error: { | ||
parser: { | ||
token_read: | ||
"Ich verstehe nicht, was du in Zeile {line} meinst.", | ||
unexpected_eof: | ||
"Das Programm sollte noch weitergehen.", | ||
unexpected_eof_instead: | ||
"Das Programm sollte noch weitergehen. Als nächstes würde ich {expected} schreiben.", | ||
unexpected_token: | ||
"Ich verstehe nicht, was du mit '{value}' in Zeile {line} meinst.", | ||
unexpected_token_instead: | ||
"Ich verstehe nicht, was was du in Zeile {line} meinst. Du hast '{value}' geschrieben, aber ich habe {expected} erwartet.", | ||
nested_program_definition: | ||
"Ein Programm darf nicht in einem anderen Block stehen.", | ||
nested_routine_definition: | ||
"Eine Anweisung darf nicht in einem anderen Block stehen.", | ||
}, | ||
runtime: { | ||
undefined: "Den Befehl '{identifier}' kenne ich nicht.", | ||
}, | ||
world: { | ||
move_out_of_world: "Ich kann nicht über den Rand meiner Welt laufen.", | ||
jump_too_high: "So hoch kann ich nicht springen.", | ||
move_cuboid: "Auf einen Quader kann ich mich nicht stellen.", | ||
action_out_of_world: "Ich kann Ziegel nicht aus meiner Welt hinauswerfen.", | ||
action_cuboid: "Auf einen Quader kann ich keine Ziegel legen.", | ||
action_too_high: "Ich kann nicht höher stapeln.", | ||
action_no_blocks: "Hier gibt es keine Ziegel zum aufheben.", | ||
action_already_marked: "Das Feld ist schon markiert.", | ||
action_no_mark: "Hier gibt es keine Markierung zum löschen.", | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Kids friendly English localization variables. | ||
* Enable by setting locale: "de" in config.js. | ||
*/ | ||
config({ | ||
simulation: { | ||
run: "Go!", | ||
}, | ||
error: { | ||
parser: { | ||
token_read: | ||
"I don't understand what you mean on line {line}.", | ||
unexpected_eof: | ||
"The program isn't finished yet.", | ||
unexpected_eof_instead: | ||
"The program isn't finished yet. Next I'd write {expected}.", | ||
unexpected_token: | ||
"I don't understand what you mean by '{value}' on line {line}.", | ||
unexpected_token_instead: | ||
"I don't understand what you mean on line {line}. You wrote '{value}', but I was expecting {expected}.", | ||
nested_program_definition: | ||
"A Programm can't be inside another block.", | ||
nested_routine_definition: | ||
"A Routine can't be inside another block.", | ||
}, | ||
runtime: { | ||
undefined: "I don't know the command '{identifier}'.", | ||
}, | ||
world: { | ||
move_out_of_world: "I can't walk over the edge of my world.", | ||
jump_too_high: "I can't jump that high.", | ||
move_cuboid: "I can't stand on a cuboid.", | ||
action_out_of_world: "I can't throw bricks out of my world.", | ||
action_cuboid: "I can't place bricks on top of a cuboid.", | ||
action_too_high: "I can't stack any higher.", | ||
action_no_blocks: "There are no bricks here to pick up.", | ||
action_already_marked: "This field is already marked.", | ||
action_no_mark: "There is no mark here to remove.", | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Errors for our simulated programming language and runtime. | ||
* These do not inherit from JS's own Error as they do not need | ||
* to reveal details of the interpreter/runtime internals. | ||
*/ | ||
export class Exception { | ||
message: string | ||
data: any[] | ||
constructor(message: string, ...data: any[]) { | ||
this.message = message | ||
this.data = data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.