Skip to Content
Programming Languages: Concepts and Implementation
book

Programming Languages: Concepts and Implementation

by Saverio Perugini
December 2021
Beginner
840 pages
47h 29m
English
Jones & Bartlett Learning
Content preview from Programming Languages: Concepts and Implementation

3.6 PLY: Python Lex-Yacc

PLY is a parser generator for Python akin to lex and yacc for C. In PLY, tokens are specified using regular expressions and a context-free grammar is specified using a variation of EBNF. The y a c c period y a c c, left parenthesis, right parenthesis. function is used to automatically generate the scanner/parser; it returns an object containing a parsing function. As with yacc, it is up to the programmer to specify the actions to be performed during parsing to build an abstract-syntax representation (Section 9.5).

3.6.1 A Complete Example in PLY

The following is the PLY analog of the lex and yacc specifications from Section 3.5 to generate a parser for the symbolic expression language: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Concepts and Semantics of Programming Languages 1

Concepts and Semantics of Programming Languages 1

Therese Hardin, Mathieu Jaume, Francois Pessaux, Veronique Viguie Donzeau-Gouge
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9781284222739