summaryrefslogtreecommitdiff
path: root/source/Syntax/Concrete.hs
diff options
context:
space:
mode:
authoradelon <22380201+adelon@users.noreply.github.com>2025-08-12 00:37:28 +0200
committeradelon <22380201+adelon@users.noreply.github.com>2025-08-12 00:37:28 +0200
commit39ef87d3ce39152febc130aa95e25dc0722c3525 (patch)
tree018ce21f85bc132306ac5130db405527a313c1a7 /source/Syntax/Concrete.hs
parentafce89ead823b6e9eec4a0b115bbe57a89a8e912 (diff)
Allow relation symbols with parameters
Parameters must follow the relation symbol and be surrounded by braces, like so: `\rel{x}{y}{z}`. This attempt is still brittle/broken in a few ways: - It makes using braces in creative ways in mixfix notation ambiguous. - It does not verify that the parameters are used in a consistent manner for each symbol. It essentially allows users to define `a\MyRel b` and `a\MyRel{x} b` (and ones with even more parameters). - It allows parameters for all relation symbols, even for those where it makes no sense in ordinary TeX markup, e.g. `a <{x} b`.
Diffstat (limited to 'source/Syntax/Concrete.hs')
-rw-r--r--source/Syntax/Concrete.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/Syntax/Concrete.hs b/source/Syntax/Concrete.hs
index 383f348..3c6700b 100644
--- a/source/Syntax/Concrete.hs
+++ b/source/Syntax/Concrete.hs
@@ -84,8 +84,8 @@ grammar lexicon@Lexicon{..} = mdo
relationSign <- rule $ pure Positive <|> (Negative <$ command "not")
relationExpr <- rule $ RelationExpr <$> (command "mathrel" *> group expr)
relation <- rule $ (RelationSymbol <$> relator) <|> relationExpr
- chainBase <- rule $ ChainBase <$> exprs <*> relationSign <*> relation <*> exprs
- chainCons <- rule $ ChainCons <$> exprs <*> relationSign <*> relation <*> chain
+ chainBase <- rule $ ChainBase <$> exprs <*> relationSign <*> relation <*> many (brace expr) <*> exprs
+ chainCons <- rule $ ChainCons <$> exprs <*> relationSign <*> relation <*> many (brace expr) <*> chain
chain <- rule $ chainCons <|> chainBase
formulaPredicate <- rule $ asum $ prefixPredicateOf FormulaPredicate expr <$> HM.keys lexiconPrefixPredicates
@@ -250,7 +250,7 @@ grammar lexicon@Lexicon{..} = mdo
defnAdj <- rule $ DefnAdj <$> optional (_an *> nounPhrase) <*> var <* _is <*> adjVar
defnVerb <- rule $ DefnVerb <$> optional (_an *> nounPhrase) <*> var <*> verbVar
defnNoun <- rule $ DefnNoun <$> var <* _is <* _an <*> nounVar
- defnRel <- rule $ DefnRel <$> (beginMath *> varSymbol) <*> relator <*> varSymbol <* endMath
+ defnRel <- rule $ DefnRel <$> (beginMath *> varSymbol) <*> relator <*> many (group varSymbol) <*> varSymbol <* endMath
defnSymbolicPredicate <- rule $ math $ asum $ prefixPredicateOf DefnSymbolicPredicate varSymbol <$> HM.keys lexiconPrefixPredicates
defnHead <- rule $ optional _write *> asum [defnAdj, defnVerb, defnNoun, defnRel, defnSymbolicPredicate]
@@ -269,7 +269,7 @@ grammar lexicon@Lexicon{..} = mdo
abbreviationVerb <- rule $ AbbreviationVerb <$> var <*> verbVar <* (_iff <|> _if) <*> stmt <* _dot
abbreviationAdj <- rule $ AbbreviationAdj <$> var <* _is <*> adjVar <* (_iff <|> _if) <*> stmt <* _dot
abbreviationNoun <- rule $ AbbreviationNoun <$> var <* _is <* _an <*> nounVar <* (_iff <|> _if) <*> stmt <* _dot
- abbreviationRel <- rule $ AbbreviationRel <$> (beginMath *> varSymbol) <*> relator <*> varSymbol <* endMath <* (_iff <|> _if) <*> stmt <* _dot
+ abbreviationRel <- rule $ AbbreviationRel <$> (beginMath *> varSymbol) <*> relator <*> many (brace varSymbol) <*> varSymbol <* endMath <* (_iff <|> _if) <*> stmt <* _dot
abbreviationFun <- rule $ AbbreviationFun <$> (_the *> funVar) <* (_is <|> _denotes) <*> term <* _dot
abbreviationEq <- rule $ uncurry AbbreviationEq <$> symbolicPatternEqTerm
abbreviation <- rule $ (abbreviationVerb <|> abbreviationAdj <|> abbreviationNoun <|> abbreviationRel <|> abbreviationFun <|> abbreviationEq)