askql icon indicating copy to clipboard operation
askql copied to clipboard

Add comma as a way to list statements

Open mhagmajer opened this issue 4 years ago • 6 comments

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)) { }

mhagmajer avatar Jun 04 '20 22:06 mhagmajer

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

ghost avatar Oct 02 '20 13:10 ghost

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

mhagmajer avatar Oct 02 '20 13:10 mhagmajer

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.

ghost avatar Oct 04 '20 16:10 ghost

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).

czerwinskilukasz1 avatar Oct 05 '20 10:10 czerwinskilukasz1

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

khushboo97 avatar Nov 30 '20 17:11 khushboo97

Hello @khushboo97 you can use the playground https://cli.askql.org/

hunarjain09 avatar Dec 04 '20 14:12 hunarjain09