| OCR Text |
Show «HSf« 54 example "' combining the above three sections to form a recognizer for arithmatlc expressions'' ' metas *- (aexp, term, factor, primary, aop, mop); terms*- ("(",")", ("f'VW). mop^-C'*","/"," "), aop*-("+"," ")); syntax^- ( ■ --v start: atoms: atom t prim: fact: term: aexp: & 1 , scan >££ atoms , "(" | , scan ,£o atoms , aop j , scan ,jjo atom 1 , j primary *- ident Idt , scan ,go prim , | primary ♦" num nm , scan ,go prim , err'- | factoro-factor "f" primary & opr ,go fact , |factor *- primary A ,go fact , 1 factor "t" scan ,go atoms , j term*- term mop factor & opr ,go term , |term *~ factor b. ,go term , I term mop . scan ,go atoms. 1 aexp ♦-aexp aop term A opr , scan ,£0 aexp , j aexp ♦- aop term A unsum , ••S2 aexp ' jaexp 4- term A, 1 '££ aexp ' j aexp aop 1 scan .go atoms , j primary*- "(" aexp ")" 1 scan ,go prim , 1 aexp ft .jgo halt , trr2 Notice the similarity between the above and the p base structure definition for arithmetic expressions:''' <aexp>:: = 4iexp]> <äop> <;term"> lUaopi ^term> t ^term^ < term>:: = <term> <mop> ifactor> I ^.factor^ ^factor>:: = <factor>t^primary> I. ^factor^ <pritnary>:;- ident ( num ) ((aexp>) <aop,>::= +|- <mop>::= *\l |-^ |