Skip to content
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

Add comma as a way to list statements #48

Open
mhagmajer opened this issue Jun 4, 2020 · 6 comments
Open

Add comma as a way to list statements #48

mhagmajer opened this issue Jun 4, 2020 · 6 comments
Labels
AskScript ./src/askscript/** enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed type:syntax related to syntax or syntax sugar

Comments

@mhagmajer
Copy link
Collaborator

mhagmajer commented Jun 4, 2020

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 mhagmajer added bug Something isn't working AskScript ./src/askscript/** labels Jun 4, 2020
@mhagmajer mhagmajer modified the milestones: v1.2, v1.1 Jun 4, 2020
@mhagmajer mhagmajer added good first issue Good for newcomers enhancement New feature or request and removed bug Something isn't working labels Jun 4, 2020
@czerwinskilukasz1 czerwinskilukasz1 changed the title Missing syntax for multiple statements on the same line Add comma as a way to list statements Jun 6, 2020
@czerwinskilukasz1 czerwinskilukasz1 removed this from the v1.1 milestone Jun 17, 2020
@czerwinskilukasz1 czerwinskilukasz1 added type:syntax related to syntax or syntax sugar help wanted Extra attention is needed labels Jul 3, 2020
@ghost
Copy link

ghost commented Oct 2, 2020

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

@mhagmajer
Copy link
Collaborator Author

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

@ghost
Copy link

ghost commented Oct 4, 2020

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.

@czerwinskilukasz1
Copy link
Collaborator

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

@khushboo97
Copy link

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

@hunarjain09
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AskScript ./src/askscript/** enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed type:syntax related to syntax or syntax sugar
Projects
None yet
Development

No branches or pull requests

4 participants