Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dangling Else Ambiguity

Name: OMG LEFT RECURSION111!! 2007-12-09 11:36

Halp /prog/, I want to solve the Dangling Else Ambiguity here but I keep screwing it up.

void IfStmt() : {}
{
        <IF> Expr() <THEN> Stmt()
    |    <IF> Expr() <THEN> Stmt() <ELSE> Stmt()
}

void Stmt() : {}
{
        Assignment()
    |    IfStmt()
    |    WhileStmt()
    |    CaseStmt()
    |    Function()
    |    IOStmt()
    |    Block()
    |    Return()
}

Name: Anonymous 2007-12-09 12:15

data Aexp = Number Float | Plus Aexp Aexp | Minus Aexp Aexp | Times Aexp Aexp
evaluate :: Aexp -> Float
evaluate (Number x)  = x
evaluate (Plus x y)  = evaluate (x) + evaluate (y)
evaluate (Minus x y) = evaluate (x) - evaluate (y)
evaluate (Times x y) = evaluate (x) * evaluate(y)


you bitches dont know about my haskell

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List