compiler construction - Is a function call unary expression or statement or what? -


in general terms, how can call this? don't know if it's statement or unary expression or else. guess it's unary expression because need 1 thing: arguments work, right? think i'm looking compiler-term can't find myself.

a function call function call. separate production rule in formal grammar of language.

the production rule looks like:

function_call := identifier '(' argument_list ')' argument_list := expression ( ',' argument_list )* 

which implies there 1 rule function calls no matter how many arguments.

since function call returns value, whole thing 1 kind of expression. not "unary expression", that's not common different languages. production rules expression this:

expression := literal expression := '(' expression ')' expression := function_call ... 

i oversimplifying bit expression. expression rule falls apart many different levels operator precedence. e.g. argument_list rule contain expression precedence higher comma , rule parenthesis have lowest-precedence expression inside , produce highest-precedence one. that's general idea.

the highest precedence expression in cases called "unary expression", in case function call unary expression. may called else, depends on grammar definition of particular language.

note above applies languages function calls have arbitrary number of arguments. there languages, haskell function calls may have 1 argument (multi-argument functions implemented via currying).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -