mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-17 16:08:01 +03:00
Add a lexer, and use it to parse whitespace before the first statement.
This commit is contained in:
parent
79c20d1193
commit
4ec2277903
@ -1,2 +1,4 @@
|
||||
// Example10.escad -- map!.
|
||||
echo(map(cos, [0, pi/2, pi]));
|
||||
cube(10);
|
||||
translate1 (10) cube(10);
|
@ -31,6 +31,9 @@ import Graphics.Implicit.ExtOpenScad.Parser.Util (genSpace, tryMany, stringGS, (
|
||||
-- the top level of the expression parser.
|
||||
import Graphics.Implicit.ExtOpenScad.Parser.Expr (expr0)
|
||||
|
||||
-- The lexer.
|
||||
import Graphics.Implicit.ExtOpenScad.Parser.Lexer (whiteSpace)
|
||||
|
||||
-- Let us use the old syntax when defining Names.
|
||||
pattern Name :: String -> GIED.Pattern
|
||||
pattern Name n = GIED.Name (Symbol n)
|
||||
@ -39,8 +42,9 @@ parseProgram :: SourceName -> String -> Either ParseError [StatementI]
|
||||
parseProgram name s = parse program name s where
|
||||
program :: ParsecT String u Identity [StatementI]
|
||||
program = do
|
||||
_ <- whiteSpace
|
||||
sts <- many computation
|
||||
eof
|
||||
_ <- eof
|
||||
return sts
|
||||
|
||||
-- | A computable block of code in our openscad-like programming language.
|
||||
|
@ -87,6 +87,7 @@ Library
|
||||
Graphics.Implicit.ObjectUtil.GetImplicit2
|
||||
Graphics.Implicit.ObjectUtil.GetImplicit3
|
||||
Graphics.Implicit.ExtOpenScad.Default
|
||||
Graphics.Implicit.ExtOpenScad.Parser.Lexer
|
||||
Graphics.Implicit.ExtOpenScad.Parser.Util
|
||||
Graphics.Implicit.ExtOpenScad.Eval.Statement
|
||||
Graphics.Implicit.ExtOpenScad.Eval.Expr
|
||||
|
Loading…
Reference in New Issue
Block a user