Skip to content

grammar error in function call when missing comma between parameters #46

@willqian

Description

@willqian

update: pull request #47

missing comma when calling test(1 2), and compile ok

int test(int a, int b)
{
  return a + b;  
}

int main()
{
  int result;
  result = test(1 2);
  return 0;
}

patch

  else if (tk == Id) {
    ...
--  while (tk != ')') { expr(Assign); *++e = PSH; ++t; if (tk == ',') next(); }
++  while (tk != ')') { 
++    expr(Assign); *++e = PSH; ++t;
++    if (tk == ',') { next(); if(tk == ')') { printf("%d: error unexpected comma in function call\n", line); exit(-1); }}
++    else if(tk != ')') { printf("%d: error missing comma in function call\n", line); exit(-1); }
++  }
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions