language-openscad-0.1.8: A simple parser for OpenSCAD

Safe HaskellNone
LanguageHaskell2010

Language.OpenSCAD

Contents

Synopsis

Basic parsing

parse :: ByteString -> Either String [TopLevel] Source #

Parse OpenSCAD source

Primitives

newtype Ident Source #

An identifier

Constructors

Ident String 
Instances
Eq Ident Source # 
Instance details

Defined in Language.OpenSCAD

Methods

(==) :: Ident -> Ident -> Bool #

(/=) :: Ident -> Ident -> Bool #

Ord Ident Source # 
Instance details

Defined in Language.OpenSCAD

Methods

compare :: Ident -> Ident -> Ordering #

(<) :: Ident -> Ident -> Bool #

(<=) :: Ident -> Ident -> Bool #

(>) :: Ident -> Ident -> Bool #

(>=) :: Ident -> Ident -> Bool #

max :: Ident -> Ident -> Ident #

min :: Ident -> Ident -> Ident #

Show Ident Source # 
Instance details

Defined in Language.OpenSCAD

Methods

showsPrec :: Int -> Ident -> ShowS #

show :: Ident -> String #

showList :: [Ident] -> ShowS #

Arbitrary Ident Source # 
Instance details

Defined in Language.OpenSCAD

Methods

arbitrary :: Gen Ident #

shrink :: Ident -> [Ident] #

Pretty Ident Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: Ident -> Doc ann #

prettyList :: [Ident] -> Doc ann #

ident :: Parser Ident Source #

Parse an identifier

data TopLevel Source #

Things which can appear at the top level of an OpenSCAD source file

Instances
Eq TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

Show TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

Generic TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

Associated Types

type Rep TopLevel :: Type -> Type #

Methods

from :: TopLevel -> Rep TopLevel x #

to :: Rep TopLevel x -> TopLevel #

Arbitrary TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

Pretty TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: TopLevel -> Doc ann #

prettyList :: [TopLevel] -> Doc ann #

type Rep TopLevel Source # 
Instance details

Defined in Language.OpenSCAD

topLevel :: Parser TopLevel Source #

Parse the top-level definitions of an OpenSCAD source file

data Object Source #

An OpenSCAD geometry object

Instances
Eq Object Source # 
Instance details

Defined in Language.OpenSCAD

Methods

(==) :: Object -> Object -> Bool #

(/=) :: Object -> Object -> Bool #

Show Object Source # 
Instance details

Defined in Language.OpenSCAD

Generic Object Source # 
Instance details

Defined in Language.OpenSCAD

Associated Types

type Rep Object :: Type -> Type #

Methods

from :: Object -> Rep Object x #

to :: Rep Object x -> Object #

Arbitrary Object Source # 
Instance details

Defined in Language.OpenSCAD

Pretty Object Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: Object -> Doc ann #

prettyList :: [Object] -> Doc ann #

type Rep Object Source # 
Instance details

Defined in Language.OpenSCAD

