Skip to content

Commit

Permalink
mini spec: Operators and punctuation; ebnf: Integer literals
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Dec 23, 2024
1 parent 63b7dff commit 3ef5ae9
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions doc/spec-mini.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Go+ Mini Specification
=====

Go+ has a recommended best practice syntax set, which we call the Go+ Mini Specification.It is simple but Turing-complete and can elegantly implement any business requirements.
Go+ has a recommended best practice syntax set, which we call the Go+ Mini Specification. It is simple but Turing-complete and can elegantly implement any business requirements.

## Notation

Expand Down Expand Up @@ -134,14 +134,38 @@ continue for import return var

### Operators and punctuation

TODO
The following character sequences represent [operators](#operators) (including [assignment operators](#assignment-statements)) and punctuation:

```
+ & += &= && == != ( )
- | -= |= || < <= [ ]
* ^ *= ^= <- > >= { }
/ << /= <<= ++ = := , ;
% >> %= >>= -- ! ... . :
&^ &^= ~
```

### Integer literals

An integer literal is a sequence of digits representing an [integer constant](). An optional prefix sets a non-decimal base: 0b or 0B for binary, 0, 0o, or 0O for octal, and 0x or 0X for hexadecimal. A single 0 is considered a decimal zero. In hexadecimal literals, letters a through f and A through F represent values 10 through 15.

For readability, an underscore character _ may appear after a base prefix or between successive digits; such underscores do not change the literal's value.

```go
int_lit = decimal_lit | binary_lit | octal_lit | hex_lit .
decimal_lit = "0" | ( "1""9" ) [ [ "_" ] decimal_digits ] .
binary_lit = "0" ( "b" | "B" ) [ "_" ] binary_digits .
octal_lit = "0" [ "o" | "O" ] [ "_" ] octal_digits .
hex_lit = "0" ( "x" | "X" ) [ "_" ] hex_digits .

decimal_digits = decimal_digit { [ "_" ] decimal_digit } .
binary_digits = binary_digit { [ "_" ] binary_digit } .
octal_digits = octal_digit { [ "_" ] octal_digit } .
hex_digits = hex_digit { [ "_" ] hex_digit } .
```

For example:

```go
42
4_2
Expand Down

0 comments on commit 3ef5ae9

Please sign in to comment.