Dmsp4 V7r1.Pdf (1.02MB)
Total Page:16
File Type:pdf, Size:1020Kb
z/VM Version 7 Release 1 OpenExtensions Advanced Application Programming Tools IBM SC24-6295-00 Note: Before you use this information and the product it supports, read the information in “Notices” on page 135. This edition applies to version 7, release 1, modification 0 of IBM z/VM (product number 5741-A09) and to all subsequent releases and modifications until otherwise indicated in new editions. Last updated: 2018-09-05 © Copyright International Business Machines Corporation 1993, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents List of Tables........................................................................................................vii About this Document............................................................................................ ix Intended Audience......................................................................................................................................ix Conventions Used in This Document.......................................................................................................... ix Case-Sensitivity..................................................................................................................................... ix Typography.............................................................................................................................................ix Where to Find More Information.................................................................................................................ix Links to Other Documents and Websites............................................................................................... x How to Send Your Comments to IBM......................................................................xi Summary of Changes for z/VM OpenExtensions Advanced Application Programming Tools.......................................................................................... xii SC24-6295-00, z/VM Version 7 Release 1................................................................................................xii Chapter 1. Tutorial Using OpenExtensions 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..................................................................................................... 4 Definitions...............................................................................................................................................7 Translations............................................................................................................................................ 7 Declarations............................................................................................................................................8 lex Input for Simple Desk Calculator................................................................................................... 10 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..................................................................................................................... 20 lex Input................................................................................................................................................20 The yacc Bare Grammar.......................................................................................................................21 Expression Trees.................................................................................................................................. 22 Compilation.......................................................................................................................................... 26 Chapter 2. Generating a Lexical Analyzer Using OpenExtensions lex......................29 Introduction to the lex Utility.................................................................................................................... 29 The lex Input Language............................................................................................................................. 29 Language Fundamentals...................................................................................................................... 29 Putting Things Together....................................................................................................................... 31 lex Programs.........................................................................................................................................32 iii 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...............................................................................................................................46 Character Set........................................................................................................................................46 Chapter 3. Generating a Parser Using OpenExtensions yacc.................................