![]() ![]() A progressive series of examples leads eventually to the development of a simple desktop calculator that can assign values to variables and evaluate a range of arithmetic expressions. In a similar vein, chapter 3, “Using Yacc,” covers the use of yacc in more detail. ![]() Again, exercises are included at its end. The chapter concludes with some simple exercises.Ĭhapter 2, “Using Lex,” covers the use of lex in more detail, using a word-counting program and a C source code analyzer. As explained in the text, yacc is an acronym for “yet another compiler-compiler.” Two simple yacc programs are developed to parse English sentences. The lex examples of chapter 1 are then modified so that they can be called from the yacc parser. The machine on which I tried these examples has an ancient C compiler, and I had to change them slightly to make them acceptable. The examples show how the lex specifications are written as a series of rules for matching tokens each rule has a set of action statements (written in C) that is executed when a match is found. The examples are available without charge through USENET, and the authors provide instructions for obtaining them using the uucp or anonymous ftp facilities.Ĭhapter 1 illustrates the capabilities of the lex lexical analyzer through a couple of examples that classify the words found in a sentence into verbs, adjectives, nouns, and so on. A series of graded examples is presented in each chapter, and the reader is encouraged to implement and develop an understanding of these as she or he moves through the book. It assumes a working knowledge of the C programming language. This book is intended for those who need to develop assemblers, compilers, menu generators, syntax checkers, and related utilities. A new chapter addresses parsing SQL statements, and some new appendices cover versions of lex and yacc for MS-DOS, OS/2, and other systems. ![]() John Levine has joined the original authors to produce a useful programmer's guide that reflects some of those developments. A number of developments in programming methodologies, standards, and hardware platforms have occurred since that time. The YACC specification is processed as follows (files y.tab.h, needed by the Flex-generated code, and y.tab.The first edition of this book, written by Mason and Brown, was published in 1990. ![]() The Flex specification is processed as follows (the file lex.yy.c is produced): Token BATATA is not recognized by the lexical analyzer and is only used to specify the precedence of the unary operators (+ and -) by specifying that the corresponding rules should be reduced with the precedence associated with the token BATATA (the highest in the grammar). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |