3deec521f704dc500a

Upload: veronica-gisca

Post on 07-Aug-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/20/2019 3deec521f704dc500a

    1/18

    S u p p o r t i n g t h e A t t r ib u t e G r a m m a r P r o g r a m m in g

    P a r a d i g m in a L a z y F u n c t io n a l P r o g r a m m i n g

    L a n g u a g e

    R . A . F r o s t a n d S . K a r a m a t o s

    School of Co m pute r Science, Univers i ty of W indsor , O ntar io , Ca na da N 9B 3P4

    Ab st ra ct . Attribute grammars

    w e r e in t r o d u c e d i n th e l a t e

    60's. In the 70's

    they

    f o u n d u s e

    in compiler work, a

    u s e t h a t i s c o n t i n u i n g t o g r o w .

    A more re-

    cent development is that of t h e ' a t t r i b u t e grammar programming paradigm'.

    A number of environments have been built to support this paradigm. W/ AG E

    is one such environment. It consists of several functions that extend the

    standard environment of the pure lazy functional programming language Mi-

    randa. W/ AG E has been used in the construction of various types of program

    including nat ura l language interpreters, database front-ends, file-processors,

    theorem provers, and VLSI specification transformers.

    1 I n t r o d u c t i o n

    O v e r t h e l a s t s e v er a l y e a r s r e se a r c h e r s a t t h e U n i v e r s i t y o f W i n d s o r h a v e b e e n i n -

    v o l v e d i n v a r io u s p r o j e c t s i n v o l v in g t h e i n v e s t i g a t i o n o f n e w t h e o r ie s a n d t e c h n i q u e s

    i n th e a r e a s o f d a t a b a s e m a n a g e m e n t , V L S I d e si gn a n d n a t u r a l l a n g u a g e p r oc e s si n g.

    T h e s e i n v e s t i g a t i o n s h a v e a ll r e q u i re d t h e c o n s t r u c t i o n o f s p e c i a l p u r p o s e l a n g u a g e

    p r o ces s e r s . Th e d e s ig n an d co n s t r u c t i o n o f t h e s e p r o ces s o r s req u i r ed a g o o d d ea l o f

    e f fo r t. I t b e c a m e e v i d e n t t h a t s u b s t a n t i a l r e s o u r c es w e r e b e i n g u s e d f o r t h i s p u r p o s e

    an d th a t t h i s w as h av in g a d e l e t e r io u s e f f ec t o n o u r r e s ea r ch . W e d ec id ed , t h e r e f o r e ,

    t o c o n s t r u c t a p r o g r a m m i n g e n v i ro n m e n t t h a t w o u ld e n a b l e r e se a rc h e rs t o p r o d u c e

    l a n g u a g e p r oc e s so r s w i t h m i n i m u m e f fo rt . T h e e n v i r o n m e n t t h a t w e h a v e b u i lt i s

    c al le d t h e W i n d s or A t t r i b u t e G r a m m a r P r o g r a m m i n g E n v i ro n m e n t W / A G E . T h i s

    e n v i r o n m e n t a l l o w s l a n g u a g e p r o c e s s o r s t o b e c o n s t r u c t e d a s e x e c u t a b l e s p e c i fi c a -

    t i o n s o f t h e s y n t a x a n d s e m a n t i c s o f t h e l a n g u a g e s r e q u ir e d .

    W / A G E w a s i n it i a l ly u s e d in t h e c o n s t r u c t i o n o f n a t u r a l l a n g u a g e i n t e r p r e t e r s ,

    d a t a b a s e f r o n t - e n d s , a n d s p e c i fi c a t io n t r a n s f o r m e r s . S u b s e q u e n tl y , i t w a s r e c o g n is e d

    t h a t o t h e r t y p e s o f p r o g r a m c o u l d b e p r o f it a b l y c o n s t ru c t e d a s l a n g u a g e p ro c e s s o r s

    a n d W / A G E h a s s i nc e b e e n u s e d t o b u il d t h e o r e m p r o ve r s, t re e p r o c es o r s a n d e v e n

    f i le p rocesso r s .

    T h e p u r p o s e o f t h i s p a p e r is t w o fo l d: f i rs t ly t o i n t r o d u c e r e a d e r s t o W / A G E

    a n d s e c o n d l y t o i l l u s t r a t e t h e w i d e a p p l i c a b i l i t y o f t h e t e c h n i q u e o f c o n s t r u c t i n g

    p r o g r a m s a s e x e c u t a b le a t t r i b u t e g r a m m a r s .

    2 A t t r i b u t e G r a m m a r s

    A t t r i b u t e g r a m m a r s w e r e in t r o d u c e d b y K n u t h i n 1 96 81 10 ] a s a m e a n s fo r s p e c i f y in g

    t h e s e m a n t i c s o f c o n t e x t f re e l a n g u a g e s . S in c e t h e n , a t t r i b u t e g r a m m a r s h a v e b e e n

    u s ed ex t en s iv e ly i n co m p i l e r w o r k .

  • 8/20/2019 3deec521f704dc500a

    2/18

    2 7 9

    3 . 1 N o t a t i o n

    U s e d i n t h i s S e c t i o n

    T h e f o ll o w i ng M i r a n d a n o t a t i o n is u s e d i n t h i s s e ct i on :

    x = = y i n t r o d u c e s x a s a n a c r o n y m f o r t h e t y p e n a m e y .

    x : : y d e c l a r e s x t o b e o f t y p e y .

    W h e r e t h e s e t t y p e i s d e f i n e d i n d u c t i v e l y a s f o ll o w s :

    n u m . , c h a r ,

    b o o l 6

    t y p e .

    I f t 6 t y p e t h e n s o i s I t ] ,

    i e. t h e t y p e o f l i s ts w h o s e e l e m e n t s a r e o f t y p e t .

    I f t l . . t n 6 t y p e t h e n s o i s ( t 1 , . . , t n ) ,

    ie . t h e t y p e o f t u p l e s w i t h e l e m e n t s o f t y p e t l t o t n .

    I f t l , t 2 6 t y p e t h e n s o i s t l - > t 2 ,

    ie

    t h e t y p e o f f u n c t i o n s w i t h a r g u m e n t s i n t l a n d r e s u l ts i n t 2 .

    I f y a n d z 6 t y p e t h e n s o i s x

    w h e r e x : : = C 1 y I . . I Cn z a n d C l t o C n a r e

    u s e r d e f i n e d

    c o n s t r u c t o r s

    3 .2 T h e T y p e o f T e r m i n a l s

    T h e t y p e t e r m i n a l i s p r e d e fi n e d i n W / A G E a s f o ll ow s :

    t e r m i n a l

    : : =

    I N T _ T E R M

    [ c h a r ] I R EIL _T EIL ~ [ c h a r ]

    [

    I D E N T I F I E R _ T E R M [ c h a r ]

    I

    SPECIAL_SYMBOL_TEI~I [char]

    [ R E S E R V E D _ W O R D _ T E R M [ c h a r ]

    I

    U N C A T E G O R I S E D _ T E R M [ c h a r ]

    I A N Y _ T E R M [ c h a r ]

    In addition to defining the type t e rm i n a l this introduces s even n e w identifiers:

    I N T _ T E R M , R E A L _ T E R M , e t c. a s c o ns t ru c to r s f or t e rm i na l s. N o t e t h a t e a c h o f t h es e

    c o n s t ru c t o rs i s o f t y p e [ c h a r ] - > t e r m i n a l . W e i n t r o d u c e a n a c r o n y m fo r t h is

    t y p e :

    t e r m i n a l _ c o n s t r u c t o r

    = =

    [ c h a r ]

    - > t e r m i n a l

    3 .3 T h e T y p e o f t h e L e x i c a l S c a n n i n g F u n c t i o n t o k e n i s e

    t o k e n i s e : : s t r in g _ t o _ b e _ p r o c e s s e d - > [ t e r m i n a l ]

    w h e r e

    s t r i n g _ t o _ b e _ p r o c e s s e d = = [ ch ar ]

    3 .4 T h e T y p e o f A t t r i b u t e s

    T h e t y p e a t t r i b u t e i s d e f in e d b y W / A G E u s e rs a c c o r d i n g t o t h e a p p l i c a t i o n . F o r

    e x a m p l e :

    a t t r i b u t e : := LITERAL_VAL e r m i n a l I V A L n t m

    [ O P n u l l - > n u . - > n u m [ P A I R n u m [ c h a r ]

    N o t e t h a t c o n s t r u c t o r s c a n h a v e a n y n u m b e r o f f ie ld s . F o r e x a m p l e , t h e c o n s t r u c t o r

    P A I R h a s t w o f ie l ds . A f i e ld m a y b e a n y M i r a n d a t y p e a s d e f i n e d i n 3. 1. T o a n a l y s e

    a n a t t r i b u t e , w e us e M i r a n d a p a t t e r n m a t c h i n g a s i l lu s t r a t e d la t e r .

  • 8/20/2019 3deec521f704dc500a

    3/18

    2 8 0

    W i t h a l it t l e c h a n ge in p e r s p e c t iv e , m a n y o t h e r t y p e s o f p r o g r a m c a n b e c o n -

    s t r u c t e d a s e x e c u t a b l e a t t r i b u t e g r a m m a r s . W e r e f e r t o s u c h p r o g r a m s a s

    passages

    T h i s s t y l e o f p r o g r a m m i n g w a s f i rs t su g g e s t e d b y K n u t h i n 1 97 11 12 ], a n d s u b s e -

    q u e n t l y d e v e l o p e d b y K a t a y a m a [ 9 ] , t t e h n e r a n d S i l v e r b e r g [ 7 ] , S i m o n [ 1 6 ] , J o h n s -

    s on [8 ], P a n a y i o t o p o u l o s , P a p a k o n s t a n t i n o u , a n d S t a m a t o p o u lo s [ 1 4 ], F o r b i g a n d L a m -

    m e l [ 3] , F ro st[4 ][5 ] an d o th e r s . S e v e r a l en v i r o n m en t s h av e b een b u i l t t o s u p p o r t t h e a t -

    t r ib u t e g r a m m a r p r o g r a m m i n g p a r a di g m ,

    eg

    P L A S T I C [ 16 ], S A G E [ 1 5 ] , A G I L P [ 1 4 ] ,

    F L R [ 3 ] , a n d W / A G E .

    W / A G E c o n si st s o f a s e v er a l f u n c ti o n s t h a t e x t e n d t h e s t a n d a r d e n v i r o n m e n t

    o f t h e p u r e l a z y p r o g r a m m i n g la n g u a g e M i ra n d a[ 17 ] . T h e r e s u lt i n g c o m b i n a t i o n o f

    p r o g r a m m i n g p a r a d i g m s f a c i li t a te s s o f tw a r e d e v e l o p m e n t i n s e ve r al w a y s :

    1. P r o g r a m s a r e c o m p l e t e l y d e c l a r a t i v e , e x t r e m e l y m o d u l a r , a n d a r e la r g e l y v a r i -

    a b l e f re e . T h i s s i m p l if ie s r e a s o n i n g a b o u t t h e m f o r t h e p u r p o s e o f v e ri f ic a t i on ,

    c o m p l e x i t y a n a l y s i s , t r a n s f o r m a t i o n , e t c .

    2. T h e i n d u c t iv e p r o g r a m s t r u c t u re t h a t r e su l ts f ro m t h e c o m b i n e d p a r a d i g m l e n ds

    i t s e l f w e l l t o t h e t e c h n i q u e o f d e r i v i n g ' p r o g r a m s f r o m p r o o f s ' .

    3 . T h e s t r u c t u r e o f a p r o g r a m t h a t i s b u i l t i n t h i s w a y is cl o se l y r e l a t e d t o t h e

    s t r u c t u r e o f t h e d a t a t h a t i t i s t o p r o c es s . T h i s r e s u l t s in c o d e t h a t i s e a s ie r t o

    m a i n t a i n a n d e a s i e r t o m o d i f y .

    T h i s p a p e r w i ll i n t ro d u c e r e a d e rs t o th e a t t r i b u t e g r a m m a r p r o g r a m m i n g p a r a -

    d i g m , s h o w h o w t h i s p a r a d i g m c a n b e r e a d i l y s u p p o r t e d i n a p u r e f u n c t i o n a l p r o -

    g r a m m i n g l a n g u a g e , a n d b r i e fl y d i sc u s s so m e o f t h e a d v a n t a g e s t h a t d e r i v e f r o m t h i s

    a p p r o a c h .

    3 An Overview of W / A GE

    W e u s e th e n o t a t i o n o f t h e M i r a n d a 1 f u n c ti o n a l p r o g r a m m i n g l a n g u a g e t h r o u g h o u t

    t h e p a p e r . W e g i ve br i e f e x p l a n a t i o n o f th i s n o t a t i o n w h e r e a p p r o p r i a t e . R e a d e r s

    w h o a r e u n f a m i l i a r w i t h f u n c t i o n a l n o t a t i o n a r e r e f e r r e d t o T u r n e r [ 1 7 ] .

    W / A G E c u r r e n tl y c o n si st s o f f iv e c o m p o n e n t s :

    A lex ical scann ing func tion : to ke n i ze

    A se t o f func tions fo r app ly ing in te rp re te r s: {ap p ly . . r eco gn is er ,

    a p p l y _ i n t e r p r e t e r }

    A set of functions for building basic interpreters:

    { l i t e r a l ~ i n t e r p r e t e d ,

    t m i n t e r p r e t e d }

    A set of in terpreter combinators :

    { $ o r e l s e , $ e x c l _ o r e l s e ~

    s t r u c t u r e }

    A func t ion fo r c rea t ing a t t r ibu te l i st s : me an ing-o f

    a Miranda is a t rademark of Research Sof tware Ltd .

  • 8/20/2019 3deec521f704dc500a

    4/18

    281

    3.5 T h e T y p e o f In t e rp re t e r s

    We have chosen to define the type in t e r p r e t e r as follows:

    i n t e r p r e t e r = = [ ( [ a t t r i b u t e ] , [ t e r m i n a l ] ) ] - > [ ( [ a t t r i b u t e ] , [ t e r m i n a l ] ) ]

    That is, an interpreter is a function that maps a list of pairs of type ( [ a t t r i b u t e ] ,

    [ t e na i na l ] ) to a list of pairs of the same type, such that:

    1. Each pair ( a s , t s ) that is in the list that is input to an interpreter is such

    that the list of attributes as may be regarded as a context in which the list of

    terminals ts is to be interpreted.

    2. Each pair ( a s ' ,t s ' ) in the list that is output by an interpreter is related to

    exactly one pair ( a s , t s ) in the input list such that : (i) a s ' is a subset of the

    union of as and the interpretation of some initial segment of ts , and (ii) t s ' is

    the list of remaining uninterpreted terminals in ts .

    3. Interpreters return lists of pairs because each pair in the inpu t may have more

    than one interpretation.

    4. Interpreters are regarded as accepting lists of pairs for a number of reasons, such

    as it simplifies composition.

    3 .6 The Type o f Func t ions fo r Top- leve l Appl ica t ion o f In t e rp r e te r s

    The types of the functions apply-recognizer and apply_interpreter are as fol-

    lows:

    a p p l y _ r e c o g n i z e r : :

    i n t e r p r et e r - > s t r i n g _ t o _ b e _ r e c o g n i z e d - > m e s s a g e

    w h e r e s t r i n g _ t o _ b e _ r e c o g n i z e d = = [ c ha r ]

    me ss ag e =ffi [char ]

    a p p l y _ i n t e r p r e t e r : : i n t e r p r e t e r - > s t r i n g _ t o _ b e _ i n t e r p r e t e d - > [ a t t r i b u t e ]

    w h e r e s t r i n g _ t o _ b e _ i n t e r p r e t e d = ffi [ c h a r ]

    Throughout the paper, we use the notation x => y to indicate that output y is

    returned by the Miranda interpreter when x is evaluated. For example:

    a p p l y _ i n t e r p r e t e r n u m b e r " 1 2 " ffi> [ V A L 1 2]

    3 .7 The Type o f Func t ions fo r Bui ld ing Basic In te rp re te r s

    There are three functions in W/AGE that may be used to build interpreters for

    single terminals:

    l i t e r a l :: t e r m i n a l _ c o n s t r u c t o r - > i n t e r p r e t e r

    u n i n t e r p r e t e d :: t e r m i n a l - > i n t e r p r e t e r

    i n t e r p r e t e d :: ( t e r m in a l , [ a t t r i b ut e ] ) - > i n t e r p r e t e r

  • 8/20/2019 3deec521f704dc500a

    5/18

    282

    3 .8 T h e T y p e o f I n t e r p r e t e r C o m b i n a t o r s

    T h e r e a r e t h r ee f u n c t io n s i n W / A G E t h a t m a y b e u se d t o d ef in e n e w i n t e rp r e t e rs

    i n t e r m s o f o t h e r i n t e r p r e t e r s :

    $ o r e l s e :: i n t e r p r e t e r - > i n t e r p r e t e r - > i n t e r p r e t e r

    S e x c l _ o r e l s e :: i n t e r p r e t e r - > i n t e r p r e t e r - > i n t e r p r e t e r

    s t r u c t u r e

    ::

    l i s t . o f _ t a g g e d _ i n t e r p r e t e r s - > l i s t _ o f _ a t t r i b u t e _ r u l e s

    - > i n t e r p r e t e r

    w h e r e

    l i s t _ o f _ t a g g e d _ i n t e r p r e t e r s = = [ ( ta g , i n t e r p r e t e r ) ]

    l i s t _ o f _ a t t r i b u t e _ r u l e s •ffi [ ( r u l e _ h u m , a t t _ i d , a r t _ f u n c t i o n , [ a t t _ i d ] ) ]

    w h e r e

    a t t _ i d - = ( ( t ag , a r t _ d i r e c t i o n ) , a t t _ t y p e )

    a r t _ f u n c t i o n = = [a t t r i b ut e ] - > a t t r i b u t e

    a r t _ t y p e

    •ffi

    [ c h a r ]

    a t t _ d i r e c t i o n : : = U P ] D O W N

    3 .9 T h e T y p e o f t h e

    m e a n i n g _ o f

    F u n c t i o n

    T h e t y p e o f t h e f u n c t i o n m e a n i n g _ o f i s a s fo ll ow s :

    m e a n i n g _ o f :: i n t e r p r e t e r - > s t r i n g _ t o _ b e _ i n t e r p r e t e d - > [ a tt r i bu t e]

    w h e r e s t r i n g _ t o _ b e _ i n t e r p r e t e d =ffi [ c h a r]

    I n t h e n e x t f ew s e c ti o n s , w e g i v e e x a m p l e s o f v a r i o u s p a s s a g e s t h a t h a v e b e e n b u i l t

    u s i ng W / A G E . A l l o f t h e p a s s a g e s a r e c o m p l e te a n d c a n b e e x e c u te d a s M i r a n d a

    p r o g r a m s j u s t a s t h e y a p p e a r p r o v id e d t h a t t h e W / A G E s c r ip t i s a v a i l ab l e i n th e

    M i r a n d a ' l o c a l ' d ir e c t or y .

    4 L e x i c a l A n a l y s i s

    Passage #1 illustrates how the function tokenise can be tailored for particular

    applicat ions through definition of the reserved words and special symbols.

    [ [ P a s s a g e # 1 :

    ~, in s r r < l o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ I _ R E L E A S E ~ 9 >

    [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : : t y p e

    I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s = [ " b e g in " , " e n d" , " o n e "]

    special_symbols = [ ' ( ' , , )J , , - , , ~/, , ,+, , , -, ]

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    I

    E X A M P L E A P P L I C A T I O N

    t o k e n i s e " 1 2 3 b e g i n s a s d d d a 2 3 4 b 3 . 2 3 . 4 ( f f ~" = >

    [ I N T _ T E R M " 1 2 3 ",

    RESERVED_WORD_TERM

    b e g i n " , I D E N T I F I E R _ T E R M " s as " ,

    I

    I D E N T I F I E R _ T E R M " d dd " , I D E N T I F I E R _ T E R M " a 23 4 ", U N C A T E G O R I S E D _ T E R M " b 3. 2 ",

    I R E A L _ T E R M " 3 .4 " , S P E C I A L _ S Y M B O L _ T E R M " (" , U N C A T E G O R I S E D _ T E R M " f f ~ "]

  • 8/20/2019 3deec521f704dc500a

    6/18

    2 8 3

    5 C o n s t r u c t i n g B a s i c R e c o g n i s e r s a n d I n t e r p r e t e r s

    Passage # 2 illustrates o w the W / A G E functions literal, interpreted, an d un-

    interpreted can b e u s ed to bu i ld bas ic recogn isers and in te rp re te rs , ie . recogn isers

    an d in te rp r e te r s f o r sin g le t e rmin a l s .

    l[ P a s s a g e # 2 :

    Z i n s e r t < I o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ I _ R E L E A S E _ 0 . m >

    I

    a t t r i b u t e : := L I T E R A L _ V A L t e r m i n a l I V A L n u m

    [ E N G L I S H [ c ha r ] [ G E N D E R c h a r

    I

    r e s e r v e d _ w o r d s = [ " b e g i n " , " o ne " ]

    s p e c i a l _ s y m b o l s = [3

    I I

    i n t

    a n y t h i n g

    k e y

    b e g i n

    o n e

    s a l a i r e

    = l i t e r a l I N T _ T E R M

    = l i t e r a l A N Y _ T E R M

    = u n i n t e r p r e t e d ( I D E N T I F I E R _ T E R M a n y )

    = u n i n t e r p r e t e d ( R E S E R V E D _ W O R D _ T E R M " b e g i n " )

    = i n t e r p r e t e d ( R E S E R V E D _ W O R D _ T E R M " o n e " , [ VA L 1 1)

    = i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " s a l a i r e " , [ E N G L I S H " w a ge " ,

    G E N D E R ' m ' ] )

    E X A M P L E A P P L I C A T I O N S

    a p p l y _ r e c o g n i z e r i n t

    a p p l y _ i n t e r p r e t e r i n t

    a p p l y _ i n t e r p r e t e r a n y t h i n g

    a p p l y _ i n t e r p r e t e r k e y

    a p p l y _ i n t e r p r e t e r b e g i n

    a p p l y _ i n t e r p r e t e r b e g i n

    a p p l y _ i n t e r p r e t e r o n e

    ~[ a p p l y _ i n t e r p r e t e r s a l a i r e " s a l a i r e "

    " 64 " = > i n p u t i s r e c o g n i z e d s u c c e s s f u l l y

    " 1 0 6 " = > [ L I T E R A L _ V A L ( I N T _ T E R M " 1 0 6 " )I

    " 3 . 2 1 " = > [ L I T E R A L _ V A L ( R E A L _ T E R M " 3 . 2 1 ") I

    s a s => [1

    "beg in" => [3

    " s a s " = > i n p u t n o t r e c o g n i z e d

    "one" => [VAL 1]

    = > [ E N G L I S H " w a g e " , G E N D E R ' m ']

  • 8/20/2019 3deec521f704dc500a

    7/18

    284

    6 C o n s t r u c t i n g N o n - B a s i c R e c o g n i z e r s

    Passage # 3 illustrates how non-basic recognizers can be built by 'gluing' other recog-

    nisers together using the combinators $orease and $utructure.

    I I

    P a s s a g e # 3 : A r e c o g n i s e r o f a r i t h m e t i c e x p r e s s i o n s

    Z i n s e r t < I o c a l / h e a d e r _ f o r _ N A G E _ V E R S I O N _ I _ R E L E A S E _ O . m >

    JJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r ibute :: = LITERAL_VAL ermin al

    [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s = []

    s p e c i a l _ s y m b o l s = [ ~ ( ' , ~ )~ , ' *' , ' /' , ' +' , ' -' ]

    J ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    op = uninte rprete d

    $orelse

    uninterpreted

    $orelse

    uninterpreted

    n e g at e = u n i n t e r p r e t e d

    o p b r = u n i n t e r p r e t e d

    c l b r = u n i n t e r p r e t e d

    u n i n t e r p r e t e d _ n u m b e r = u n i n t e r p r e t e d

    $ o r e l s e

    uninterpreted

    ( S P E C I A L _ S Y M B O L _ T E R M

    + )

    ( S P E C I A L _ S Y M B O L _ T E R M " * " )

    (SPECIAL_SYMBOL_TERM 1 )

    (SPECIAL_SYMBOL_TERM - " )

    (SPECIAL_SYMBOL_TERM ( )

    (SPECIAL_SYMBOL_TERM ) )

    (INT_TERM any)

    ( R E A L _ T E R M a n y)

    J . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    rec_expr

    = s t r u c t u r e ( sl u n i n t e r p r e t e d _ n u m b e r )

    []

    $ o r e l s e

    s t r u c t u r e ( s l o p b r + + s 2 r e c _ e x p r ++ s3 o p + + s 4 r e c _ e x p r ++ s5 c l b r

    [ ]

    $ o r e l s e

    s t r u c t u r e ( s l n e g a t e + + s 2 r e c _ e z p r )

    [ ]

    EXAHPLE A PPLICATIONS

    a p p l y _ r e c o g n i z e r o p + => i n p u t i s r e c o g n i z e d s u c c e s s f u l l y

    a p p l y _ r e c o g n i z e r r e c _ e x p r ( 1 2 + 4 5 ) => i n p u t i s r e c o g n i z e d s u c c e s s f u l l y

    a p p l y _ r e c o g n i z e r r e c _ e x p r 1 2 + 5 => e nd o f i n p u t n o t r e c o g n i z e d

    ie

    [ S P E C I A L _ S Y M B O L _ T E R M " + " , I N T _ T E R M " 5" ]

    a p p l y _ r e c o g n i z e r r e c _ e z p r " ( 1 2 + 45 ) + 3 "

    = > e n d o f i n p u t n o t r e c o g n i z e d

    i e [ S P E C I A L _ S T M B O L _ T E R M " + " , I N T _ T E R M " 3" ]

    a p p l y _ r e c o g n i z e r r e c _ e x p r " ( ( o n e + 4 5 ) + 3 ) " = > i n p u t n o t r e c o g n i z e d

    Notice that the lists of attribute rules in the definition of rec_expr are empty.

    This is because rec_expr is a recognizer and not an interpreter, therefore no at-

    tributes are to be computed.

  • 8/20/2019 3deec521f704dc500a

    8/18

    2 8 5

    7

    Constructing Non-Basic Interpreters

    Passage # 4 illustrates how non-basic interpreters can be built by 'gluing' other

    interpreters together us ing the combinators orelse and s t ructure.

    {{ P a s s a g e # 4: A n a r i t h m e t i c e v a l u a t o r

    ~ i n s e r t < I o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ I _ R E L E A S E _ O . m >

    ~ i n s e r t < l o c a l / n u m b e r _ i n t e r p e t e r _ f o r _ W A O E _ V E R S I O N _ l _ R E L E A S E _ O . m >

    [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : := L I T E R A L _ V A L t e r m i n a l { V A L h U m ] O P n u m - > n u m - >

    n u m

    ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ . o r d s = []

    s p e c i a l _ s y m b o l s = [ '( ', ' ) ' , ' * ' , ' / ' , ' + ' , ' - ' ]

    [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    op = i n t e r p r e t e d (SPECIAL_SYMBOL_TERM + ,[OP (+)])

    $ore l se

    i n t e r p r e t e d (SPECIAL_SYMBOL_TERM * , [OP (* )] )

    $ore l se

    i n t e r p r e t e d (SPECIAL_SYMBOL_TERM / , [0P ( / ) ] )

    negop = un i n t e r p r e t ed (SPECIAL_SYMBOL_TERM - )

    opbr = un i n t e r p r e t ed (SPECIAL_SYMBOL_TERM ( )

    c lb r = un i n t e r p re t ed (SPECIAL_SYMBOL_TERM ) )

    I I

    expr = structure (s l number)

    [c _r ul e 1 (VAL $u lh s) EQ (VAL $u s l ) ]

    $ore l se

    structure (sl opbr ++ s2 expr ++ s3 op ++ s4 expr ++ s5 clbr)

    [ a _ r u l e 2 ( V A L S u l h s ) E Q a p p l y _ o p [ V A L $ u s 2 , 0 P $ u s 3 , V l L S u s 4 ]]

    $ore l se

    structure (sl negop ++ s2 expr)

    [ a _ r u l e 3 ( V A L S u l h s) E Q n e g a t e [ V A L $ u s 2 ]]

    appl y_op [VAL x, 0P y, VAL z] = VAL (y x z)

    neg ate [VAL x] = VAL (- x)

    {{ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .

    I I EXAMPLE

    A P P L I C A T I O N S

    II

    11

    ap pl y_ in te rp re te r expr (12 + 4.5 ) => [VAL 16.5]

    [[ ap pl y_ in te rp re te r expr ((4 + (4 * 3) )/ -2 ) => [VAL (-8. 0)]

    The sy ntax used for the att rib ute rules is a variant of stan dard BNF notat ion.

    The following provides an in formal semantics for our notatio n:

  • 8/20/2019 3deec521f704dc500a

    9/18

    286

    v $ u s s t a n d s f o r t h e s y n t h e s i z e d v a t t r i b u t e p a s s e d

    up

    b y t h e s t r u c t u r e s

    v S d e s t a n d s f o r t h e i n h e r i t e d v a t t r i b u t e p a s s e d down

    t o t h e s t r u c t u r e s

    c _ r u l e n x EQ y i n d i c a t e s t h a t th e a t t r i b u t e x i s t o b e

    cop i ed

    f r o m t h e a t t r i b u t e y

    a . x u l e n x E Q f I i n d i c a t e s t h a t t h e a t t r i b u t e x i s o b t a i n e d b y

    a p p l y i n g

    t h e a t t r i b u t e f u n c t i o n f t o t h e l is t o f a t t r i b u t e s 1

    i _ r u l e n x E Q y i n d i c a t e s t h a t th e a t t r i b u t e x i s t o b e

    i n i t i a l i s ed

    t o t h e v a l u e y

    8 E x a m p l e s o f P a s s a g e s

    8 . 1 A S i m p l e D a t a P r o c e s s i n g E x a m p l e

    P a s s a g e # 5 c a l c u l a t e s t h e a v e r a g e n u m b e r o f e n t r i e s p e r r e c o r d i n a f il e i n w h i c h

    e a c h r e c o r d c o n s i s t s o f a n i n t e g e r k e y f o l l o w e d b y o n e o r m o r e a l p h a n u m e r i c s t r i n g

    e n t r i e s . R e c o r d s a r e s e p a r a t e d b y s e m i c o l o n s , f ie ld s b y c o m m a s , a n d e n d - o f- f i l e i s

    s i g n i f ie d b y a p e r i o d .

    I I P a s s a g e # 5 : C a l c u l a t i n g a v e r a g e n u m b e r o f e n t r i e s o f r e c o r d s i n a f i l e

    ~ i n s e r t < l o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ 1 _ R E L E A S E _ 0 9 >

    J j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : := L I T E R A L _ V A L t e r m i n a l

    I

    ~ H _ R E C S n u m

    I

    N U M _ E N T S n u m

    [ A V _ E N T S n u m

    J j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s ffi [ ]

    s p e c i a l _ s y m b o l s = [ ' . ' , * ; ' , ' ,' ]

    J j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    k e y = u n i n t e r p r e t e d ( I N T _ T E R H a ny )

    e n t r y = u n i n t e r p r e t e d ( I D E N T I F I E R _ T E R M a n y )

    p e r i o d = u n i n t e r p r e t e d ( S P E C I A L _ S Y M B O L _ T E R M " ." )

    s e m i c o l o n = u n i n t e r p r e t e d ( S P E C I A L _ S Y M B D L _ T E R M " ;" )

    c o m m a = u n i n t e r p r e t e d ( S P E C I A L _ S Y M B O L _ T E R M " ," )

    j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    f i l e = s t r u c t u r e ( sl r e c o r d s + + s 2 p e r i o d )

    [ c _ r u l e 1 ( N U H _ E N T S $ u l h s) E Q ( N U H _ E N T S $ u s l ) ,

    c _ r u l e 2 ( N U H _ E E C S $ u l h s ) E Q ( ~ G H _ R E C S S u s l ) ,

    a _ r u l e 3 ( A V _ E N T S S u l hs ) E Q c a l c _ a v e r a g e [ N U M _ E N T S $ u l hs ,

    N U H _ R E C S $ u l h s ]]

    r e c o r d s ffi s t r u c t u r e ( s l r e c o r d + + s 2 s e m i c o l o n ++ s 3 r e c o r d s )

    [ a _ r u l e .4 (N UM _R EC S S u l h s ) EQ a d d _ o n e_ t o _ n um _ r e c s[ ~ F O M _ R E C S $ u s 3 ] ,

    a _ r u l e 5 ( N U M _ E N T S u l h s ) EQ a d d _ n u m _ e n t s [ ~ _ E N T S u s l ,

    ~ t~ _E N T S u s 3 ] ]

    $ e x c l _ o r e l s e

    s t r u c t u r e ( s l r e c o rd )

    [ i _ r u l e 6 ( N U M _ R E C S S u lh s ) E Q ( N U M _ R E C S I ),

    c _ r u l e 7 ( ~ _ E N T S $ u l h s ) E Q ( N U M _ E N T S $ u s l) ]

  • 8/20/2019 3deec521f704dc500a

    10/18

    287

    r e c o r d = s t r u c t u r e ( sl k e y + + s 2 c o m m a + + s 3 e nt r i e s )

    [ c _ r u l e 8 ( I ~J N_ E NT S $ u l h s ) E Q ( N U M _ E N T S $ u s 3 ) ]

    e n t r i e s = s t r u c t u r e ( sl e n t r y + + s 2 c o m m a + + s 3 e n t r i e s )

    [ a _ r u l e 9 ( ~[ tJ M_ EN TS $ u l h s ) E Q a d d _ o n e _ t o _ n u m _ e n t s [ ~ J H _ E N T S $ u s 3 ] ]

    $ e x c l _ o r e l s e

    s t r u c t u r e ( sl e nt r y )

    [ i _ r u l e I 0 ( N U H _ E N T S $ u l h s ) T O ( N U H _ E N T S I )]

    c a l c _a v e r ag e [ ~ _ E N T S x , ~ _ R E C S y] = AV_ENTS ( x / y )

    a d d _ o n e _ t o _ n u m _ r e c s [ N U M _ R E C S x ] = N U M _ R E C S ( I + x )

    a d d _ n u m _ e n t s [ N U M _ E N T S x , N U H _ E N T S y ] - N U M _ E N T S ( x + y )

    a d d _ o n e _ t o _ n u m _ e n t s [ N U M _ E N T S x ] - N U N _ E N T S ( 1 + x )

    ~ I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ]l E X A M P L E A P P L I C A T I O N

    ] l a p p l y _ i n t e r p r e t e r f i l e " 1 2 3 4 , h e s s e l i n k , h e n s e n j o n e s ; 2 3 4 5 ,

    I ~ b a u e r , p a r t s c h , s h a r i r , m o r g a n ; 5 6 7 8 , h e a t h , l i n . "

    I ]

    = > [ N U M _ E N T S

    9,NUH_EECS 3,AV_ENTS

    3 . 0 ]

    8 . 2 A P a s s a g e t o R e v e r s e a L is t

    Passage # 6 reverses its input. T he combinat or Sex cl_ ore lse avoids unnecessary

    backtracking a nd ensures that the list s parsed in only on e w a y (ie. he parse sho uld

    include all elements). Reverse here h as O ( n 2) complexity, ow in g to the fact that the

    ap pe nd operator + + is O ( m ) wh er e m is the length of its leR operand. It is relatively

    straightforward to transform this passage to one with O( n) complexity.

    ]] P a s s a g e # 6 : R e v e r s i n g a l i s t

    Z i n s e r t < I o c a l / h e a d e r _ f o r _ N A G E _ V E R S I O N _ I _ R E L E A S E _ 0 . m >

    ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : := L I T E R A L _ V A L t e r m i n a l [ R E S l i s t _ o f _ t e r m i n a l s

    t l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s = []

    s p e c i a l _ s y m b o l s = [ ]

    I I

    .......................................................................

    e l e m = l i t e r a l A N Y _ T E R M

    l i s t = s t r u c t u r e ( s l e l e m + + s 2 l i s t )

    [ a _ r u l e 1 ( RE S S u l h s ) E Q s t i c k _ o n _ e n d [ L I T E R A L _ V A L S u s l ,

    RES S u s2]]

    S e x c l _ o r e l s e

    s t r u c t u r e ( s i e l e m )

    [ a _ r u l e 2 ( R E S S u l h s ) E Q m a k e _ l i s t [ L I T E R A L _ V A L S u s l ] ]

    m a k e _ l i s t [ L I T E R A L _ V A L x ] = R E S [ x]

    s t i c k _ o n _ e n d [ L I T E R A L _ V A L x , R E S y ] = R E S ( y + + [ x] )

    I ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ]] E X A M P L E A P P L I C A T I O N

    ]] a p p l y _ i n t e r p r e t e r l i s t " 5 s i x 7 8 "

    l ]

    = > I RE S l I N T _ T E RM " 8 " , I N T _ T E R M " 7 " , I D E N T I F I E R _ T E R M , . s i x . ,

    I I INT_TERM 5 ] ]

  • 8/20/2019 3deec521f704dc500a

    11/18

    2 8 8

    8 .3 A P a s s a g e t o C a l c u l a t e F i b o n a c c i N u m b e r s

    P a s s a g e ~ 7 r e c o g n i z e s n u m b e r s a n d r e t u r n s t h e i r F i b o n a c c i v a l u e s . I t w o u l d a p p e a r

    t h a t t h e a t t r i b u t e g r a m m a r p a r a d i g m i s n o t a p p r o p r i a t e f o r t h is p r o b le m . H o w -

    e v e r , a n a l t e r n a t i v e p a s s a g e f o r c a l c u l a t i n g f i b o n a c c i n u m b e r s i n l i n e a r t i m e c a n b e

    o b t a i n e d b y t r a n s f o r m i n g t h i s p a s s a g e a s d i s cu s s ed i n F ro s t[ 5 ].

    [1 P a s s a g e # 7 : C a l c u l a t i n g F i b o n a c c i n u m b e r s

    ~ i n s e r t < l o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ l _ K E L E A S E _ O . m >

    ~ i n s e r t < i o c a l / n u m b e r _ i n t e r p r e t e r _ f o r _ W A G E _ V E R S I O N _ l _ R E L E A S E _ O . m >

    1 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : : = L I T E R A L _ V A L t e r m i n a l [ F I B n u m [ V A L n u m

    ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s = []

    s p e c i a l _ s y m b o l s ffi [ ]

    I I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    f i b n u m b = s t r u c t u r e ( sl n u m b e r )

    [ a _ r u l e I ( F IB S u lh s ) E Q c a l c _ f i b [ V A L S u sl ] ]

    c a l c _ f i b [ V A L x ] = F I B ( f ib x )

    w h e r e f i b n ffi i , n [ F I B 5 ]

    9 U s e o f t h e F u n c t i o n

    m e a n i n g _ o f

    T h e f u n c t i o n m e a n i n g _ o f a l lo w s li s ts o f a t t r i b u t e s t o b e d e fi n ed i n t e r m s o f t h e

    a p p l i c a t i o n o f a n i n t e r p r e t e r t o a n e x p r e ss i o n . T h e f o ll o w i n g p a s s a g e i l l u s t r a t e s s u c h

    u s e .

    N o t i c e t h a t i n t h i s p a s s a g e , t h e p r o p e r n o u n j o h n d o e s n o t d e n o t e a n e n t i ty .

    R a t h e r , i t d e n o t e s a f u n c t i o n d e f in e d in t e r m s o f t h e e n t i t y d e n o t e d b y th e n u m b e r

    1 . T h i s i d e a i s l o o s e l y b a s e d o n a n o t i o n f r o m R i c h a r d M o n t a g u e ' s a p p r o a c h t o t h e

    i n t e r p r e t a t i o n o f n a t u r a l l a n g u a g e .

    ] [ P a s s a g e # 8 :

    ~ i n s e r t

    < I o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ I _ R E L E A S E _ O . m >

    I I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : : = A N S b o o l [ D E T V A L ( [ e n t i t y ] - > [ e n t i t y ] - > b o o l )

    [

    C N O U N V A L [ e n t i t y ]

    [

    T _ P H R A S E V A L ( [ e n ti t y ] - > b o o l )

    [ I N T R V B V A L [ e n t i t y]

    [

    L I T E R A L _ V A L t e r m i n a l

    e n t i t y = = n u m

    ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ w o r d s = []

    s p e c i a l _ s y m b o l s

    =

    []

    I I . . . . . . . . . . - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    c n o u n ffi i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " p e r s o n " , [ C N D U N V A L [ I . . I 0] ] )

    $ o r e l s e i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " w o m a n " , [ C N O U N V A L [ 6 . . 1 0] ] )

    i n t r v b = i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " r u n s " , [ I N T R V B V A L [ 2 . . 7] ] )

  • 8/20/2019 3deec521f704dc500a

    12/18

    2 8 9

    d e t ffi i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " e v e r y " , [ D E T V A L f _ e v e r y ] )

    $ o r e l s e i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " a " , [ D E T VA L f _ a ])

    p n o u n = i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " j o h n " , [ T _ P H R A S E V A L f _ j o h n ] )

    $ o r e l s e i n t e r p r e t e d ( I D E N T I F I E R _ T E R M " s o m e o n e " ,

    m e a n i n g _ o f d e t p h r a s e " a p e r s o n ")

    [ [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - . . . . . . . . . . . . . .

    s e n t = s t r u c t u r e ( sl t e r m p h r a s e + + s 2 i n t r v b )

    [ a _ r u le 1 ( A N S $ u l h s ) E Q a p p I y l [ T _ P H R A S E V A L $ u s l ,

    I N T R ~ B V A L $ u s 2 ] ]

    t e r m p h r a s e = s t r u c t u r e ( s l p n o u n )

    [ c _ r u l e 2 ( T _ P H R A S E V A L $ u l h s) E Q ( T _ P H R A S E V A L S u s l ) ]

    $ o r e l s e

    s t r u c t u r e ( s l

    d e t p h r a s e )

    [ c _ r u l e 3 ( T _ P H R A S E V A L $ u l h s ) E Q ( T _ P H R A S E V A L $ u 8 1 ) ]

    d e t p h r a s e ffi s t r u c t u r e ( s l d e t + + s 2 c n o u n )

    [ a _ r u l e 4 ( T _ P H R A S E V A L S u l h s ) E Q a p p l y 2 [ D E T V A L $ u s l ,

    CNOUNVAL

    S u s 2 ] ]

    a p p l y l [ T _ P H R A S E V A L f , I N T R V B V A L s / = A N S ( f s )

    a p p l y 2 [ D E T V A L f , C N O U N V A L s / = T _ P H R A S E V A L ( f s )

    f_ ev er y x y ffi (x -- - y) = []

    f _ a x y = ( i n t e r s e c t x y ) - = []

    w h e r e i n t e r s e c t x y = ( x - - - ( x - - - y ) )

    f _ j o h n x ffi m e m b e r x 1

    [ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    11

    E X A M P L E A P P L I C A T I O N S

    I I

    I I a p p l y _ i n t e r p r e t e r s e n t " e v e r y w o m a n r u n s " = > [ A NS F a l s e ]

    I I a p p l y _ i n t e r p r e t e r s e n t " s o m e o n e r u n s " = > [ A NS T r u e ]

    II a p p l y _ i n t e r p r e t e r s e n t " j o h n r u n s " = > [ A N S F a l s e ]

    1 0 L e f t R e c u r s i o n

    W / A G E h a s r ec e n t ly b e e n e x t e n d e d to a c c o m m o d a t e a t t r i b u t e g r a m m a r s w i t h le f t

    r e cu r s i v e p ro d u c t i o n s . T h e t e ch n i q u e t h a t a l lo ws l e f t r e cu r s i v e p ro d u c t i o n s t o co -

    ex i s t w i t h t o p d o wn p a r s i n g i s d e s c r i b ed i n F ro s t [ 6 ] .

    1 1 I n t e r p r e t i n g A m b i g u o u s I n p u t

    I n n o e x a m p l e g iv e n s o f a r , h a v e w e a p p l ie d a n i n t e r p r e t e r d i r e c t ly t o a n i n p u t . W e

    h a v e a lw a y s u se d t h e hi g he r o r d e r f u n c ti o n a p p l y _ i n t e r p r e t e r . T h i s a p p r o a c h is

    o n l y a p p r o p r i a t e w h e n a t m o s t o n e p a r s e o f t h e i n p u t i s a n t i c ip a t e d . H o w e v e r , t h e r e

    a re ap p l i ca t i o n s i n wh i ch i t i s n ece s s a ry t o r e t u rn m u l t i p l e i n t e rp re t a t i o n s , o n e fo r

    each way in wh i ch t h e i n p u t c an b e p a r s ed . R eca l l , f ro m s ec t i o n 3. 5, t h a t t h e t y p e

    i n t e r p r e t e r i s d e f in e d a s fo llo ws:

    i n t e r p r e t e r = = [ ( [ a t t r i b u t e / , [ t e r m i n a l / ) / - > [ ( [ a t t r i b u t e / , [ t e r m i n a l / ) /

  • 8/20/2019 3deec521f704dc500a

    13/18

    2 9 0

    T h i s m e a n s t h a t i f a n i n t e r p r e t e r i s a p p l i e d d i re c t l y t o a ' s u i t a b l y p a c k a g e d ' i n p u t

    s t r i n g , s e v e r a l r e s u l t s m a y b e r e t u r n e d . F o r e x a m p l e , s u p p o s e t h a t t h e i n t e r p r e t e r

    l i s t o f p a s s a g e # 6 h a d b e e n d e f in e d u s in g $ o r e l s e i n p l ace o f S e x c l _ o r e l s e . D i rec t

    a p p l i c a t i o n o f th e m o d i f ie d i n t e r p r e t e r t o a n y i n p u t w i t h m o r e t h a n o n e t e r m i n a l ,

    w i l l g i v e m u l t i p l e r e s u l t s . F o r ex am p l e :

    l i s t [ ( [ ] , t o k e n i s e " 5 s i x 7 8 " ) ]

    = >

    [ ( I R E S l I N T _ T E R M " 8 " , I N T _ T E R M " 7 " , I D E N T I F I E R _ T E R M " s i x " , I N T _ T E R M " 5 " ] ] , [ ] ) ,

    ( [ R E S l I N T _ T E R M " 7 " , I D E N T I F I E R _ T E R M " s i x " , I N T _ T E R M " 5 " ] ] , l I N T _ T E R M " 8 " ] ) ,

    ( I R E S [ I D E N T I F I E R _ T E R M " s i x " , I N T _ T E R M " 5 " ] ] , l I N T _ T E R M " 7 " , I N T _ T E R M " 8 " ] ) ,

    ( I R E S l I N T _ T E R M " 5 " ] ] , [ I D E N T I F I E R _ T E R M " s i x " , I N T _ T E R M " 7 " , N T _ T E R M " 8 " ] ) ]

    Eac h o f t h e s e fo u r r e s u l t s is r e l a t ed t o a p a r s e o f th e i n p u t a s a li s t. T h e f i r st r e s u l t

    co r r e s p o n d s t o a p a r s e o f t h e w h o l e o f t h e i n p u t a s a li s t. Th e l a s t r e s u l t co r r e s p o n d s

    t o a p a r s e o f t h e i n p u t a s a s i n g l e t o n li s t f o l lo wed b y t h ree u n i n t e rp r e t ed t e rm i n a l s .

    T h e a b i l i t y t o h a n d l e a m b i g u o u s i n p u t i s u s e f u l i n m a n y a p p l i c a t i o n s i n c l u d -

    i n g n a t u ra l l an g u ag e p ro ces si n g . H o wev e r , i t is a ls o a fu n d a m en t a l p ro p e r t y o f t h e

    W / A G E s y s t e m . A l l i n t e r p r e t e r s a r e im p l e m e n t e d a s t o p d o w n , f u ll y b a c k t r a c k i n g ,

    s y n t a x d i r e c te d , l a z y e v a lu a t o r s . T h e r e is o n e m a j o r a d v a n t a g e o f th i s: p a s sa g e s

    a re m o d u l a r . A d i f f e r en t , b u t s o m ewh a t r e l a t ed , ap p ro ach t o l a z y r ecu r s i v e d e s cen t

    p a r s i n g f o r m o d u l a r l a n g u a g e i m p l e m e n t a t i o n i s d e s c r i b e d i n K o s k i m i e s [ 1 3 ] . M a n y

    o f t h e a r g u m e n t s g i v e n th e r e a p p l y to t h e p a r s i n g s t r a t e g y t h a t w e h a v e a d o p t e d i n

    W / A G E .

    1 2 A n E x a m p l e o f a C o m p l e x P a s s a g e

    P as s ag e # 9 co n v e r t s ex p re s s io n s o f p ro p o s i t i o n a l l o g ic t o c l au s a l fo rm . I f t h e ex p re s -

    s io n is va l id , th e i n t e r p r e t e r w f f r e t u r n s t h e e m p t y c l a u se s e t, a n d m a y t h e r e f o r e b e

    reg a rd ed a s a d ec i s i o n p ro ced u re fo r p ro p o s i t i o n a l l o g i c .

    I ~ P a s s a g e # 9 :

    ~ i n s e r t < l o c a l / h e a d e r _ f o r _ W A G E _ V E R S I O N _ I _ R W - ~ A S E _ O 9 >

    1 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    a t t r i b u t e : : = L I T E R A L _ V A L t e r m i n a l J C C F S E T [ d i s j c l a u s e ] J C O N T E X T [ c h a r ]

    d i s j c l a u s e : : = D I S J C L [ [ c h a r ] ]

    jj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    r e s e r v e d _ g o r d s = [ " a n d " , " o r " , " i m p l i e s " ]

    s p e c i a l _ s y m b o l s = [ ' . ' , ' ( ' , ' ) ~ , ' - ' ]

    J j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    [ I o p b r , c l b r , p e r i o d a n d n e g a t e a s d e f i n e d i n e a r l i e r p a s s a g e s

    o r r = u n i n t e r p r e t e d ( R E S E R V E D _ W O R D _ T E R M " o r " )

    a a n d = u n i n t e r p r e t e d ( R E S E R V E D _ W O R D _ T E R M " a n d " )

    i m p l i e s = u n i n t e r p r e t e d ( R E S E R V E D _ W O R D _ T E R M " i m p l i e s " )

    v a r

    = l i t e r a l I D E N T I F I E R _ T E R M

    J j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -- . . . . . . .

    w f f -- s t r u c t u r e ( s l e x p r + + s 2 p e r i o d )

    [ c _ r u l e I ( C C F S E T $ u l h s ) E Q ( C C F S E T $ u s l ) ,

    i _ r u l e 2 ( C O N T E X T d s l ) E Q ( C O N T E X T " p o s " ) ]

  • 8/20/2019 3deec521f704dc500a

    14/18

    29

    e x p r =

    s t r u c t u r e ( s l v a r )

    [ a _ r u l e 3 ( C C F S E T S u l h s ) E Q m a k e _ c c f s e t

    [ L I T E R A L _ V A L $ u s l ,

    C O N T E X T S d l h s ] ]

    $ o r e l s e

    s t r u c t u r e ( s l o p b r + + s 2 ( c o n j u n c t i o n $ o r e l s e d i s j u n c t i o n

    $ o r e l s e i m p l i c a t i o n ) + + s 3 c l b r )

    [ c _ r u l e 4 ( C C F S E T S u l h s ) E O ( C C F S E T S u s 2 ) ,

    c _ r u l e 5 ( C O N T E X T S d s 2 ) E Q ( C O N T E X T S d l h s ) ]

    $ o r e l s e s t r u c t u r e ( sl n e g a t e + + s 2 e x p r)

    [ c _ r u l e 6 ( C C F S E T S u l h s ) E Q ( C C F S E T S u s 2 ) ,

    a _ r u l e ? ( C O N T E X T $ d s 2) E Q o p p o s i t e [ C O N T E X T $ d l h s ] ]

    c o n j u n c t i o n = s t r u c t u r e ( sl e x p r + + s 2 a a n d

    [ a _ r u l e 8 ( C C F S E T $ u l h s ) E Q

    c _ r u l e 9 ( C O N T E X T S d s l ) E Q

    c _ r u l e I 0 ( C O N T E X T S d s 3 ) E Q

    $ o r e l s e s t r u c t u r e ( sl e x p r )

    [ c _ r u l e ii ( C C F S E T $ u l h s) E Q

    c _ r u l e 1 2 ( C O N T E X T S d s l ) E Q

    + + s 3 c o n j u n c t i o n )

    context_and

    [ C O N T E X T S d l h s ,

    C C F S E T $ u s l,

    C C F S E T $ u s 3 ],

    ( C O N T E X T S d l h s ),

    ( C O N T E X T S d l h s ) ]

    ( C C F S E T S u s l ),

    (CONTEXT S d l h s ) ]

    d i s j u n c t i o n = s t r u c t u r e ( sl e x p r + + s 2 o r r

    [ a _ r u l e 1 3 ( C C F S E T $ u l h s) E Q

    c _ r u l e 1 4 ( C O N T E X T $ d s l ) E O

    c _ r u l e 15 ( C O N T E X T $ d s 3 ) E Q

    $ o r e l s e s t r u c t u r e ( sl e x p r)

    [ c _ r u l e 16 ( C C F S E T S u l h s) E Q

    c _ r u l e 1 7 ( C O N T E X T S d s l ) E Q

    + + s 3 d i s j u n c t i o n )

    c o n t e x t _ o r

    [ C O N T E X T $ d l h s ,

    C C F S E T S u s l ,

    C C F S E T S u s 3 ] ,

    ( C O N T E X T S d l h s ) ,

    (CONTEXT Sd lh s ) ]

    ( C C F S E T $ u s l ) ,

    ( C O N T E X T S d l h s ) ]

    T h e f u n c t i o n s o r t i s r e q u i r e d i n t h e d e f i n i t i o n o f u n i t e _ c l a u s e s i n o r d e r t h a t mkset

    performs ~ required.

    i m p l i c a t i o n = s t r u c t u r e ( si e x p r + + s 2 i m p l i e s + + s 3 e x p r)

    [ a _ r u l e 1 8 ( C C F S E T S u l h s ) E Q c o n t e x t _ o r

    [ C O N T E X T $ d l h s ,

    C C F S E T S u s l ,

    C C F S E T $ u s 3 ],

    a _ r u l e 1 9 ( C O N T E X T $ d s l ) E Q o p p o s i t e

    [ C O N T E X T S d l h s ] ,

    c _ r u l e 2 0 ( C O N T E X T S d s 3 ) E Q ( C O N T E X T S d l h s )]

    I j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  • 8/20/2019 3deec521f704dc500a

    15/18

    292

    c o n t e x t _ a n d [ C O N T E X T " p o s " , x , y ] = c c f _ a n d x y

    c o n t e x t _ a n d [ C O N T E X T " n e g " , x , y ] = c c f _ o r x y

    c o n t e x t _ o r [ C O N T E X T " p o s " , x , y ] = c c f _ o r x y

    c o n t e x t _ o r [ C O N T E X T " n e g " , x , y ] = c c f _ a n d x y

    o p p o s i t e [ C O N T E X T " p o s "] = C O N T E X T " n e g "

    o p p o s i t e [ C O N T E X T " n e g" ] = C O N T E X T " p o s "

    m a k e _ c c f s e t [ L I T E R A L _ Y A L ( I D E N T I F I E R _ T E R N v ) , C 0 N T E X T " p os " ]

    = C C F S E T [ D I S J C L [ v i i

    m a k e _ c c f s e t [ L I T E R A L _ V A L ( I D E N T I F I E R _ T E R N v ) , C O N T E X T " n eg " ]

    C C F S E T [ D I S J C L [ n e g a t e _ l i t v ] ]

    i i . _ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    II F U N C T I O N S F R O M C L A U S E F O R M L O G I C

    ]I T h e f u n c t i o n c c f _ a n d f o r m s t h e c l a u s a l c o n j u n c t i o n o f t wo c o n j u n c t i v e

    [ [ c l a u s e s e t s

    c c f ~ a n d ( C C F S E T d c s ) ( C C F S E T d c s ' ) = C C F S E T ( m k s et ( d c s + + d c s ' ) )

    [[ T h e f u n c t i o n c c f _ o r f o r m s t h e c l a u s a l d i s j u n c t i o n o f t w o c l a u s e s e t s

    ][ t a u t o l o g o u s c l a u s e s a r e r e m o v e d w h e n p r o d u c e d , m k s e t m a k e s a se t

    ][ f r o m a l i s t

    c c f _ o r ( C C F S E T d c s) ( C C F SE T d c s ' ) =

    C C F S E T ( m k s e t [ n e w c l a u s e [ ( D I S J C L c l ) - d c s ; ( D I S J C L c 2 ) - d c s ~ ; ]

    n e ~ c l a u s e - [ D I S J C L ( u n i t e _ c l a u s e s cl c 2) ] ; n o t _ t a u t n e w c l a u s e ] )

    n o t _ t a u t ( D I S J C L c) = [ 1 1 1 I i - c ; 1 2 - c ; i i = ( n e g a t e _ l i t 1 2 ) ] = []

    n e g a t e _ l i t ( ~- ~ : x ) = x

    n e g a t e _ l i t y = ( ~ -~ : y )

    u n i t e _ c l a u s e s c l c 2 = ( s o r t . m k s e t ) ( c l + + c 2)

    ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    [[ E X A M P L E A P P L I C A T I O N S

    I I

    [J a p p l y _ i n t e r p r e t e r w f f . .. .. ( p i m p l i e s q ) i m p l i e s ( r i m p l i e s ( s a n d t ) ) ) . "

    --> [[CCFSET [DISJCL [ -r , p , s ], DISJCL [ - r , p , t ],

    D I S J C L [ " - q " , " - r " , " s t'] , D I S J C L [ " - q " , " - r " , " t " ] ] ] ]

    a p p l y _ i n t e r p r e t e r wf f " ( ( j oh n h a s _ m o n e y a n d ( j o h n _ h a s _ m on e y i m p l i e s

    j o h n _ c o u l d_ p a y ) ) i m p l i es j o h n _ c o u l d _ p a y ) . "

    ~> [CCFSET [] ]

    The seco nd example shows how a val id form ula i s co nv er te d to an empty

    c l au s e fo rm s e t . T h e re fo re , t o s ee i f a fo rmu l a F i s a t h eo rem o f a s e t o f

    fo rm ulas S, you s imply app ly con ver t to (S imp l ie s F) . . I f an empty

    c l au s e s e t i s r e t u rn ed , t h en F i s a t h eo rem o f S , o t h e rw i s e i t i s n o t .

  • 8/20/2019 3deec521f704dc500a

    16/18

    293

    1 3 C o n c l u d i n g C o m m e n t s

    1 3.1 E x p e r im e n t a t io n w i t h W / A G E

    D u r i n g t h e l a s t t w e lv e m o n t h s , W / A G E h a s b e e n u s ed e x t e n s iv e l y i n a n u m b e r o f a p -

    p l i c a t i o n a r e a s . I n p a r t i c u l a r , i t h a s b e e n u s e d i n t h e c o n s t r u c t i o n o f a s o p h i s t i c a t e d

    e x p e r i m e n t a l n a t u r a l l a n g u a g e i n te r fa c e t o a d a t a b a s e , i n t h e t r a n s f o r m a t i o n c o m p o -

    n e n t o f a V L S I d e s i g n e r ' s a s s i s t a n t , a n d a s a t e a c h i n g a i d in a t h i r d y e a r ' G r a m m a r s

    a n d T r a n s l a t o r s ' c o u rs e . T h e n a t u r a l l a n g u a g e i n t e rf a c e t h a t w a s c o n s t ru c t e d u s i ng

    W / A G E c a n h a n d l e b o t h s y n t a c t i c a n d s e m a n t i c a m b i g u i t y a n d p r o v id e s ' d i a l o g u e '

    a n s w e r s t o u s e r ' s q u e s ti o n s . T h e i n t e r p r e t e r w a s b u i l t a s p a r t o f a n i n v e s t i g a t i o n i n t o

    t h e f e a s ib i li ty o f e x t e n d i n g M o n t a g u e ' s c o m p o s i t i o n a l s e m a n t i c s t o a c c o m m o d a t e

    s e m a n t i c a m b i g u i t y . T h e V L S I p r o je c t i n v ol v e d t h e c o n s t r u c ti o n o f ( i) p r o g r a m s t o

    t r a n s l a t e m a t h e m a t i c a l s p e c i f ic a t i o n s o f f in i t e i m p u l s e r e s p o n s e f i lt e r s t o e x e c u t a b l e

    s p ec i f i c a t i o n s o f s y s to l i c c i r cu i t s b a s ed o n a s t a n d a r d V L S I cel l, an d ( i i) p r o g r a m s

    t o t r a n s l a t e t h e e x e c u t a b l e s p e c i f i c a t i o n s t o E D I F n e t l i s t r e p r e s e n t a t i o n s s u i t a b l e

    f o r i n p u t t o a V L S I l a y o u t p a c k a g e . T h e v i a b i l i t y o f t h e a p p r o a c h w a s c o n f i r m e d

    b y t e s t i n g t h e t r a n s l a t o r s o n a r e a l F I R f i l t e r d e s i g n c o m p r i s i n g 3 m o d u l i a n d 6 4

    co e f fi c ien t s. A d e t a i l ed d e s c r ip t i o n o f t h i s w o r k i s g iv en in M as t e r ' s t h e s e s av a i l ab l e

    f r o m t h e U n i v er s it y o f W i n d so r . W / A G E h a s a l so b e e n u s e d in t h e c o n s t r u c t io n o f

    v a r io u s o t h e r p r o g r a m s in a s e p a r a t e s t u d y i n to t h e u s e of t h e a t t r i b u t e g r a m m a r

    p a r a d i g m i n c o n st r u c ti v e ( t r a n s f o r m a t i o n a l ) p r o g r a m m i n g / 4 / .

    1 3 . 2 F i n d i n g s

    W e h a v e fo u n d t h a t t h e i n t e g r a ti o n o f t h e l a z y f u n c ti o n a l p r o g r a m m i n g a n d a t t r i b u t e

    g r a m m a r p a r a d i g m s is s t ra i g h t fo r w a r d . C o n s t r u c t i o n o f a p r o g r a m m i n g e n v i ro n m e n t

    t o s u p p o r t t h i s c o m b i n e d p a r a d i g m w a s h e l p e d s ig n i f ic a n t l y b y t h e d e c l a r a t i v e n a t u r e

    o f t h e h o s t l a n g u a g e M i r a n d a. S o m e o f t h e m o r e d if fi cu lt a s p e c t s o f t h e W / A G E

    w e r e c o n s t r u c t e d u s i n g th e m e t h o d o f ' p r o g r a m s f r o m p r o o f s ' i n w h i c h i n d u c t i o n

    i s u s ed ' i n r ev e r s e ' t o d e s ig n a co m p lex r ecu r s iv e f u n c t io n d e f in i t i o n . W e ch o s e t o

    i m p l e m e n t t h e s y n t a x a n a l y z e r s a s t o p - d o w n fu l l y b a c k t r a c k i n g p a r s e r s . I t h a s b e e n

    a r g u e d e l s ew h e r e/ 13 / t h a t s u c h p a r s e r s a re m o r e m o d u l a r t h a n t h o s e b u i l t u s in g

    o t h e r s t r a t e g ie s . T h e l a z y e v a l u a t i o n o r d e r a l l o w s a t t r i b u t e e v a l u a t i o n t o b e c l o se l y

    r e l a t e d t o s y n t a x a n a l y s i s c a r ri e d o u t b y t o p - d o w n f u ll y b a c k t r a c k i n g p a r s e r s w i t h o u t

    i n c u r r i n g th e r e d u n d a n t c o m p u t a t i o n t h a t w o u l d o c c u r i f a s t r i c t e v a l u a t i o n o rd e r

    were used .

    O u r e x p e r i m e n t a t i o n w i t h W / A G E h a s c o nv i n ce d us t h a t a p p l i c a t io n o f t h e n e w

    c o m b i n e d p r o g r a m m i n g p a r a d i g m r e su l ts i n e x t r e m e l y c l ea r a n d m o d u l a r e x e c u t a b l e

    s p e c i fi c a ti o n s o f l a n g u a g e i n t e r p r e te r s . H o w e v e r , th e a c t u a l c o n s t r u c t i o n o f t h e i n t e r-

    p r e t e rs w a s h i n d er e d b y th e p o o r d e b u g g in g fa c il it ie s o f b o t h W / A G E a n d M i r a n d a .

    I n p a r t i c u l a r , t h e a b s e n c e o f t r a c e f a c il i ti e s i n W / A G E w a s a v e r y n o t i c e a b l e s h o r t -

    c o m i n g . A d d i n g a t r a c e fa c il it y t o W / A G E i s n o t a s i m p l e t a s k . T h e f a c t t h a t p u r e

    f u n c t i o n a l p r o g r a m m i n g l a n g u a g e s d o n o t a l lo w a n y k i n d o f s i de e f fe c ts re q u i r e s o n e

    t o a d o p t a c o m p l e t e l y d if fe r en t a p p r o a c h t o t h e p r o v i s i o n o f d e - b u g g i n g f a c il it i es .

    W e h o p e t o o v e r c o m e t h is p r o b l e m i n th e n e x t f ew m o n t h s .

  • 8/20/2019 3deec521f704dc500a

    17/18

    2 9 4

    D u r i n g o u r i n v e s t ig a t i o n , w e f o u n d t h a t i t w o u l d h a v e b e e n u s e fu l i f W / A G E

    c o u l d ha v e s u p p o r t e d t h e c o n s t r u c t i o n o f l a n g u a g e t r a n s f o r m e r s i e . s y n t a c t i c r e w r i t -

    e r s) a s w e ll as l a n g u a g e i n t e r p r e te r s . I f th e s e t r a n s f o r m e r s a r e o f t h e s a m e t y p e a s

    i n t e r p r e t e r s , t h e t w o c o u l d b e c o m b i n e d i n v a r io u s w a y s e n a b l i n g w i d e r e x p e r i m e n -

    t a t i o n i n l a n g u a g e p r o c e s s in g . S u c h e x t e ns i o n o f b o t h t h e p r o g r a m m i n g p a r a d i g m

    a n d t h e e n v i r o n m e n t t o s u p p o r t i t i s t h e s u b j e c t o f o u r c u r r e n t w o r k .

    W / A G E i s c u r r e n t l y u n d e r go i n g e x p e r im e n t a l u s e a t a n u m b e r o f u n i v e rs i t y

    s i te s . P o t e n t i a l u s e rs c a n o b t a i n a c o py o f t h e W / A G E c o d e t h r o u g h r e q u e s t t o

    r i c h a r d @ e s , u w i n ds o r ,

    c a .

    T h e a u t h o r s a c k n o w l e d g e t h e a s s i s t a n c e o f N . S . E . R . C . o f C a n a d a , a n d o f S u b i r

    B a n d y o p a d h y a y a n d W a l i d S a b a o f t h e S c h oo l o f C o m p u t e r S c ie n ce a t t h e U n i v e rs i ty

    o f W i n d s o r .

    R e f e r e n c e s

    1. B . E d u p u g a n t y a n d B . R . B r y a n t , T w o - l e v e l g r a m m a r a s a f u n c t i o n a l p r o g r a m m i n g

    lan g u ag e . T h e C o m p u te r Jo u rn a l , 3 2 (1 ) , 3 6 - 4 4 (1 9 8 9 ) .

    2 . M . S . F e a t h e r , A s u r v e y a n d C l a s s i f ic a t i o n o f s o m e p r o g r a m t r a n s f o r m a t i o n a p p r o a c h e s

    a n d t e c h n iq u e s . I n L . G . L . T . M e e r t e n s ( E d i t o r ) P r o g r a m S p e c i f i c a t io n a n d T r a n s f o r -

    m a t i o n . I F I P 1 98 7. E l s e v i e r S c i e nc e P u b l i s h e r s B . V . N o r t h - H o l l a n d .

    3 . P . F o r b i g , a n d U . L a m m e l , K n o w l e d g e b a s e d p r o g r a m g e n e r a t i o n u s in g a t t r i b u t e g r a m -

    m a r s , i n : G r a b o w s k i , J ( e d ) , P r o c . o f t h e B e r l i n e r I n f o r m a t i k T a g e b i t ' 8 9. A k a d e m i e d .

    W i s s e n s c h a f t e n d e r D D R , f i r - R e p o r t , 1 1 4 - 1 2 3 , ( 1 9 8 9 ) .

    4 . R . A . F r o s t , C o n s t r u c t i n g P r o g r a m s i n a C a l c u l u s o f I n t e r p r e t e r s , P r o c e e d i n g s o f t h e 1 99 0

    A C M I n t e r n a t i o n a l W o r k s h o p o n F o r m a l M e t h o d s i n S o f t w a r e D e v e l o p m e n t , ( 1 9 9 0 ) .

    5 . R . A . F r o s t , C o n s t r u c t i n g p r o g r a m s a s e x e c u t a b l e a t t r i b u t e g r a m m a r s , T h e C o m p u t e r

    J o u r n a l ( t o a p p e a r i n t h e A u g u s t 1 9 9 2 i s s u e ) .

    6 . R . A F r o s t , G u a r d e d A t t r i b u t e G r a m m a r s : T o p D o w n P a r s i n g a n d L e f t R e c u rs i v e P r o -

    d u c t io n s , A C M S IG P L A N 2 7 (6 ) , 7 2 -7 6 , (1 9 9 2 ) .

    7 . E . C . R . H e h n e r a n d B . A . S il v e r b e rg , P r o g r a m m i n g w i t h g r a m m a r s : a n e x e r c is e i n

    m eth o d o lo g y -d i rec t ed l an g u ag e d es ig n . T h e C o m p u te r Jo u r n a l 2 6 (3 ), 22 7 - 28 1 (1 9 8 3 ).

    8 . T . J o h n s s o n , A t t r i b u t e g r a m m a r s a s a f u n c t i o n a l p r o g r a m m i n g p a r a d i g m . S p r i n g e r L e c -

    ture Notes 274, 155 - 173 (1987).

    9. T . K a t a y a m a , H F P : A h i er a r c hi c a l a n d f u n c t io n a l p r o g r a m m i n g b a s e d o n a t t r i b u t e

    g r a m m a r s , P r o c e e d i n g s o f 5 th I n t e r n a t i o n a l C o n f. o n S o f t w a r e E n g i n e e ri n g , 3 4 3 -3 5 3 ,

    (1981).

    1 0. D . E . K n u th , S em an t i c s o f co n tex t - f r ee l an g u ag es . M ath . S y s t . T h eo ry . 2 (2 ) , 1 2 7 -1 4 5 ,

    (1968).

    1 1. D . E . K n u th , S em an t i c s o f co n te x t - f r ee l an g u ag es : co r rec t io n . M ath . S y s t . T h eo ry . 5 ,

    95-96 , (1971) .

    1 2. D . E . K n u t h , E x a m p l e s o f F o r m a l S e m a n t i c s . S p r i n g e r L e c t u r e N o t e s i n C o m p u t e r

    Science Vol 188, 212-235 (1971).

    1 3. K . K o s k i m i e s , L a z y r e c u r s i v e d e s c e n t p a r s i n g f or m o d u l a r l a n g u a g e i m p l e m e n t a t i o n .

    S o f tw are P rac t i ce an d E x p er i en ce , 2 0 (8 ) , 7 4 9 -7 7 2 (1 9 9 0 ) .

    14 . T . P a n a y i o t o p o u l o s , G . P a p a k o n s ta n t i n o u , a n d G . S t a m a t o p o u l o s , A t t r i b u t e g r a m m a r s

    and log ic p ro gra m m ing , Agn ew. In f . No 5 (1988) 227.

    15 . Y . S h i n o d a a n d T . K a t a y a m a , A t t r i b u t e g r a m m a r b a s e d p r o g r a m m i n g a ~ d i t s e n -

    v i r o n m e n t , P r o c e e d i n g s o f 2 1s t H a w a i i I n t e r n a t i o n a l C o n f e r e nc e o n S y s t e m S c i en c e s ,

    K a i lu -K o n a , Haw ai i , 6 1 2 -6 2 0 , (1 9 8 8 ) .

  • 8/20/2019 3deec521f704dc500a

    18/18

    2 9 5

    1 6 . E . S i m o n , A n e w p r o g r a m m i n g m e t h o d o l o g y u s i n g a t t r i b u t e g r a m m a r s , A c t a C y b e r -

    net ica, 7 (4) , 425-436 (1986).

    17 . D . Turne r , A non- s t r i c t func t i ona l l anguage wi th po lymorphic t ypes . P roc . IF IP

    I n t . C o n f . o n F u n c t i o n a l P r o g r a m m i n g L a n g u a g e s a n d C o m p u t e r A r c h i t e c t u r e , N a n c y ,

    France. Spr inger Lecture Notes in Computer Science 201. (1985) .