Browse files

More whitespace/comment parsing issues fixed.

  • Loading branch information...
1 parent 730f279 commit 7c74cd9b4edc616b46cdb1da7fd5b1d1fe4390c6 @colah committed Sep 11, 2012
Showing with 28 additions and 27 deletions.
  1. +0 −15 Graphics/Implicit/ExtOpenScad/Statements.hs
  2. +28 −12 Graphics/Implicit/ExtOpenScad/Util.hs
View
15 Graphics/Implicit/ExtOpenScad/Statements.hs
@@ -28,21 +28,6 @@ import Graphics.Implicit.ExtOpenScad.Util.Computation
tryMany = (foldl1 (<|>)) . (map try)
--- white space, including tabs and comments
-genSpace = many $
- space
- <|>
- char '\t'
- <|> (do
- string "//"
- many ( noneOf "\n")
- string "\n"
- return ' '
- ) <|> (do
- string "/*"
- manyTill anyChar (try $ string "*/")
- return ' '
- )
-- | A statement in our programming openscad-like programming language.
computationStatement :: GenParser Char st ComputationStateModifier
View
40 Graphics/Implicit/ExtOpenScad/Util.hs
@@ -42,29 +42,45 @@ infixr 2 <||>
then f $ (\(Just a) -> a) coerceAttempt
else g input
+-- white space, including tabs and comments
+genSpace = many $
+ space
+ <|>
+ char '\t'
+ <|> (do
+ string "//"
+ many ( noneOf "\n")
+ string "\n"
+ return ' '
+ ) <|> (do
+ string "/*"
+ manyTill anyChar (try $ string "*/")
+ return ' '
+ )
+
moduleArgsUnit ::
GenParser Char st ([VariableLookup -> OpenscadObj], [(String, VariableLookup -> OpenscadObj)])
moduleArgsUnit = do
char '(';
- many space;
+ genSpace
args <- sepBy (
(try $ do -- eg. a = 12
symb <- variableSymb;
- many space;
+ genSpace
char '=';
- many space;
+ genSpace
expr <- expression 0;
return $ Right (symb, expr);
) <|> (try $ do -- eg. a(x,y) = 12
symb <- variableSymb;
- many space;
+ genSpace
char '('
many space
argVars <- sepBy variableSymb (many space >> char ',' >> many space)
char ')'
many space
char '=';
- many space;
+ genSpace
expr <- expression 0;
let
makeFunc baseExpr (argVar:xs) varlookup' = OFunc $
@@ -77,7 +93,7 @@ moduleArgsUnit = do
return $ Left expr;
})
) (many space >> char ',' >> many space);
- many space;
+ genSpace
char ')';
let
isRight (Right a) = True
@@ -90,26 +106,26 @@ moduleArgsUnitDecl ::
GenParser Char st (VariableLookup -> ArgParser (VariableLookup -> VariableLookup))
moduleArgsUnitDecl = do
char '(';
- many space;
+ genSpace
args <- sepBy (
(try $ do
symb <- variableSymb;
- many space;
+ genSpace
char '=';
- many space;
+ genSpace
expr <- expression 0;
return $ \varlookup ->
ArgParser symb (Just$ expr varlookup) "" (\val -> return $ insert symb val);
) <|> (try $ do
symb <- variableSymb;
- many space;
+ genSpace
char '('
many space
argVars <- sepBy variableSymb (many space >> char ',' >> many space)
char ')'
many space
char '=';
- many space;
+ genSpace
expr <- expression 0;
let
makeFunc baseExpr (argVar:xs) varlookup' = OFunc $
@@ -124,7 +140,7 @@ moduleArgsUnitDecl = do
ArgParser vsymb Nothing "" (\val -> return $ insert vsymb val);
})
) (many space >> char ',' >> many space);
- many space;
+ genSpace
char ')';
let
merge ::

0 comments on commit 7c74cd9

Please sign in to comment.