Commit 75bbce9e authored by Robert Griesemer's avatar Robert Griesemer

- added language to document .() notation

- propose change to char/string productions: I find this easier to read

SVN=116037
parent a0d5d808
The Go Programming Language The Go Programming Language
---- ----
(March 28, 2008) (April 17, 2008)
This document is an informal specification/proposal for a new systems programming This document is an informal specification/proposal for a new systems programming
language. language.
...@@ -402,15 +402,15 @@ Character and string literals are similar to C except: ...@@ -402,15 +402,15 @@ Character and string literals are similar to C except:
The rules are: The rules are:
char_lit = "'" ( unicode_value | byte_value ) "'" . char_lit = "'" ( utf8_char_no_single_quote | "\" esc_seq ) "'" .
unicode_value = utf8_char | little_u_value | big_u_value | escaped_char .
byte_value = octal_byte_value | hex_byte_value . esc_seq =
octal_byte_value = "\" oct_digit oct_digit oct_digit . "a" | "b" | "f" | "n" | "r" | "t" | "v" | "\" | "'" | "\"" |
hex_byte_value = "\" "x" hex_digit hex_digit . oct_digit oct_digit oct_digit |
little_u_value = "\" "u" hex_digit hex_digit hex_digit hex_digit . "x" hex_digit hex_digit |
big_u_value = "\" "U" hex_digit hex_digit hex_digit hex_digit "u" hex_digit hex_digit hex_digit hex_digit |
hex_digit hex_digit hex_digit hex_digit . "U" hex_digit hex_digit hex_digit hex_digit
escaped_char = "\" ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | "\" | "'" | "\"" ) . hex_digit hex_digit hex_digit hex_digit .
A unicode_value takes one of four forms: A unicode_value takes one of four forms:
...@@ -457,8 +457,8 @@ Double-quoted strings have the usual properties; back-quoted strings ...@@ -457,8 +457,8 @@ Double-quoted strings have the usual properties; back-quoted strings
do not interpret backslashes at all. do not interpret backslashes at all.
string_lit = raw_string_lit | interpreted_string_lit . string_lit = raw_string_lit | interpreted_string_lit .
raw_string_lit = "`" { utf8_char } "`" . raw_string_lit = "`" { utf8_char_no_back_quote } "`" .
interpreted_string_lit = "\"" { unicode_value | byte_value } "\"" . interpreted_string_lit = "\"" { utf8_char_no_double_quote | "\\" esc_seq } "\"" .
A string literal has type 'string'. Its value is constructed by A string literal has type 'string'. Its value is constructed by
taking the byte values formed by the successive elements of the taking the byte values formed by the successive elements of the
...@@ -1078,7 +1078,8 @@ Expression syntax is based on that of C but with fewer precedence levels. ...@@ -1078,7 +1078,8 @@ Expression syntax is based on that of C but with fewer precedence levels.
PrimaryExpr = PrimaryExpr =
identifier | Literal | "(" Expression ")" | "iota" | identifier | Literal | "(" Expression ")" | "iota" |
Call | Conversion | Allocation | Call | Conversion | Allocation |
Expression "[" Expression [ ":" Expression ] "]" | Expression "." identifier . Expression "[" Expression [ ":" Expression ] "]" | Expression "." identifier |
Expression "." "(" Type ")" .
Call = Expression "(" [ ExpressionList ] ")" . Call = Expression "(" [ ExpressionList ] ")" .
Conversion = TypeName "(" [ ExpressionList ] ")" . Conversion = TypeName "(" [ ExpressionList ] ")" .
...@@ -1092,8 +1093,9 @@ Expression syntax is based on that of C but with fewer precedence levels. ...@@ -1092,8 +1093,9 @@ Expression syntax is based on that of C but with fewer precedence levels.
unary_op = "+" | "-" | "!" | "^" | "<" | ">" | "*" | "&" . unary_op = "+" | "-" | "!" | "^" | "<" | ">" | "*" | "&" .
Field selection ('.') binds tightest, followed by indexing ('[]') and then calls and conversions. Field selection and type assertions ('.') bind tightest, followed by indexing ('[]')
The remaining precedence levels are as follows (in increasing precedence order): and then calls and conversions. The remaining precedence levels are as follows
(in increasing precedence order):
Precedence Operator Precedence Operator
1 || 1 ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment