askql
askql copied to clipboard
Add comma as a way to list statements
All these cause syntax errors:
Example 1
ask { 1, 2 }
// returns 2
Example 2
ask {
1, 2
}
// returns 2
Example 3
for(let i = 0; i < arr:size; i = i + 1, sum = sum + arr:at(i)) { }
Hello, I want to contribute to these issue. Can you please guide me and specify in which files I have to make this change? @mhagmajer
Hello @hunarjain! The parser definitions are stored in https://github.com/xFAANG/askql/tree/master/src/askscript/parser. @czerwinskilukasz1 is the owner of that part of the codebase
Hello @czerwinskilukasz1 I am really interested in resolving this issue can you please guide me as to what type of changes I have to make in the parser files mentioned by @mhagmajer.
Hello @hunarjain , I am very happy you volunteer to do this task - it would be a useful syntax structure. You will need to edit a grammar file (https://github.com/xFAANG/askql/blob/master/src/askscript/parser/askscript.grammar.pegjs) to: step 1) make pegjs accept expression with a comma-separated list of statements. I would try adding a new definition to nonArithmNoMethodsExpression . Please read more about PegJS if needed from their site: https://pegjs.org/
step 2) write appropriate code in https://github.com/xFAANG/askql/blob/master/src/askscript/parser/askscript.grammar.pegjs.classes.ts, which will handle this and translate to mhagmajer's structures - please consult with him what's the most convenient way. Likely you will produce a code block for the comma-separated list of statements (and the last one will be treated as a return value for the whole block just out-of-the-box).
Hello @czerwinskilukasz1 , Please help me by guiding how to run the above mentioned file on my system to check errors and debug them. I am trying for first time so if you could guide me, it would be a great help to get a start.
Thanks
Hello @khushboo97 you can use the playground https://cli.askql.org/