Softer level boundaries #774
Felienne
started this conversation in
Large Projects & Plans
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One of the issues code to Hedy of course is that kids mix levels. We see this both in the data analysis of saved programs and in observations with kids.
The initial strategy (when Hedy and Hedy programs were really small) was to take the whole program back a level when a transpile error was detected, a process we dubbed "fall back transpilation". However, kids usually don't consistently make mistakes, but forget one quote or one variable name before an ask.
So, a better strategy would be to merge grammars from multiple levels, keeping both the old and the new production rule alive. We already have some of the infrastructure to combine grammars. I think it should be possible to create multiple rules in the merging process and then parse code based on all the rules.
F.e. let's consider
ask
Level 1 ask is:
ask: _ASK (_SPACE text)?
Level 2 ask is:
ask: var _SPACE _IS _SPACE _ASK _SPACE + (_SPACE | text | punctuation)*
We could create a rule ask_1 and ask_2 based on this and add both to the grammar. If ask_1 is used, in ConvertToPython we throw a HedyException that a certain line uses level 1 code. Or... we could transform it even in some cases!
Questions are whether this would make parsing a lot slower? Whether we'd get too much ambiguity?
Another question is whether this is really needed for all rules, and thus to be done upon merging, or would be better first implemented manually for a few rules. The ask example commonly leads to errors but that is not true for all new rules. Some are already well covered in other ways. For example, forgetting quotation marks already gives a nice warning, which is not level based per see, it does not say: "you use level 2 code" it just tells you that you forgot quotes.
Beta Was this translation helpful? Give feedback.
All reactions