A Brief and Brisk Overview of Compiler Architecture
The language itself is a bit unusual compared to the typical architecture of compilers, which is partly what inspired me to write this article, though this will be discussed further on in the article. Most languages define a word as a grouping of letters and digits, the identifier typically must with a letter (or an underscore), e.g.
Is not valid Go code as it is probably parsed into these tokens:
Most identifiers that we encounter are of the form:
Lexers will also have to deal with other problems, e.g.:
… and before you think about using regular expressions to do this, I would not recommend it! In compilers, a parser will usually take an input of tokens, and produce a tree of some sort.
Source: blog.felixangell.com