Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simple4 parser: _= may be omitted
  • Loading branch information
mbenke committed Sep 9, 2011
1 parent bc91ebd commit f27b2c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Simple4/ParsecParser.hs
Expand Up @@ -33,7 +33,9 @@ pOptionalSemi :: Parser ()
pOptionalSemi = optional $ symbol ";"

pDef :: Parser Def
pDef = do
pDef = (try pFullDef) <|> ((\e -> ("_",e)) <$> pExp)

pFullDef =do
v <- identifier
foo <- symbol "="
e <- pExp
Expand Down
12 changes: 6 additions & 6 deletions Simple4/Test.hs
Expand Up @@ -40,12 +40,12 @@ prog3 = [
-- undefined var
bad1 = [("_", EVar "x")]

text2 = "l=new 1 x=*l \
\ _ = let x = 2 in if x then x else 42\
text2 = "l=new 1; x=*l \
\ let x = 2 in if x then x else 42\
\ y = 2\
\ _ = x+y"
\ x+y"

text4 = "locals = new {}; \
\ _=locals.y=1; \
\ _ = if locals.y then locals.y = None else locals.y = 42;\
\ _ = locals.y"
\ locals.y=1; \
\ if locals.y then locals.y = 42 else locals.y = None;\
\ locals.y"

0 comments on commit f27b2c2

Please sign in to comment.