Professional Documents
Culture Documents
Design
ICT023
NCST-CSD - BSCS
Size vs
Speed
Size VS Speed
Size versus speed refers to the trade-off between
the size of the generated lexical analyzer and the
speed at which it operates.
Lexers
A lexer, also known as a scanner, is a program that breaks down
the input source code into a sequence of tokens, which are the
basic building blocks of a program. These tokens can then be
passed on to the next stage of the compilation process, which
typically involves parsing the tokens to build an abstract syntax
tree.
Lexer Generator
A lexer generator is a tool that generates a lexer program
automatically based on a set of rules or regular expressions. The
input to the lexer generator is a description of the tokens in the
language being compiled, along with the regular expressions that
define each token. The output is a lexer program that can be
integrated into the compiler.
import java.util.regex.Matcher;
import java.util.regex.Pattern;