A lexical token is a sequence of characters that can be treated as a unit in the grammar of the programming languages.
Example of tokens:
Table of Contents
-
- Type token
- id, number, real, . . .
- Punctuation tokens
- if, void, return, . . .
- Alphabetic tokens
- keywords
- Type token
Below are the types of lexical tokens in Verilog,
- Whitespace
- Comments
- Operator
- Number
- String
- Identifier
- Keyword
White Spaces
What is whitespace?
Whitespace is any string of text composed only of spaces, tabs, or line breaks.
The following is a commented Whitespace program, where each Space, Tab, or Linefeed character is preceded by the identifying comment “S”, “T”, or “L”, respectively:
S S T S T S S L
T L
S S S ST T S S T S T L
T L
S S T T S T T L
T L
S S L
L
Comments
A comment is a programmer-readable explanation or annotation in the source code. They are added to make the source code easier for humans to understand, and are generally ignored by compilers and interpreters.
Syntax of Verilog comments,
The Verilog HDL has two forms to introduce comments.
- A one-line comment shall start with the two characters // and end with a newline
- A block comment shall start with /* and end with */
Operators
Operators are symbols that tell the compiler to perform specific mathematical or logical manipulations. Below are the different categories of operators, details of each will be described in later sections.
1. Arithmetic
2. Relational
3. Bitwise
4. Logical
5. Assignment
6. Increment
7. Miscellaneous