@@ -14,10 +14,10 @@ import ProjectM36.MiscUtils
1414attributeListP :: RelationalMarkerExpr a => Parser (AttributeNamesBase a)
1515attributeListP =
1616 (reservedOp "all but" >>
17− InvertedAttributeNames . S.fromList <$> sepBy identifier comma) <|>
17+ InvertedAttributeNames . S.fromList <$> sepBy attributeNameP comma) <|>
1818 (reservedOp "all from" >>
1919 RelationalExprAttributeNames <$> relExprP) <|>
20− (AttributeNames . S.fromList <$> sepBy identifier comma)
20+ (AttributeNames . S.fromList <$> sepBy attributeNameP comma)
2121
2222makeRelationP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
2323makeRelationP = do
@@ -31,7 +31,7 @@ makeRelationP = do
3131--Either Text Int
3232adTypeConstructorP :: Parser TypeConstructor
3333adTypeConstructorP = do
34− tConsName <- capitalizedIdentifier
34+ tConsName <- typeConstructorNameP
3535 tConsArgs <- many typeConstructorP
3636 pure $ ADTypeConstructor tConsName tConsArgs
3737
@@ -48,7 +48,7 @@ tupleExprP = do
4848
4949tupleAtomExprP :: RelationalMarkerExpr a => Parser (AttributeName, AtomExprBase a)
5050tupleAtomExprP = do
51− attributeName <- identifier
51+ attributeName <- attributeNameP
5252 atomExpr <- atomExprP
5353 pure (attributeName, atomExpr)
5454
@@ -57,9 +57,9 @@ projectP = Project <$> braces attributeListP
5757
5858renameClauseP :: Parser (T.Text, T.Text)
5959renameClauseP = do
60− oldAttr <- identifier
60+ oldAttr <- attributeNameP
6161 reservedOp "as"
62− newAttr <- identifier
62+ newAttr <- attributeNameP
6363 pure (oldAttr, newAttr)
6464
6565renameP :: Parser (RelationalExprBase a -> RelationalExprBase a)
@@ -78,7 +78,7 @@ groupClauseP :: RelationalMarkerExpr a => Parser (AttributeNamesBase a, T.Text)
7878groupClauseP = do
7979 attrs <- braces attributeListP
8080 reservedOp "as"
81− newAttrName <- identifier
81+ newAttrName <- attributeNameP
8282 pure (attrs, newAttrName)
8383
8484groupP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
@@ -91,7 +91,7 @@ groupP = do
9191ungroupP :: Parser (RelationalExprBase a -> RelationalExprBase a)
9292ungroupP = do
9393 reservedOp "ungroup"
94− Ungroup <$> identifier
94+ Ungroup <$> attributeNameP
9595
9696extendP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a)
9797extendP = do
@@ -130,8 +130,15 @@ relOperators = [
130130relExprP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
131131relExprP = try withMacroExprP <|> makeExprParser relTerm relOperators
132132
133+--allow for additional characters
134+attributeNameP :: Parser AttributeName
135+attributeNameP = uncapitalizedIdentifier
136+
137+relVarNameP :: Parser RelVarName
138+relVarNameP = uncapitalizedIdentifier
139+
133140relVarP :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
134−relVarP = RelationVariable <$> identifier <*> parseMarkerP
141+relVarP = RelationVariable <$> relVarNameP <*> parseMarkerP
135142
136143relTerm :: RelationalMarkerExpr a => Parser (RelationalExprBase a)
137144relTerm = parens relExprP
@@ -158,7 +165,7 @@ relationalBooleanExprP =
158165
159166restrictionAttributeEqualityP :: RelationalMarkerExpr a => Parser (RestrictionPredicateExprBase a)
160167restrictionAttributeEqualityP = do
161− attributeName <- identifier
168+ attributeName <- attributeNameP
162169 reservedOp "="
163170 AttributeEqualityPredicate attributeName <$> atomExprP
164171
@@ -175,7 +182,7 @@ extendTupleExpressionP = attributeExtendTupleExpressionP
175182
176183attributeExtendTupleExpressionP :: RelationalMarkerExpr a => Parser (ExtendTupleExprBase a)
177184attributeExtendTupleExpressionP = do
178− newAttr <- identifier
185+ newAttr <- attributeNameP
179186 reservedOp ":="
180187 AttributeExtendTupleExpr newAttr <$> atomExprP
181188
@@ -193,14 +200,14 @@ consumeAtomExprP consume = try functionAtomExprP <|>
193200attributeAtomExprP :: Parser (AtomExprBase a)
194201attributeAtomExprP = do
195202 _ <- string "@"
196− AttributeAtomExpr <$> identifier
203+ AttributeAtomExpr <$> attributeNameP
197204
198205nakedAtomExprP :: Parser (AtomExprBase a)
199206nakedAtomExprP = NakedAtomExpr <$> atomP
200207
201208constructedAtomExprP :: RelationalMarkerExpr a => Bool -> Parser (AtomExprBase a)
202209constructedAtomExprP consume = do
203− dConsName <- capitalizedIdentifier
210+ dConsName <- dataConstructorNameP
204211 dConsArgs <- if consume then sepBy (consumeAtomExprP False) spaceConsumer else pure []
205212 ConstructedAtomExpr dConsName dConsArgs <$> parseMarkerP
206213
@@ -243,7 +250,7 @@ withMacroExprP = do
243250
244251createViewP :: RelationalMarkerExpr a => Parser (RelVarName, RelationalExprBase a)
245252createViewP = do
246− name <- identifier
253+ name <- relVarNameP
247254 reservedOp "as"
248255 expr <- relExprP
249256 pure (name, expr)