Skip to content
Newer
Older
100644 104 lines (90 sloc) 3.16 KB
e7bd7a9 @feuerbach Split Parse.hs into the files
feuerbach authored Mar 22, 2010
1 module AST where
ec29ecf @feuerbach Introduce locations
feuerbach authored Jun 14, 2010
2
3 import Text.Parsec.Pos (SourcePos)
4
5 type L = (SourcePos, SourcePos)
6
e7bd7a9 @feuerbach Split Parse.hs into the files
feuerbach authored Mar 22, 2010
7 -- A parameter can be denoted by a name, a number, or one of the special
8 -- characters listed in Special Parameters.
9 --
10 -- A variable is a parameter denoted by a name.
11 --
12 -- A positional parameter is a parameter denoted by the decimal value
13 -- represented by one or more digits, other than the single digit 0.
14 type Name = String
15 data Parameter = Var Name
16 | Positional Int
17 | Special Char
18 deriving Show
19
20 data SubstringType = Suffix | Prefix
21 deriving Show
22 data PatternType = Largest | Smallest
23 deriving Show
24 data CheckType = CheckUnset | CheckUnsetAndNull
25 deriving Show
26
27 data ParModifier = UseDefault Word CheckType
28 | AssignDefault Word CheckType
29 | Assert Word CheckType
30 | UseAlternative Word CheckType
31 | StringLength
32 | Remove Word PatternType SubstringType
33 | NoModifier
34 deriving Show
35
36 data ParSubstExpr = ParSubstExpr Parameter ParModifier
37 deriving Show
38
39 data WordPart = Bare String
40 | SQuoted String
41 | DQuoted [WordPart]
42 | Escaped Char
ec29ecf @feuerbach Introduce locations
feuerbach authored Jun 13, 2010
43 | CommandSubst CompoundList L
44 | ParSubst ParSubstExpr L
e7bd7a9 @feuerbach Split Parse.hs into the files
feuerbach authored Mar 22, 2010
45 | Arith [WordPart]
46 deriving Show
47
48 type Word = [WordPart]
49 data Token = Word [WordPart]
50 | Op String
51 deriving Show
52
53 data Redirection = Redirection Int RedirectionOp Word
54 deriving Show
55
56 data StripHereDoc = Strip | NoStrip
57 deriving Show
58 data Clobber = Clobber | NoClobber
59 deriving Show
60 data RedirectionOp = RedirectInput
61 | RedirectOutput Clobber
62 | AppendOutput
6211fe4 @feuerbach First approximation of heredoc parsing (fixme)
feuerbach authored Jun 15, 2010
63 | HereDoc StripHereDoc Int
e7bd7a9 @feuerbach Split Parse.hs into the files
feuerbach authored Mar 22, 2010
64 | DupInput
65 | DupOutput
66 | ReadWrite
67 deriving Show
68
69 data Assignment = Assignment Name Word
70 deriving Show
71
72 data Command = ComSimple SimpleCommand
73 | ComCompound CompoundCommand [Redirection]
74 | ComFunction FunctionDefinition
75 deriving Show
76 data FunctionDefinition =
77 FunctionDefinition Name CompoundCommand [Redirection]
78 deriving Show
79 data SimpleCommand = SimpleCommand [Assignment] [Redirection] [Word]
80 deriving Show
81 data ForList = ForWords [Word] | ForPositional
82 deriving Show
83 data CompoundCommand = BraceGroup CompoundList
84 | SubShell CompoundList
85 | For Name ForList CompoundList
86 | Case Word [([Word],CompoundList)]
87 | If [(CompoundList,CompoundList)] -- 'if' and 'elif'
88 (Maybe CompoundList) -- optional 'else'
89 | While CompoundList CompoundList
90 | Until CompoundList CompoundList
91 deriving Show
92 data PipelineStatus = Straight | Inverted
93 deriving Show
94 data Pipeline = Pipeline PipelineStatus [Command]
95 deriving Show
96 data AndOrList = First Pipeline
97 | And Pipeline AndOrList
98 | Or Pipeline AndOrList
99 deriving Show
100 data ExecutionMode = Seq | Async
101 deriving Show
102 type CompoundList = [(AndOrList,ExecutionMode)]
103
Something went wrong with that request. Please try again.