type Rep Object = D1 (MetaData "Object" "Language.OpenSCAD" "language-openscad-0.1.8-inplace" False) (((C1 (MetaCons "Module" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Argument Expr]) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Object)))) :+: C1 (MetaCons "ForLoop" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object)))) :+: (C1 (MetaCons "Objects" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Object])) :+: (C1 (MetaCons "If" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Object)))) :+: C1 (MetaCons "BackgroundMod" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object))))) :+: ((C1 (MetaCons "DebugMod" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object)) :+: (C1 (MetaCons "RootMod" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object)) :+: C1 (MetaCons "DisableMod" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Object)))) :+: (C1 (MetaCons "ModuleDef" PrefixI True) (S1 (MetaSel (Just "moduleName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: (S1 (MetaSel (Just "moduleArgs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Ident, Maybe Expr)]) :*: S1 (MetaSel (Just "moduleBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Object]))) :+: (C1 (MetaCons "VarDef" PrefixI True) (S1 (MetaSel (Just "varName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: S1 (MetaSel (Just "varValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "FuncDef" PrefixI True) (S1 (MetaSel (Just "funcName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: (S1 (MetaSel (Just "funcArgs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Ident]) :*: S1 (MetaSel (Just "funcBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))))))

object :: Parser Object Source #

Parse an OpenSCAD object

Expressions

data Expr Source #

An OpenSCAD expression

Instances
Eq Expr Source # 
Instance details

Defined in Language.OpenSCAD

Methods

(==) :: Expr -> Expr -> Bool #

(/=) :: Expr -> Expr -> Bool #

Show Expr Source # 
Instance details

Defined in Language.OpenSCAD

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

Generic Expr Source # 
Instance details

Defined in Language.OpenSCAD

Associated Types

type Rep Expr :: Type -> Type #

Methods

from :: Expr -> Rep Expr x #

to :: Rep Expr x -> Expr #

Arbitrary Expr Source # 
Instance details

Defined in Language.OpenSCAD

Methods

arbitrary :: Gen Expr #

shrink :: Expr -> [Expr] #

Pretty Expr Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: Expr -> Doc ann #

prettyList :: [Expr] -> Doc ann #

type Rep Expr Source # 
Instance details

Defined in Language.OpenSCAD

type Rep Expr = D1 (MetaData "Expr" "Language.OpenSCAD" "language-openscad-0.1.8-inplace" False) ((((C1 (MetaCons "EVar" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident)) :+: (C1 (MetaCons "EIndex" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "ENum" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double)))) :+: (C1 (MetaCons "EVec" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Expr])) :+: (C1 (MetaCons "ERange" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Range Expr))) :+: C1 (MetaCons "EString" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))) :+: ((C1 (MetaCons "EBool" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)) :+: (C1 (MetaCons "EFunc" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Ident) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Argument Expr])) :+: C1 (MetaCons "ENegate" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))) :+: (C1 (MetaCons "EPlus" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: (C1 (MetaCons "EMinus" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "EMult" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))))) :+: (((C1 (MetaCons "EDiv" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: (C1 (MetaCons "EMod" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "EEquals" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))) :+: (C1 (MetaCons "ENotEquals" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: (C1 (MetaCons "EGT" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "EGE" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr))))) :+: ((C1 (MetaCons "ELT" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: (C1 (MetaCons "ELE" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "ENot" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))) :+: ((C1 (MetaCons "EOr" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)) :+: C1 (MetaCons "EAnd" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr))) :+: (C1 (MetaCons "ETernary" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr))) :+: C1 (MetaCons "EParen" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Expr)))))))

expression :: Parser Expr Source #

Parse an expression

data Argument a Source #

An item in an argument list

Constructors

Argument a

Just a plain value

NamedArgument Ident a

A named argument

Instances
Eq a => Eq (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

(==) :: Argument a -> Argument a -> Bool #

(/=) :: Argument a -> Argument a -> Bool #

Show a => Show (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

showsPrec :: Int -> Argument a -> ShowS #

show :: Argument a -> String #

showList :: [Argument a] -> ShowS #

Generic (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

Associated Types

type Rep (Argument a) :: Type -> Type #

Methods

from :: Argument a -> Rep (Argument a) x #

to :: Rep (Argument a) x -> Argument a #

Arbitrary a => Arbitrary (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

arbitrary :: Gen (Argument a) #

shrink :: Argument a -> [Argument a] #

Pretty a => Pretty (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: Argument a -> Doc ann #

prettyList :: [Argument a] -> Doc ann #

type Rep (Argument a) Source # 
Instance details

Defined in Language.OpenSCAD

data Range a Source #

Range start end step denotes a list starting at start and stopping at end with increments of step.

Constructors

Range 

Fields

Instances
Eq a => Eq (Range a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

(==) :: Range a -> Range a -> Bool #

(/=) :: Range a -> Range a -> Bool #

Show a => Show (Range a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

showsPrec :: Int -> Range a -> ShowS #

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Arbitrary a => Arbitrary (Range a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

arbitrary :: Gen (Range a) #

shrink :: Range a -> [Range a] #

Pretty a => Pretty (Range a) Source # 
Instance details

Defined in Language.OpenSCAD

Methods

pretty :: Range a -> Doc ann #

prettyList :: [Range a] -> Doc ann #

Generic1 Range Source # 
Instance details

Defined in Language.OpenSCAD

Associated Types

type Rep1 Range :: k -> Type #

Methods

from1 :: Range a -> Rep1 Range a #

to1 :: Rep1 Range a -> Range a #

type Rep1 Range Source # 
Instance details

Defined in Language.OpenSCAD