
z/OS Version 2 Release 3 UNIX System Services Programming Tools IBM SA23-2282-30 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 3 of z/OS (5650-ZOS) and to all subsequent releases and modifications until otherwise indicated in new editions. Last updated: 2019-02-16 © Copyright International Business Machines Corporation 1996, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents List of 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...........................................................................................xiv Summary of changes for z/OS UNIX for Version 2 Release 3 (V2R3)...................................................... xiv Summary of changes for z/OS UNIX for Version 2 Release 2 (V2R2)...................................................... xiv Summary of changes................................................................................................................................. xiv z/OS Version 2 Release 1 summary of changes....................................................................................... xiv 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/yacc applications using Enhanced ASCII support................................................................. 28 Chapter 2. Generating a lexical analyzer using lex................................................ 29 Introduction to the lex utility.....................................................................................................................29 The lex input language...............................................................................................................................29 Language fundamentals.......................................................................................................................29 iii 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 Pages304 Page
-
File Size-