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

Parsing functions with multiple arguments #114

Open
Zelatrix opened this issue Jul 4, 2022 · 2 comments
Open

Parsing functions with multiple arguments #114

Zelatrix opened this issue Jul 4, 2022 · 2 comments

Comments

@Zelatrix
Copy link

Zelatrix commented Jul 4, 2022

I have managed to successfully implement functions with no arguments into my parser and they parser correctly, The way I have it so far also allows me to parse functions with a single argument. But I am not sure how to parse functions with multiple arguments. The code I have for this at the moment is the following:

@self.pg.production('arg : type expr')
 def typed_arg(p):
   return [p[0], p[1]]
     
# Argument list for functions:
# function f(int x) {
#   print(x);
# }

@self.pg.production('arg_list : arg COMMA arg_list')
def arg_list(p):
  return [p[0]] + p[2]

@self.pg.production('arg_list : ')
def empty_args(p):
  return []
@nobodxbodon
Copy link
Contributor

@Zelatrix
Copy link
Author

Zelatrix commented Jul 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants