Programming 101 – 5. syntax

Tom Deneire
9 min readOct 5, 2024
Photo by AltumCode on Unsplash

Disclaimer: the Programming 101 series was originally written to be published as a short book. However, since I never got round to finishing it, I’m publishing the chapters here as individual blog posts…

Now that we understand how a programming language goes from being
language to performing actions, it is high time we take a closer look at what these languages look like. As we saw earlier, we use the linguistic word syntax for that. Because this is easier with a particular example in mind, we will take a look at the specification of the Go programming language, which you can find at https://go.dev/ref/spec.

Tokens

You may recall that the lexing step of a compiler involves splitting up
the source code into tokens. These form the vocabulary of a programming language. In Go there are four kinds of tokens.

  1. Identifiers name program entities such as variables and types.
  2. Keywords, like if or break are reserved and may not be used as identifiers.
  3. Operators, such as +or && (Go for AND)
  4. Punctuation, like { or }
  5. Literals, like integers (1) or strings ("hello" )

The following keywords are reserved and may not be used as identifiers.

--

--