【Compile】Lex and Yacc

Posted by 西维蜀黍 on 2024-06-27, Last Modified on 2024-07-23

Lex

Lex is a computer program that generates lexical analyzers (“scanners” or “lexers”). It is commonly used with the yacc parser generator and is the standard lexical analyzer generator on many Unix and Unix-like systems.

Lex reads an input stream specifying the lexical analyzer and writes source code which implements the lexical analyzer in the C programming language.

Yacc (Yet Another Compiler-Compiler)

Yacc is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser (the part of a compiler that tries to make syntactic sense of the source code) based on a formal grammar, written in a notation similar to Backus–Naur form (BNF).

Reference