UNIX: A History and Memoir by Brian W Kernighan
Author:Brian W Kernighan
Language: eng
Format: epub
Published: 2019-12-10T16:00:00+00:00
5.2 Yacc, Lex, Make
We use language to communicate, and better languages help us to communicate more effectively. This is especially true of the artificial languages that we use to communicate with computers. A good language lowers the barrier between what we want to say (“just do it”) and what we have to say to get some job done. A great deal of research in computing is concerned with how to create expressive languages.
Seventh edition Unix offered a diversity of language-based tools, some rather unconventional. I think it’s fair to say that the majority of those languages would not exist had it not been for tools, especially Yacc, that made it easy for non-experts to create new languages. This section describes the language-building tools. The overall message is that Unix tools facilitated the creation of new languages and thus led to better ways to communicate with computers. You can safely skip the details, but the message is important.
Computer languages are characterized by two main aspects, syntax and semantics. Syntax describes the grammar: what the language looks like, what’s grammatically legal and what’s not. The syntax defines the rules for how statements and functions are written, what the arithmetic and logical operators are, how they are combined into expressions, what names are legal, what words are reserved, how literal strings and numbers are expressed, how programs are formatted, and so on.
Semantics is the meaning that is ascribed to legal syntax: what does a legal construction mean or do. For the area computation program in Chapter 2, which is repeated here:
void main() {
float length, width, area; scanf("%f %f", ^length, &width); area = length * width; printf("area = %f\n", area);
}
the semantics say that when the function main is called, it will call the function scanf to read two data values from the standard input, compute the area, and call printf to print area =, the area and a newline character (\n).
A compiler is a program that translates something written in one language into something semantically equivalent in another language. For example, compilers for high-level languages like C and Fortran might translate into assembly language for a particular kind of computer; some compilers translate from other languages, such as Ratfor into Fortran.
The first part of the compilation process is to parse the program, that is, to determine its syntactic structure by recognizing names, constants, function definitions, control flow, expressions, and the like, so that subsequent processing can attach suitable semantics.
Today, writing a parser for a programming language is well-understood technology, but in the early 1970s it was an active research area, focused on creating programs that would convert the grammar rules of a language into an efficient parser for programs written in that language. Such parser-generator programs were also known as “compiler-compilers,” since they made it possible to generate the parser for a compiler mechanically. Typically they created a parser and also provided a way to execute code when particular grammar constructs were encountered during parsing.
Yacc
In 1973, Steve Johnson (Figure 5.1), with language-theory help from A1 Aho, created a compiler-compiler that he called YACC (henceforth Yacc).
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Filmora Efficient Editing by Alexander Zacharias(5758)
The Infinite Retina by Robert Scoble Irena Cronin(5228)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3961)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Edit Like a Pro with iMovie by Regit(3408)
Linux Administration Best Practices by Scott Alan Miller(2858)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2835)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2520)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2385)
Docker on Windows by Stoneman Elton(2317)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2312)
Creative Projects for Rust Programmers by Carlo Milanesi(2231)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2107)
Hands-On Linux for Architects by Denis Salamanca(2051)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(2004)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
The Old New Thing by Raymond Chen(1940)
Linux Kernel Debugging by Kaiwan N Billimoria(1762)
