Commit 68fb2d04 authored by Rob Pike's avatar Rob Pike

use tabs for indentation consistently

R=gri
OCL=14125
CL=14125
parent f97832e4
......@@ -288,7 +288,8 @@ Digits and Letters
oct_digit = { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" } .
dec_digit = { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" } .
hex_digit = { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" |
hex_digit =
{ "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" |
"A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F" } .
letter = "A" | "a" | ... "Z" | "z" | "_" | non_ascii .
......@@ -421,13 +422,11 @@ point value that is constrained only upon assignment.
sign = "+" | "-" .
int_lit = [ sign ] unsigned_int_lit .
unsigned_int_lit = decimal_int_lit | octal_int_lit | hex_int_lit .
decimal_int_lit = ( "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" )
{ dec_digit } .
decimal_int_lit = ( "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ) { dec_digit } .
octal_int_lit = "0" { oct_digit } .
hex_int_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } .
float_lit = [ sign ] ( fractional_lit | exponential_lit ) .
fractional_lit = { dec_digit } ( dec_digit "." | "." dec_digit )
{ dec_digit } [ exponent ] .
fractional_lit = { dec_digit } ( dec_digit "." | "." dec_digit ) { dec_digit } [ exponent ] .
exponential_lit = dec_digit { dec_digit } exponent .
exponent = ( "e" | "E" ) [ sign ] dec_digit { dec_digit } .
......@@ -444,20 +443,27 @@ The string type represents the set of string values (strings).
Strings behave like arrays of bytes, with the following properties:
- They are immutable: after creation, it is not possible to change the
contents of a string.
contents of a string.
- No internal pointers: it is illegal to create a pointer to an inner
element of a string.
element of a string.
- They can be indexed: given string "s1", "s1[i]" is a byte value.
- They can be concatenated: given strings "s1" and "s2", "s1 + s2" is a value
combining the elements of "s1" and "s2" in sequence.
combining the elements of "s1" and "s2" in sequence.
- Known length: the length of a string "s1" can be obtained by the function/
operator "len(s1)". The length of a string is the number of bytes within.
Unlike in C, there is no terminal NUL byte.
operator "len(s1)". The length of a string is the number of bytes within.
Unlike in C, there is no terminal NUL byte.
- Creation 1: a string can be created from an integer value by a conversion;
the result is a string containing the UTF-8 encoding of that code point.
"string('x')" yields "x"; "string(0x1234)" yields the equivalent of "\u1234"
the result is a string containing the UTF-8 encoding of that code point.
"string('x')" yields "x"; "string(0x1234)" yields the equivalent of "\u1234"
- Creation 2: a string can by created from an array of integer values (maybe
just array of bytes) by a conversion
just array of bytes) by a conversion:
a [3]byte; a[0] = 'a'; a[1] = 'b'; a[2] = 'c'; string(a) == "abc";
......@@ -480,7 +486,8 @@ This section is precise but can be skipped on first reading. The rules are:
octal_byte_value = "\" oct_digit oct_digit oct_digit .
hex_byte_value = "\" "x" hex_digit hex_digit .
little_u_value = "\" "u" hex_digit hex_digit hex_digit hex_digit .
big_u_value = "\" "U" hex_digit hex_digit hex_digit hex_digit
big_u_value =
"\" "U" hex_digit hex_digit hex_digit hex_digit
hex_digit hex_digit hex_digit hex_digit .
escaped_char = "\" ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | "\" | "'" | """ ) .
......@@ -589,7 +596,8 @@ with the static type of the variable.
Types may be composed from other types by assembling arrays, maps,
channels, structures, and functions. They are called composite types.
Type = TypeName | ArrayType | ChannelType | InterfaceType |
Type =
TypeName | ArrayType | ChannelType | InterfaceType |
FunctionType | MapType | StructType | PointerType .
TypeName = QualifiedIdent.
......@@ -1294,8 +1302,8 @@ Expression syntax is based on that of C but with fewer precedence levels.
Expression "." identifier | Expression "." "(" Type ")" .
Call = Expression "(" [ ExpressionList ] ")" .
Conversion = "convert" "(" Type [ "," ExpressionList ] ")" |
ConversionType "(" [ ExpressionList ] ")" .
Conversion =
"convert" "(" Type [ "," ExpressionList ] ")" | ConversionType "(" [ ExpressionList ] ")" .
ConversionType = TypeName | ArrayType | MapType | StructType | InterfaceType .
Allocation = "new" "(" Type [ "," ExpressionList ] ")" .
Index = SimpleIndex | Slice .
......
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