@@ -14,10 +14,10 @@ import ProjectM36.MiscUtils
14attributeListP :: RelationalMarkerExpr a => Parser (AttributeNamesBase a)
14attributeListP :: RelationalMarkerExpr a => Parser (AttributeNamesBase a)
15attributeListP =
15attributeListP =
16 (reservedOp "all but" >>
16 (reservedOp "all but" >>
17− InvertedAttributeNames . S.fromList <$> sepBy identifier comma) <|>
17+ InvertedAttributeNames . S.fromList <$> sepBy attributeNameP comma) <|>
18 (reservedOp "all from" >>
18 (reservedOp "all from" >>
19 RelationalExprAttributeNames <$> relExprP) <|>
19 RelationalExprAttributeNames <$> relExprP) <|>
20− (AttributeNames . S.fromList <$> sepBy identifier comma)
20+ (AttributeNames . S.fromList <$> sepBy attributeNameP comma)
22makeRelationP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
22makeRelationP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
23makeRelationP = do
23makeRelationP = do
@@ -31,7 +31,7 @@ makeRelationP = do
31--Either Text Int
31--Either Text Int
32adTypeConstructorP :: Parser TypeConstructor
32adTypeConstructorP :: Parser TypeConstructor
33adTypeConstructorP = do
33adTypeConstructorP = do
34− tConsName <- capitalizedIdentifier
34+ tConsName <- typeConstructorNameP
35 tConsArgs <- many typeConstructorP
35 tConsArgs <- many typeConstructorP
36 pure $ ADTypeConstructor tConsName tConsArgs
36 pure $ ADTypeConstructor tConsName tConsArgs
@@ -48,7 +48,7 @@ tupleExprP = do
49tupleAtomExprP :: RelationalMarkerExpr a => Parser (AttributeName, AtomExprBase a)
49tupleAtomExprP :: RelationalMarkerExpr a => Parser (AttributeName, AtomExprBase a)
50tupleAtomExprP = do
50tupleAtomExprP = do
51− attributeName <- identifier
51+ attributeName <- attributeNameP
52 atomExpr <- atomExprP
52 atomExpr <- atomExprP
53 pure (attributeName, atomExpr)
53 pure (attributeName, atomExpr)
@@ -57,9 +57,9 @@ projectP = Project <$> braces attributeListP
58renameClauseP :: Parser (T.Text, T.Text)
58renameClauseP :: Parser (T.Text, T.Text)
59renameClauseP = do
59renameClauseP = do
60− oldAttr <- identifier
60+ oldAttr <- attributeNameP
61 reservedOp "as"
61 reservedOp "as"
62− newAttr <- identifier
62+ newAttr <- attributeNameP
63 pure (oldAttr, newAttr)
63 pure (oldAttr, newAttr)
65renameP :: Parser (RelationalExprBase a -> RelationalExprBase a)
65renameP :: Parser (RelationalExprBase a -> RelationalExprBase a)
@@ -78,7 +78,7 @@ groupClauseP :: RelationalMarkerExpr a => Parser (AttributeNamesBase a, T.Text)
78groupClauseP = do
78groupClauseP = do
79 attrs <- braces attributeListP
79 attrs <- braces attributeListP
80 reservedOp "as"
80 reservedOp "as"
81− newAttrName <- identifier
81+ newAttrName <- attributeNameP
82 pure (attrs, newAttrName)
82 pure (attrs, newAttrName)
84groupP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
84groupP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
@@ -91,7 +91,7 @@ groupP = do
91ungroupP :: Parser (RelationalExprBase a -> RelationalExprBase a)
91ungroupP :: Parser (RelationalExprBase a -> RelationalExprBase a)
92ungroupP = do
92ungroupP = do
93 reservedOp "ungroup"
93 reservedOp "ungroup"
94− Ungroup <$> identifier
94+ Ungroup <$> attributeNameP
96extendP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
96extendP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
97extendP = do
97extendP = do
@@ -130,8 +130,15 @@ relOperators = [
130relExprP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
130relExprP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
131relExprP = try withMacroExprP <|> makeExprParser relTerm relOperators
131relExprP = try withMacroExprP <|> makeExprParser relTerm relOperators
133+--allow for additional characters
134+attributeNameP :: Parser AttributeName
135+attributeNameP = uncapitalizedIdentifier
137+relVarNameP :: Parser RelVarName
138+relVarNameP = uncapitalizedIdentifier
133relVarP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
140relVarP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
134−relVarP = RelationVariable <$> identifier <*> parseMarkerP
141+relVarP = RelationVariable <$> relVarNameP <*> parseMarkerP
136relTerm :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
143relTerm :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
137relTerm = parens relExprP
144relTerm = parens relExprP
@@ -158,7 +165,7 @@ relationalBooleanExprP =
159restrictionAttributeEqualityP :: RelationalMarkerExpr a => Parser (RestrictionPredicateExprBase a)
166restrictionAttributeEqualityP :: RelationalMarkerExpr a => Parser (RestrictionPredicateExprBase a)
160restrictionAttributeEqualityP = do
167restrictionAttributeEqualityP = do
161− attributeName <- identifier
168+ attributeName <- attributeNameP
162 reservedOp "="
169 reservedOp "="
163 AttributeEqualityPredicate attributeName <$> atomExprP
170 AttributeEqualityPredicate attributeName <$> atomExprP
@@ -175,7 +182,7 @@ extendTupleExpressionP = attributeExtendTupleExpressionP
176attributeExtendTupleExpressionP :: RelationalMarkerExpr a => Parser (ExtendTupleExprBase a)
183attributeExtendTupleExpressionP :: RelationalMarkerExpr a => Parser (ExtendTupleExprBase a)
177attributeExtendTupleExpressionP = do
184attributeExtendTupleExpressionP = do
178− newAttr <- identifier
185+ newAttr <- attributeNameP
179 reservedOp ":="
186 reservedOp ":="
180 AttributeExtendTupleExpr newAttr <$> atomExprP
187 AttributeExtendTupleExpr newAttr <$> atomExprP
@@ -193,14 +200,14 @@ consumeAtomExprP consume = try functionAtomExprP <|>
193attributeAtomExprP :: Parser (AtomExprBase a)
200attributeAtomExprP :: Parser (AtomExprBase a)
194attributeAtomExprP = do
201attributeAtomExprP = do
195 _ <- string "@"
202 _ <- string "@"
196− AttributeAtomExpr <$> identifier
203+ AttributeAtomExpr <$> attributeNameP
198nakedAtomExprP :: Parser (AtomExprBase a)
205nakedAtomExprP :: Parser (AtomExprBase a)
199nakedAtomExprP = NakedAtomExpr <$> atomP
206nakedAtomExprP = NakedAtomExpr <$> atomP
201constructedAtomExprP :: RelationalMarkerExpr a => Bool -> Parser (AtomExprBase a)
208constructedAtomExprP :: RelationalMarkerExpr a => Bool -> Parser (AtomExprBase a)
202constructedAtomExprP consume = do
209constructedAtomExprP consume = do
203− dConsName <- capitalizedIdentifier
210+ dConsName <- dataConstructorNameP
204 dConsArgs <- if consume then sepBy (consumeAtomExprP False) spaceConsumer else pure []
211 dConsArgs <- if consume then sepBy (consumeAtomExprP False) spaceConsumer else pure []
205 ConstructedAtomExpr dConsName dConsArgs <$> parseMarkerP
212 ConstructedAtomExpr dConsName dConsArgs <$> parseMarkerP
@@ -243,7 +250,7 @@ withMacroExprP = do
244createViewP :: RelationalMarkerExpr a => Parser (RelVarName, RelationalExprBase a)
251createViewP :: RelationalMarkerExpr a => Parser (RelVarName, RelationalExprBase a)
245createViewP = do
252createViewP = do
246− name <- identifier
253+ name <- relVarNameP
247 reservedOp "as"
254 reservedOp "as"
248 expr <- relExprP
255 expr <- relExprP
249 pure (name, expr)
256 pure (name, expr)