Skip to content

Commit

Permalink
Implement parsing of (data…) in NNF queries
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Oct 13, 2024
1 parent 85831c1 commit 9e920ea
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/Refinements-Parsing/NNFParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Class {
'cstrPred',
'funcSort',
'sortArg',
'define'
'define',
'data'
],
#category : #'Refinements-Parsing'
}
Expand Down Expand Up @@ -79,6 +80,35 @@ NNFParser >> cstrPred [
^pred parens ==> [ :x | CstrHead pred: x ]
]

{ #category : #grammar }
NNFParser >> data [
^'data' asParser trim,
self fTyCon trim,
(#digit asParser plus flatten trim ==> #asInteger),
$= asParser trim,
($| asParser trim, self dataCtor trim ==> #second) star brackets
==> [ :x | DataDecl
ddTyCon: x second
ddVars: x third
ddCtors: x fifth ]

]

{ #category : #grammar }
NNFParser >> dataCtor [
^NNFParser upperId trim,
(self dataField commaSeparated optional ==> [ :x | x ifNil: [#()] ifNotNil: [x] ]) braces
==> [ :x | DataCtor dcName: x first dcFields: x second ]
]

{ #category : #grammar }
NNFParser >> dataField [
^ NNFParser upperId trim,
$: asParser trim,
sort
==> [ :x | DataField dfName: x first dfSort: x last ]
]

{ #category : #grammar }
NNFParser >> decidablePred [
^matchedParen
Expand Down Expand Up @@ -234,7 +264,7 @@ NNFParser >> symSort [
{ #category : #grammar }
NNFParser >> thing [
^(constraint / var / qualif / constant / fixpoint / define "match data") parens
^(constraint / var / qualif / constant / fixpoint / define "/ match" / data) parens
]
{ #category : #'grammar - util' }
Expand Down

0 comments on commit 9e920ea

Please sign in to comment.