working on jEdit plugin
parent
c502ea889e
commit
eb86c229e0
|
|
@ -3,18 +3,14 @@
|
|||
- update plugin docs
|
||||
- word preview for remote words
|
||||
- faster completion
|
||||
|
||||
- [ [ dup call ] dup call ] infer hangs
|
||||
- type inference fails with some assembler words;
|
||||
displaced, register and other predicates need to inherit from list
|
||||
not cons, and need stronger branch partial eval
|
||||
- print warning on null class
|
||||
- optimize away dispatch
|
||||
|
||||
- code gc
|
||||
- #jump-f #jump-f-label
|
||||
- extract word inside M:, C:, and structure browsing for these
|
||||
- fix completion invoke in middle of word
|
||||
- don't hardcode so many colors
|
||||
- ffi unicode strings: null char security hole
|
||||
- utf16 string boxing
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ public class DefaultVocabularyLookup implements VocabularyLookup
|
|||
|
||||
/* comments */
|
||||
FactorWord lineComment = define("syntax","!");
|
||||
lineComment.parsing = new LineComment(lineComment,false);
|
||||
lineComment.parsing = new LineComment(lineComment);
|
||||
FactorWord stackComment = define("syntax","(");
|
||||
stackComment.parsing = new StackComment(stackComment);
|
||||
FactorWord docComment = define("syntax","#!");
|
||||
docComment.parsing = new LineComment(docComment,true);
|
||||
docComment.parsing = new LineComment(docComment);
|
||||
|
||||
/* strings */
|
||||
FactorWord str = define("syntax","\"");
|
||||
|
|
@ -91,7 +91,6 @@ public class DefaultVocabularyLookup implements VocabularyLookup
|
|||
/* word defs */
|
||||
FactorWord def = define("syntax",":");
|
||||
def.parsing = new Def(def);
|
||||
def.docComment = true;
|
||||
FactorWord ine = define("syntax",";");
|
||||
ine.parsing = new Ine(ine);
|
||||
FactorWord symbol = define("syntax","SYMBOL:");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/* :folding=explicit:collapseFolds=1: */
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2005 Slava Pestov.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package factor;
|
||||
|
||||
public abstract class FactorArtifact
|
||||
{
|
||||
private String file;
|
||||
private int line;
|
||||
private int col;
|
||||
|
||||
public String getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file)
|
||||
{
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public int getLine()
|
||||
{
|
||||
return line;
|
||||
}
|
||||
|
||||
public void setLine(int line)
|
||||
{
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public int getColumn()
|
||||
{
|
||||
return col;
|
||||
}
|
||||
|
||||
public void setColumn(int column)
|
||||
{
|
||||
this.col = col;
|
||||
}
|
||||
|
||||
public abstract String getShortString();
|
||||
public abstract String getLongString();
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class FactorReader
|
|||
private String in;
|
||||
private int base = 10;
|
||||
|
||||
private Cons definedWords;
|
||||
private Cons artifacts;
|
||||
|
||||
//{{{ getUnreadableString() method
|
||||
public static String getUnreadableString(String str)
|
||||
|
|
@ -254,10 +254,16 @@ public class FactorReader
|
|||
return word;
|
||||
} //}}}
|
||||
|
||||
//{{{ getDefinedWords() method
|
||||
public Cons getDefinedWords()
|
||||
//{{{ getArtifacts() method
|
||||
public Cons getArtifacts()
|
||||
{
|
||||
return Cons.reverse(definedWords);
|
||||
return Cons.reverse(artifacts);
|
||||
} //}}}
|
||||
|
||||
//{{{ addArtifact() method
|
||||
public void addArtifact(FactorArtifact artifact)
|
||||
{
|
||||
artifacts = new Cons(artifact,artifacts);
|
||||
} //}}}
|
||||
|
||||
//{{{ nextWord() method
|
||||
|
|
@ -282,10 +288,10 @@ public class FactorReader
|
|||
FactorWord w = intern((String)next,define);
|
||||
if(define && w != null)
|
||||
{
|
||||
definedWords = new Cons(w,definedWords);
|
||||
w.line = line;
|
||||
w.col = col;
|
||||
w.file = scanner.getFileName();
|
||||
artifacts = new Cons(w,artifacts);
|
||||
w.setFile(scanner.getFileName());
|
||||
w.setLine(line);
|
||||
w.setColumn(col);
|
||||
w.stackEffect = null;
|
||||
w.documentation = null;
|
||||
}
|
||||
|
|
@ -416,21 +422,6 @@ public class FactorReader
|
|||
getCurrentState().setStackComment(comment);
|
||||
} //}}}
|
||||
|
||||
//{{{ addDocComment() method
|
||||
public void addDocComment(String comment)
|
||||
{
|
||||
getCurrentState().addDocComment(comment);
|
||||
} //}}}
|
||||
|
||||
//{{{ bar() method
|
||||
/**
|
||||
* Sets the current parser state's cdr to the given object.
|
||||
*/
|
||||
public void bar() throws FactorParseException
|
||||
{
|
||||
getCurrentState().bar();
|
||||
} //}}}
|
||||
|
||||
//{{{ error() method
|
||||
public void error(String msg) throws FactorParseException
|
||||
{
|
||||
|
|
@ -444,27 +435,14 @@ public class FactorReader
|
|||
public FactorWord defining;
|
||||
public Cons first;
|
||||
public Cons last;
|
||||
private boolean bar;
|
||||
private boolean docComment;
|
||||
|
||||
ParseState(FactorWord start, FactorWord defining)
|
||||
{
|
||||
docComment = start.docComment;
|
||||
this.start = start;
|
||||
this.defining = defining;
|
||||
}
|
||||
|
||||
void append(Object obj) throws FactorParseException
|
||||
{
|
||||
docComment = false;
|
||||
|
||||
if(bar)
|
||||
{
|
||||
if(last.cdr != null)
|
||||
scanner.error("Only one token allowed after |");
|
||||
last.cdr = obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cons next = new Cons(obj,null);
|
||||
if(first == null)
|
||||
|
|
@ -473,39 +451,11 @@ public class FactorReader
|
|||
last.cdr = next;
|
||||
last = next;
|
||||
}
|
||||
}
|
||||
|
||||
void setStackComment(String comment)
|
||||
{
|
||||
if(defining != null && defining.stackEffect == null)
|
||||
defining.stackEffect = comment;
|
||||
}
|
||||
|
||||
void addDocComment(String comment)
|
||||
{
|
||||
if(defining != null && (docComment || alwaysDocComments))
|
||||
{
|
||||
if(defining.documentation == null)
|
||||
defining.documentation = comment;
|
||||
else
|
||||
{
|
||||
/* Its O(n^2). Big deal. */
|
||||
defining.documentation = defining.documentation
|
||||
.concat(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bar() throws FactorParseException
|
||||
{
|
||||
if(last.cdr != null)
|
||||
{
|
||||
// We already read [ a | b
|
||||
// no more can be appended to this state.
|
||||
scanner.error("Only one token allowed after |");
|
||||
}
|
||||
|
||||
bar = true;
|
||||
}
|
||||
} //}}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@
|
|||
|
||||
package factor;
|
||||
|
||||
public class FactorWord implements FactorExternalizable
|
||||
import factor.jedit.FactorWordRenderer;
|
||||
|
||||
public class FactorWord extends FactorArtifact implements FactorExternalizable
|
||||
{
|
||||
public String vocabulary;
|
||||
public String name;
|
||||
|
|
@ -46,18 +48,6 @@ public class FactorWord implements FactorExternalizable
|
|||
*/
|
||||
private FactorWord definer;
|
||||
|
||||
/**
|
||||
* Should the parser keep doc comments?
|
||||
*/
|
||||
public boolean docComment;
|
||||
|
||||
/**
|
||||
* For text editor integration.
|
||||
*/
|
||||
public String file;
|
||||
public int line;
|
||||
public int col;
|
||||
|
||||
//{{{ FactorWord constructor
|
||||
public FactorWord(String vocabulary, String name)
|
||||
{
|
||||
|
|
@ -85,4 +75,16 @@ public class FactorWord implements FactorExternalizable
|
|||
{
|
||||
this.definer = definer;
|
||||
} //}}}
|
||||
|
||||
//{{{ getShortString() method
|
||||
public String getShortString()
|
||||
{
|
||||
return name;
|
||||
} //}}}
|
||||
|
||||
//{{{ getLongString() method
|
||||
public String getLongString()
|
||||
{
|
||||
return FactorWordRenderer.getWordHTMLString(this,false);
|
||||
} //}}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
/* :folding=explicit:collapseFolds=1: */
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2005 Slava Pestov.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package factor;
|
||||
|
||||
import factor.jedit.FactorWordRenderer;
|
||||
import org.gjt.sp.jedit.jEdit;
|
||||
|
||||
public class MethodArtifact extends FactorArtifact
|
||||
implements FactorExternalizable
|
||||
{
|
||||
private FactorWord type;
|
||||
private FactorWord generic;
|
||||
|
||||
//{{{ MethodArtifact constructor
|
||||
public MethodArtifact(FactorWord type, FactorWord generic)
|
||||
{
|
||||
this.type = type;
|
||||
this.generic = generic;
|
||||
} //}}}
|
||||
|
||||
//{{{ getShortString() method
|
||||
public String getShortString()
|
||||
{
|
||||
return type.name + " " + generic.name;
|
||||
} //}}}
|
||||
|
||||
//{{{ getLongString() method
|
||||
public String getLongString()
|
||||
{
|
||||
return jEdit.getProperty("factor.completion.method",
|
||||
new String[] { type.name, generic.name });
|
||||
} //}}}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
package factor.jedit;
|
||||
|
||||
import factor.FactorWord;
|
||||
import factor.*;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.text.Position;
|
||||
import org.gjt.sp.jedit.Buffer;
|
||||
|
|
@ -37,12 +37,12 @@ import sidekick.*;
|
|||
|
||||
public class FactorAsset extends Asset
|
||||
{
|
||||
private FactorWord word;
|
||||
private FactorArtifact artifact;
|
||||
|
||||
public FactorAsset(FactorWord word, Position start)
|
||||
public FactorAsset(FactorArtifact artifact, Position start)
|
||||
{
|
||||
super(word.name);
|
||||
this.word = word;
|
||||
super(artifact.getShortString());
|
||||
this.artifact = artifact;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +53,11 @@ public class FactorAsset extends Asset
|
|||
|
||||
public String getShortString()
|
||||
{
|
||||
return word.name;
|
||||
return artifact.getShortString();
|
||||
}
|
||||
|
||||
public String getLongString()
|
||||
{
|
||||
return FactorWordRenderer.getWordHTMLString(word,false);
|
||||
return artifact.getLongString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public abstract class FactorBufferProcessor
|
|||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
Cons words = (Cons)buffer.getProperty(
|
||||
FactorSideKickParser.WORDS_PROPERTY);
|
||||
FactorSideKickParser.ARTIFACTS_PROPERTY);
|
||||
Cons wordCodeMap = null;
|
||||
while(words != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2004 Slava Pestov.
|
||||
* Copyright (C) 2004, 2005 Slava Pestov.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
|
@ -80,7 +80,7 @@ public class FactorPlugin extends EditPlugin
|
|||
Buffer buffer = jEdit.getFirstBuffer();
|
||||
while(buffer != null)
|
||||
{
|
||||
buffer.setProperty(FactorSideKickParser.WORDS_PROPERTY,null);
|
||||
buffer.setProperty(FactorSideKickParser.ARTIFACTS_PROPERTY,null);
|
||||
buffer = buffer.getNext();
|
||||
}
|
||||
} //}}}
|
||||
|
|
@ -681,6 +681,7 @@ public class FactorPlugin extends EditPlugin
|
|||
buffer.indentLines(firstLine,lastLine);
|
||||
|
||||
textArea.setSelectedText(newWord);
|
||||
buffer.indentLine(textArea.getCaretLine(),true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ mode.factor.sidekick.parser=factor
|
|||
factor.completion.in=<font color="#a0a0a0">IN: {0}</font>\
|
||||
factor.completion.def={0} <b>{1}</b>
|
||||
factor.completion.stack={0} ( {1})
|
||||
factor.completion.method=<html>M: <b>{0} {1}</b>
|
||||
factor.completion.constructor=<html>C: <b>{0}</b>
|
||||
|
||||
# Dialog boxes
|
||||
factor.status.inserted-use=Using {0}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class FactorSideKickParser extends SideKickParser
|
|||
/**
|
||||
* We store the file's parse tree in this property.
|
||||
*/
|
||||
public static String WORDS_PROPERTY = "factor-parsed";
|
||||
public static String ARTIFACTS_PROPERTY = "factor-parsed";
|
||||
|
||||
private Map previewMap;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ public class FactorSideKickParser extends SideKickParser
|
|||
public SideKickParsedData parse(Buffer buffer,
|
||||
DefaultErrorSource errorSource)
|
||||
{
|
||||
Object words = buffer.getProperty(WORDS_PROPERTY);
|
||||
Object words = buffer.getProperty(ARTIFACTS_PROPERTY);
|
||||
if(words instanceof Cons)
|
||||
forgetWords((Cons)words);
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ public class FactorSideKickParser extends SideKickParser
|
|||
d.in = r.getIn();
|
||||
d.use = r.getUse();
|
||||
|
||||
addWordDefNodes(d,r.getDefinedWords(),buffer);
|
||||
addArtifactNodes(d,r.getArtifacts(),buffer);
|
||||
}
|
||||
catch(FactorParseException pe)
|
||||
{
|
||||
|
|
@ -152,7 +152,7 @@ public class FactorSideKickParser extends SideKickParser
|
|||
}
|
||||
|
||||
if(r != null)
|
||||
buffer.setProperty(WORDS_PROPERTY,r.getDefinedWords());
|
||||
buffer.setProperty(ARTIFACTS_PROPERTY,r.getArtifacts());
|
||||
|
||||
return d;
|
||||
} //}}}
|
||||
|
|
@ -171,21 +171,24 @@ public class FactorSideKickParser extends SideKickParser
|
|||
}
|
||||
} //}}}
|
||||
|
||||
//{{{ addWordDefNodes() method
|
||||
private void addWordDefNodes(FactorParsedData d, Cons words, Buffer buffer)
|
||||
//{{{ addArtifactNodes() method
|
||||
private void addArtifactNodes(FactorParsedData d, Cons artifacts, Buffer buffer)
|
||||
{
|
||||
FactorAsset last = null;
|
||||
|
||||
while(words != null)
|
||||
while(artifacts != null)
|
||||
{
|
||||
FactorWord word = (FactorWord)words.car;
|
||||
FactorArtifact artifact = (FactorArtifact)artifacts.car;
|
||||
|
||||
/* word lines are indexed from 1 */
|
||||
int startLine = Math.max(0,Math.min(
|
||||
/* artifact lines are indexed from 1 */
|
||||
int startLine = artifact.getLine();
|
||||
startLine = Math.max(0,Math.min(
|
||||
buffer.getLineCount() - 1,
|
||||
word.line - 1));
|
||||
startLine - 1));
|
||||
int startLineLength = buffer.getLineLength(startLine);
|
||||
int startCol = Math.min(word.col,startLineLength);
|
||||
|
||||
int startCol = artifact.getColumn();
|
||||
startCol = Math.min(startCol,startLineLength);
|
||||
|
||||
int start = buffer.getLineStartOffset(startLine)
|
||||
+ startCol;
|
||||
|
|
@ -193,10 +196,10 @@ public class FactorSideKickParser extends SideKickParser
|
|||
if(last != null)
|
||||
last.end = buffer.createPosition(Math.max(0,start - 1));
|
||||
|
||||
last = new FactorAsset(word,buffer.createPosition(start));
|
||||
last = new FactorAsset(artifact,buffer.createPosition(start));
|
||||
d.root.add(new DefaultMutableTreeNode(last));
|
||||
|
||||
words = words.next();
|
||||
artifacts = artifacts.next();
|
||||
}
|
||||
|
||||
if(last != null)
|
||||
|
|
@ -264,13 +267,13 @@ public class FactorSideKickParser extends SideKickParser
|
|||
String text = buffer.getText(lineStart,caret - lineStart);
|
||||
|
||||
/* Don't complete in the middle of a word */
|
||||
int lineEnd = buffer.getLineEndOffset(caretLine) - 1;
|
||||
/* int lineEnd = buffer.getLineEndOffset(caretLine) - 1;
|
||||
if(caret != lineEnd)
|
||||
{
|
||||
String end = buffer.getText(caret,lineEnd - caret);
|
||||
if(!isWhitespace(end.charAt(0)))
|
||||
return null;
|
||||
}
|
||||
} */
|
||||
|
||||
int wordStart = 0;
|
||||
for(int i = text.length() - 1; i >= 0; i--)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class BeginConstructor extends FactorParsingDefinition
|
|||
return;
|
||||
|
||||
reader.intern("<" + type + ">",true);
|
||||
|
||||
reader.addArtifact(new ConstructorArtifact(type));
|
||||
reader.pushExclusiveState(word,type);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,14 +41,24 @@ public class BeginMethod extends FactorParsingDefinition
|
|||
public void eval(FactorReader reader)
|
||||
throws Exception
|
||||
{
|
||||
// remember the position before the word name
|
||||
FactorScanner scanner = reader.getScanner();
|
||||
int line = scanner.getLineNumber();
|
||||
int col = scanner.getColumnNumber();
|
||||
|
||||
FactorWord type = reader.nextWord(false);
|
||||
if(type == null)
|
||||
return;
|
||||
|
||||
FactorWord newWord = reader.nextWord(false);
|
||||
if(newWord == null)
|
||||
FactorWord generic = reader.nextWord(false);
|
||||
if(generic == null)
|
||||
return;
|
||||
|
||||
reader.pushExclusiveState(word,newWord);
|
||||
MethodArtifact artifact = new MethodArtifact(type,generic);
|
||||
artifact.setFile(scanner.getFileName());
|
||||
artifact.setLine(line);
|
||||
artifact.setColumn(col);
|
||||
reader.addArtifact(artifact);
|
||||
reader.pushExclusiveState(word,generic);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,23 +34,18 @@ import java.io.IOException;
|
|||
|
||||
public class LineComment extends FactorParsingDefinition
|
||||
{
|
||||
public boolean doc;
|
||||
|
||||
//{{{ LineComment constructor
|
||||
/**
|
||||
* A new definition.
|
||||
*/
|
||||
public LineComment(FactorWord word, boolean doc)
|
||||
public LineComment(FactorWord word)
|
||||
{
|
||||
super(word);
|
||||
this.doc = doc;
|
||||
} //}}}
|
||||
|
||||
public void eval(FactorReader reader)
|
||||
throws IOException, FactorParseException
|
||||
{
|
||||
String comment = reader.getScanner().readUntilEOL();
|
||||
if(doc)
|
||||
reader.addDocComment(comment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ complement [
|
|||
: complement-predicate ( complement -- list )
|
||||
"predicate" word-property [ not ] append ;
|
||||
|
||||
: define-complement ( class predicate complement -- )
|
||||
[ complement-predicate define-compound ] keep
|
||||
dupd "complement" set-word-property
|
||||
: define-complement ( class complement -- )
|
||||
2dup "complement" set-word-property
|
||||
dupd complement-predicate "predicate" set-word-property
|
||||
complement define-class ;
|
||||
|
|
|
|||
|
|
@ -23,12 +23,10 @@ USING: syntax generic kernel lists namespaces parser words ;
|
|||
#! Syntax: BUILTIN: <class> <type#> <slots> ;
|
||||
CREATE scan-word [ builtin-class ] [ ] ; parsing
|
||||
|
||||
: COMPLEMENT: ( -- class predicate definition )
|
||||
: COMPLEMENT: ( -- )
|
||||
#! Followed by a class name, then a complemented class.
|
||||
CREATE
|
||||
dup intern-symbol
|
||||
dup predicate-word
|
||||
[ dupd unit "predicate" set-word-property ] keep
|
||||
scan-word define-complement ; parsing
|
||||
|
||||
: UNION: ( -- class predicate definition )
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespaces prettyprint stdio unparser vectors words ;
|
|||
swap dup slip (each-object)
|
||||
] [
|
||||
2drop
|
||||
] ifte ; inline
|
||||
] ifte ;
|
||||
|
||||
: each-object ( quot -- )
|
||||
#! Applies the quotation to each object in the image.
|
||||
|
|
@ -34,7 +34,7 @@ namespaces prettyprint stdio unparser vectors words ;
|
|||
begin-scan (each-object)
|
||||
] [
|
||||
end-scan rethrow
|
||||
] catch ; inline
|
||||
] catch ;
|
||||
|
||||
: instances ( quot -- list )
|
||||
#! Return a list of all object that return true when the
|
||||
|
|
|
|||
Loading…
Reference in New Issue