-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow 'else if' construct #378
Comments
Yes, else if would definitely be nice. Once we have type checking we could look into pattern matching like https://ocaml.org/learn/tutorials/data_types_and_matching.html#Pattern-matching-on-datatypes |
Great. |
Task confirmed. |
Looks to me similar to pattern matching in Scala: https://docs.scala-lang.org/tour/pattern-matching.html |
@czerwinskilukasz1 i would like to look into this! |
Hello @markkulube , sounds great! |
If you had any questions, feel free to ask them here (tag me please) or on our Discord channel. |
@czerwinskilukasz1 thank you. A couple questions to help me better navigate through the project. Still at the dawn of contributing to big projects so please bear with me.
|
@markkulube , it's all good and your questions are 100% appropriate! There is a couple of ways you could handle it. Given the solution you proposed, you analyzed the codebase and understood a good chunk of its structure, congrats 🙂 So I propose to:
What do you think? |
Hi Mark, did you have a while to think over the change? |
@czerwinskilukasz1 my deepest apologies. work has been pretty busy for the past couple weeks. the good thing is my current project is MERN stack as well and it's a long weekend for me here. my plan is to work on this issue to completion as of tomorrow and hopefully close this by next Friday at the latest. i will be in touch here with a couple question very very soon. so sorry for the delay! |
@markkulube , hey, thanks for your reply. |
hey @czerwinskilukasz1, thanks. PLEASE DISREGARD
as per your recommendations i made a changes in two files but on running npm run build i get an exception from the first few tests it seems: What would this error indicate: GrammarError: Rule "ElseIf" is not defined.??? PASS build src/hello.ask
PASS build src/hello.ask.formatted.ask src/askscript/parser/askscript.grammar.pegjs
src/askscript/parser/askscript.grammar.pegjs.classes.ts |
@czerwinskilukasz1 there were 8+12=20 more tests after building and testing with my changes....i have not written any tests myself - is this to be expected? Keeping in mind my local master branch is up to date with your master branch: Test Results Before My Changes: Test Results After My Changes: |
This is interesting. Possibly a bug? @mhagmajer wrote the scripts which run tests. Could you take a look? |
And congrats for solving the build issue :) |
@czerwinskilukasz1 thanks, i am a little stuck on constructing an "if else-if else" block in console, I can only get the if statement going: 🦄 ask(if(5), return('yes')) What would the askQL expression involving an else-if clause look like?
|
Ah, OK, so, the first thing is that I pasted in #378 (comment) an example showing how
|
@czerwinskilukasz1 my apologies, my question was unclear. i need help in understanding what exact steps i can take to check if my logic is correct. how can simulate the use case as though I was say in a python shell? something like suppose names[0] = 'charlie' |
@markkulube
Does it answer your question? |
@czerwinskilukasz1 yes it worked, thank you. The following tests were executed in console and the output in bold is what we would expect when comparing integer types. It doesn't look like I broke your build/actual tests. Let me know what you think, and my what could be my possible next steps: ###test 1A ###test 1B ###test 2A ###test 2B test 2Clet len = 500 ###test 3A ###test 3B ###test 3C ###test 3D npm run build npm test |
@markkulube , great to see that it worked. Please submit your PR and mark me as a reviewer. |
Ah, some more nit comments for your tests:
|
@czerwinskilukasz1 thanks for the feedback. Let me get 1 basic test going in the AskQL test suite first, then i will gauge if/which others to include. An exception is thrown after including tests scripts to the control flow tests from folder. Looks like it has to do with formatting but i ran "Format Document" in VSCode using the Prettier plugin. Kinda stuck. src/askscript/tests/04-control-flow/program10d-if_else_if_else_1a.ask: ask { src/askscript/tests/04-control-flow/program10d-if_else_if_else_1a.test.result.ts: export = '1A PASSED'; npm test
Test Suites: 1 failed, 272 passed, 273 total |
@czerwinskilukasz1 @mhagmajer the sooner i get help with the test script, the sooner we can close this PR, and hopefully integrate if-else if-else support to AskQL. should i just submitt a draft PR with the buggy test case for if-else if-else, and maybe you can better help me that way? |
@markkulube yes, I think such PR would be helpful to drive the matter forward 🙂 Thanks for continued interest in solving this issue, it's appreciated 👍 |
@czerwinskilukasz1 @mhagmajer thanks, i really want to see this through especially because i have else-if else-if working in my local env. the draft PR has been raised. both of you should be able to edit. looking for further progress with this. |
Currently we don't have
switch
nor we permitelse if
, becauseelse
expects a block with curly braces.How about we permit
else if
, such as:The text was updated successfully, but these errors were encountered: