From 39ef87d3ce39152febc130aa95e25dc0722c3525 Mon Sep 17 00:00:00 2001 From: adelon <22380201+adelon@users.noreply.github.com> Date: Tue, 12 Aug 2025 00:37:28 +0200 Subject: 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`. --- source/Syntax/Adapt.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/Syntax/Adapt.hs') diff --git a/source/Syntax/Adapt.hs b/source/Syntax/Adapt.hs index b338d47..1b5a237 100644 --- a/source/Syntax/Adapt.hs +++ b/source/Syntax/Adapt.hs @@ -124,7 +124,7 @@ head = ScanNoun <$> noun <|> ScanAdj <$> adj <|> ScanVerb <$> verb <|> ScanFun <$> fun - <|> ScanRelationSymbol <$> relationSymbol + <|> ScanRelationSymbol . fst <$> relationSymbol <|> ScanFunctionSymbol <$> functionSymbol <|> ScanPrefixPredicate <$> prefixPredicate @@ -184,14 +184,19 @@ verb = toLexicalPhrase <$> (var *> pat <* iff) fun :: RE Token LexicalPhrase fun = toLexicalPhrase <$> (the *> pat <* (is <|> comma)) -relationSymbol :: RE Token RelationSymbol -relationSymbol = math relator' <* iff +relationSymbol :: RE Token (RelationSymbol, Int) +relationSymbol = definiendum <* iff where - relator' = do + definiendum = math do varSymbol rel <- symbol + k <- params varSymbol - pure rel + pure (rel, k) + params :: RE Token Int + params = do + vars <- many (sym InvisibleBraceL *> var <* sym InvisibleBraceR) + pure (length vars) functionSymbol :: RE Token FunctionSymbol functionSymbol = do -- cgit v1.2.3