Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
peregrine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
i7
peregrine
Commits
c4a94af6
Commit
c4a94af6
authored
May 06, 2014
by
Philipp Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Combined Petri net and property parser
parent
a786fec0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/Parser.hs
src/Parser.hs
+13
-10
No files found.
src/Parser.hs
View file @
c4a94af6
...
...
@@ -113,7 +113,6 @@ petriNet = do
reserved
"net"
name
<-
option
""
ident
statements
<-
braces
(
many
statement
)
eof
let
(
p
,
t
,
a
,
i
)
=
foldl
splitStatement
(
[]
,
[]
,
[]
,
[]
)
statements
return
$
makePetriNet
name
p
t
a
i
where
...
...
@@ -128,14 +127,13 @@ preFactor = (reservedOp "-" *> return (-1)) <|>
(
reservedOp
"+"
*>
return
1
)
linAtom
::
Integer
->
Parser
u
LinAtom
linAtom
fac
=
(
natural
>>=
\
lhs
->
option
(
Const
(
fac
*
lhs
))
((
Var
(
fac
*
lhs
))
<$>
(
reservedOp
"*"
*>
ident
))
)
<|>
((
Var
fac
)
<$>
ident
)
linAtom
fac
=
(
integer
>>=
\
lhs
->
option
(
Const
(
fac
*
lhs
))
$
Var
(
fac
*
lhs
)
<$>
(
reservedOp
"*"
*>
ident
)
)
<|>
Var
fac
<$>
ident
term
::
Parser
u
Term
term
=
Term
<$>
((
:
)
<$>
(
option
1
preFactor
>>=
linAtom
)
<*>
(
many
(
preFactor
>>=
linAtom
)
))
many
(
preFactor
>>=
linAtom
))
parseOp
::
Parser
u
Op
parseOp
=
(
reservedOp
"<"
*>
return
Lt
)
<|>
...
...
@@ -183,16 +181,21 @@ property = do
pformulas
<-
braces
formula
return
$
Property
name
ptype
pformulas
parseContent
::
Parser
u
Property
parseContent
=
whiteSpace
*>
property
parseContent
::
Parser
u
(
PetriNet
,[
Property
])
parseContent
=
do
whiteSpace
net
<-
petriNet
properties
<-
many
property
eof
return
(
net
,
properties
)
parseString
::
String
->
Property
parseString
::
String
->
(
PetriNet
,[
Property
])
parseString
str
=
case
parse
parseContent
""
str
of
Left
e
->
error
$
show
e
Right
r
->
r
parseFile
::
String
->
IO
Property
parseFile
::
String
->
IO
(
PetriNet
,[
Property
])
parseFile
file
=
do
contents
<-
readFile
file
case
parse
parseContent
file
contents
of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment