Skip to content

Commit

Permalink
doc makeKeyword
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Dec 2, 2024
1 parent 02856c8 commit a0cf2b2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion M2/Macaulay2/d/actors5.d
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export makeKeywordFun(e:Expr):Expr := (
w:=makeUniqueWord(s.v, parseinfo(prec,bprec,uprec,parsefuns(u,t)));
when globalLookup(w) is x:Symbol do buildErrorPacket("symbol already in use")
else (
install(s.v,w); -- TODO check whether install is really needed (for mathematical symbols as opposed to words)
install(s.v,w); -- install may not be needed (for words as opposed to mathematical symbols) but it doesn't hurt TODO rethink
Expr(makeKeyword(w)))
))
else WrongArg(4,"a boolean")
Expand Down
4 changes: 2 additions & 2 deletions M2/Macaulay2/d/binding.d
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ special(s:string,f:function(Token,TokenFile,int,bool):ParseTree,lprec:int,rprec:
-- created below are all in the global dictionary.

-- new operators must be:
-- set up as an "actor" with "setup()" -- or not TODO explain
-- set up as an "actor" with "setup()" if they have nonstandard syntax
-- (without "setup()", M2 will just lookup a method)
-- added to the export list in ../m2/exports.m2
-- added to the table binaryOperatorFunctions in ../m2/expressions.m2
-- added to the list of operators in the documentation node "operators" in ../packages/Macaulay2Doc/ov_language.m2
-- documented with a suitable headline, such as:
-- "a unary operator"
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/packages/Macaulay2Doc/functions.m2
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ load "./functions/lift-doc.m2"
load "./functions/liftable-doc.m2"
load "./functions/locate-doc.m2"
load "./functions/LU-doc.m2"
load "./functions/makeKeyword-doc.m2"
load "./functions/map-doc.m2"
load "./functions/max-doc.m2"
load "./functions/maxPosition-doc.m2"
Expand Down
29 changes: 29 additions & 0 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/makeKeyword-doc.m2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- status: DRAFT
--- author(s): PZJ
--- notes:

doc ///
Key
makeKeyword
(makeKeyword, String)
[makeKeyword, Precedence]
[makeKeyword, Syntax]
Headline
create a new keyword
Usage
makeKeyword s
Inputs
s: String
Precedence => {ZZ,Symbol}
Syntax => {List,Symbol}
Description
Text
Creates a new Keyword out of the input string.
The options specify the parsing behavior of the keyword.
Possible choices for @TT "Syntax"@ are: @TT "Binary"@, @TT "Prefix"@, @TT "Postfix"@ or @TT "{Binary,Prefix}"@.
If @TT "Precedence"@ is a @TT "Symbol"@, the precedence is set to the one of that symbol.
Example
makeKeyword("",Precedence => symbol <)
ZZZZ := (i,j) -> j==i+1
3≺4
///

0 comments on commit a0cf2b2

Please sign in to comment.