z/OS Version 2 Release 4 UNIX System Services Programming Tools IBM SA23-2282-40 Note Before using this information and the product it supports, read the information in “Notices” on page 275. This edition applies to Version 2 Release 4 of z/OS (5650-ZOS) and to all subsequent releases and modifications until otherwise indicated in new editions. Last updated: 2019-07-10 © Copyright International Business Machines Corporation 1996, 2019. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Tables.................................................................................................................. ix About this document.............................................................................................xi Who should use this document...................................................................................................................xi How to use this document.......................................................................................................................... xi z/OS information..........................................................................................................................................xi Discussion list........................................................................................................................................ xi How to send your comments to IBM.....................................................................xiii If you have a technical problem................................................................................................................xiii Summary of changes............................................................................................xv Summary of changes for z/OS UNIX System Services Programming Tools for Version 2 Release 4 (V2R4)....................................................................................................................................................xv Summary of changes for z/OS UNIX for Version 2 Release 3 (V2R3)....................................................... xv Summary of changes for z/OS UNIX for Version 2 Release 2 (V2R2)....................................................... xv Chapter 1. Tutorial on using lex and yacc................................................................1 Uses for the lex and yacc utilities................................................................................................................ 1 Code produced by lex and yacc................................................................................................................... 1 lex output................................................................................................................................................2 yacc output............................................................................................................................................. 2 Defining tokens.......................................................................................................................................2 Calling the code...................................................................................................................................... 3 Using the lex and yacc commands.........................................................................................................3 Tokenizing with lex.......................................................................................................................................3 Characters and regular expressions...................................................................................................... 3 Definitions...............................................................................................................................................7 Translations............................................................................................................................................ 7 Declarations............................................................................................................................................8 lex input for simple desk calculator.......................................................................................................9 yacc grammars...........................................................................................................................................10 The declarations section......................................................................................................................10 The grammar rules section.................................................................................................................. 12 The functions section........................................................................................................................... 14 The simple desk calculator.................................................................................................................. 14 Error handling.............................................................................................................................................15 Error handling in lex............................................................................................................................. 15 lex input for the improved desk calculator..........................................................................................16 Error handling in yacc...........................................................................................................................17 A sophisticated example........................................................................................................................... 19 Multiple values for yylval......................................................................................................................19 lex input................................................................................................................................................ 20 The bare grammar................................................................................................................................21 Expression trees...................................................................................................................................22 Compilation.......................................................................................................................................... 26 Writing lex and yacc applications using Enhanced ASCII support...........................................................28 Chapter 2. Generating a lexical analyzer using lex................................................ 29 iii Introduction to the lex utility.....................................................................................................................29 The lex input language...............................................................................................................................29 Language fundamentals.......................................................................................................................29 Putting things together.........................................................................................................................31 lex programs.........................................................................................................................................32 Definitions.............................................................................................................................................33 Translations.......................................................................................................................................... 34 Declarations..........................................................................................................................................35 Using lex.....................................................................................................................................................35 Using yylex()......................................................................................................................................... 35 Generating a table file.......................................................................................................................... 36 Compiling the table file........................................................................................................................ 37 The lex library routines.........................................................................................................................37 Error detection and recovery.....................................................................................................................40 Ambiguity and lookahead.......................................................................................................................... 41 Lookahead............................................................................................................................................ 42 Left context sensitivity and start conditions........................................................................................43 Tracing a lex program...........................................................................................................................44 The REJECT action..............................................................................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages306 Page
-
File Size-