---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 9 Edition"
java_version: 9
chapter: "Chapter 2. Grammars"
section: "2.2"
heading: "2.2. The Lexical Grammar"
parent: "Chapter 2. Grammars"
source: https://docs.oracle.com/javase/specs/jls/se9/html/jls-2.html#jls-2.2
id: "2.2"
url: https://jvm.obfuscated.software/jls/se9/2.2.html
raw: https://jvm.obfuscated.software/jls/se9/2.2.md
---

# 2.2. The Lexical Grammar

A *lexical grammar* for the Java programming language is given in [§3 (*Lexical Structure*)](3.md). This grammar has as its terminal symbols the characters of the Unicode character set. It defines a set of productions, starting from the goal symbol *Input* ([§3.5](3.5.md)), that describe how sequences of Unicode characters ([§3.1](3.1.md)) are translated into a sequence of input elements ([§3.5](3.5.md)).

These input elements, with white space ([§3.6](3.6.md)) and comments ([§3.7](3.7.md)) discarded, form the terminal symbols for the syntactic grammar for the Java programming language and are called *tokens* ([§3.5](3.5.md)). These tokens are the identifiers ([§3.8](3.8.md)), keywords ([§3.9](3.9.md)), literals ([§3.10](3.10.md)), separators ([§3.11](3.11.md)), and operators ([§3.12](3.12.md)) of the Java programming language.
