You have no ambiguity. The fact that the Go standard analyzer is LALR (1) proves that.
Is this the name of a type or variable name with a large number of variables?
Thus, basically your grammar and the parser as a whole should be completely disconnected from the character table; not C - your grammar is not ambiguous, so you can check the type name later in AST.
These are relevant rules (from http://golang.org/ref/spec ); they are already correct.
Parameters = "(" [ ParameterList [ "," ] ] ")" . ParameterList = ParameterDecl { "," ParameterDecl } . ParameterDecl = [ IdentifierList ] [ "..." ] Type . IdentifierList = identifier { "," identifier } .
I will explain them to you:
IdentifierList = identifier { "," identifier } .
Curly braces represent the closure of kleene (in the designation of regular expressions POSIX it is an asterisk). This rule states "identifier name, optionally followed by a literal comma and identifier, optionally followed by a literal comma and identifier, etc. & Hellip; ad infinitum"
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
The square brackets are null; this means that this part may be present or absent. (In the notation for regular expressions, POSIX is a question mark). So you have a βMaybe List ID,β followed by, possibly, an ellipsis, followed by a type.
ParameterList = ParameterDecl { "," ParameterDecl } .
You can have several ParameterDecl in the list, for example, for example. func x(a, b int, c, d string) .
Parameters = "(" [ ParameterList [ "," ] ] ")" .
These rules determine that the ParameterList parameter is optional and must be surrounded by a bracket and may include an optional final comma literal, useful when you write something like:
func x( a, b int, c, d string,
Grammar Go is portable and can be analyzed by any analyzer from the bottom up with one lookahead marker.
Change in relation to βnot be Cβ: I said this because C is context-sensitive and the way to solve this problem in many (all?) Compilers is to put the character table in the lexer and tokens differently depending on whether they are defined as type names or variables. This is a hack and should not be done for unambiguous grammars!