예제 #1
0
 public AssemblyNameWord(RawWord[] words, ProseRuntime runtime, Assembly assembly )
     : base(words)
 {
     this.assembly = assembly;
     isa = new Word[] { runtime.word("@assembly") };
 }
예제 #2
0
 public TypeNameWord(RawWord[] words, ProseRuntime runtime, Type type )
     : base(words)
 {
     this.type = type;
     isa = new Word[] { runtime.word("@type") };
 }
예제 #3
0
 public AssemblyNameWord(RawWord[] words, ProseRuntime runtime, Assembly assembly)
     : base(words)
 {
     this.assembly = assembly;
     isa           = new Word[] { runtime.word("@assembly") };
 }
예제 #4
0
        public static void constructInitialPatternTrie(ProseRuntime runtime)
        {
            ProseScope scope = runtime.GlobalScope;
            Trie<ProseObject, List<Phrase>> patternTrie = scope.PatternTree;

            //
            //	Pattern Creation Pattern
            //

            //	The only pattern we need to "force" into the system is the pattern for making patterns:
            //	word[phrase_class] : @pattern[pattern] -> @prose[value] .

            //			Phrase phrasePhrase = new SimplePhrase(runtime.Word_phrase,
            //			                                       new ProseObject[] { runtime.Word_word,

            //patternTrie.putObjectString(

            #region Word binding phrases
            //	, word : @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                {runtime.Comma, runtime.Word_word, runtime.Colon, runtime.@raw, runtime.Comma};
                WordBindingPhrase bindWords_commaDelimited = new WordBindingPhrase( runtime.Word_phrase, commaDelimitedBindWordsPattern );
                scope.addPhrase(bindWords_commaDelimited);
            }
            //	, word +: @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                {runtime.Comma, runtime.Word_word, runtime.PlusColon, runtime.@raw, runtime.Comma};
                WordBindingPhrase bindWords_commaDelimited = new WordBindingPhrase( runtime.Word_phrase, commaDelimitedBindWordsPattern );
                scope.addPhrase(bindWords_commaDelimited);
            }
            //	, word <- @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                {runtime.Comma, runtime.Word_word, runtime.LeftArrow, runtime.@raw, runtime.Comma};
                ExclusiveWordBindingPhrase exclusiveBindWords_commaDelimited = new ExclusiveWordBindingPhrase( runtime.Word_phrase, commaDelimitedBindWordsPattern );
                scope.addPhrase(exclusiveBindWords_commaDelimited);
            }

            #endregion

            #region Phrase creation phrases

            //	Comma delimited exclusive phrase creation
            // 	, word[class]: @pattern -> @prose[value] ,
            {
                ProseObject[] phrasePattern = new ProseObject[]
                {runtime.Comma, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Comma};
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            //	Semicolon delimited exclusive phrase creation
            // 	; word[class]: @pattern -> @prose[value] ;
            {
                ProseObject[] phrasePattern = new ProseObject[]
                {runtime.Semicolon, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Semicolon};
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            //	Period delimited exclusive phrase creation
            // 	. word[class]: @pattern -> @prose[value] .
            {
                ProseObject[] phrasePattern = new ProseObject[]
                {runtime.Period, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Period};
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            #endregion

            #region Reading

            //	, read @string[x] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("read"), runtime.word("@string"), runtime.Comma};
                Phrase readPhrase = new ReadPhrase(runtime.Word_phrase, p);
                scope.addPhrase(readPhrase);
            }

            //	contents of text file @string[file_name]
            {
                ProseObject[] p = new ProseObject[]
                {runtime.word("contents"), runtime.word("of"), runtime.word("text"), runtime.word("file"), runtime.word("@string")};
                Phrase readFilePhrase = new ContentsOfTextFilePhrase(runtime.Word_phrase, p);
                scope.addPhrase(readFilePhrase);
            }

            runtime.read("phrase: , read file @string[path] ,  ->  , read contents of text file path ,", runtime.GlobalClient);

            #endregion

            #region Foreign Function Interface

            //	Load an assembly and bind it to a name
            // 	, load assembly : @string[file_name] <- @raw[new_assembly_word] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("load"), runtime.word("assembly"), runtime.Colon,
                    runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma};
                BindAssemblyPhrase asmPhrase = new BindAssemblyPhrase(runtime.Word_phrase, p);
                scope.addPhrase(asmPhrase);
            }

            //	Load a type and bind it to a name
            // 	, @assembly[asm_name] type : @string[type_name] <- @raw[new_type_word] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("@assembly"), runtime.word("type"), runtime.Colon,
                    runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma};
                BindTypePhrase typePhrase = new BindTypePhrase(runtime.Word_phrase, p);
                scope.addPhrase(typePhrase);
            }

            //	Load a method and bind it to a name
            // 	, @type[type_name] method : @string[method_name] <- @raw[new_method_word] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("@type"), runtime.word("method"), runtime.Colon,
                    runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma};
                BindMethodPhrase methodPhrase = new BindMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(methodPhrase);
            }

            //	Apply a method to some arguments to produce an action
            //	, @method[method_name] @prose[args] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("@method"), runtime.@prose, runtime.Comma};
                Phrase applyMethodPhrase = new ApplyMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(applyMethodPhrase);
            }

            //	Apply a method with no arguments to produce an action
            //	, @method[method_name] ,
            {
                ProseObject[] p = new ProseObject[]
                {runtime.Comma, runtime.word("@method"), runtime.Comma};
                Phrase applyMethodPhrase = new ApplyMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(applyMethodPhrase);
            }

            #endregion

            //	Add a breakpoint
            {
                ProseObject[] p = new ProseObject[]
                {runtime.@break};
                Phrase addBreakpointPhrase = new BreakPointPhrase(runtime.Word_phrase, p);
                scope.addPhrase(addBreakpointPhrase);
            }

            #region Debugger

            #endregion

            #region Experimental
            //	, -> @pattern -> ,
            {
                ProseObject[] test = new ProseObject[]
                {runtime.Comma, runtime.RightArrow, runtime.@pattern, runtime.RightArrow, runtime.Comma};
                DebugOutputPhrase dbg = new DebugOutputPhrase("Carlybou", runtime.Word_phrase, test);
                scope.addPhrase(dbg);
            }
            #endregion
        }
예제 #5
0
 public MethodNameWord(RawWord[] words, ProseRuntime runtime, ProseLanguage.ActionDelegate delegateMethod )
     : base(words)
 {
     this.delegateMethod = delegateMethod;
     isa = new Word[] { runtime.word("@method") };
 }
예제 #6
0
 public TypeNameWord(RawWord[] words, ProseRuntime runtime, Type type)
     : base(words)
 {
     this.type = type;
     isa       = new Word[] { runtime.word("@type") };
 }
예제 #7
0
        static public void constructInitialPatternTrie(ProseRuntime runtime)
        {
            ProseScope scope = runtime.GlobalScope;
            Trie <ProseObject, List <Phrase> > patternTrie = scope.PatternTree;

            //
            //	Pattern Creation Pattern
            //

            //	The only pattern we need to "force" into the system is the pattern for making patterns:
            //	word[phrase_class] : @pattern[pattern] -> @prose[value] .

//			Phrase phrasePhrase = new SimplePhrase(runtime.Word_phrase,
//			                                       new ProseObject[] { runtime.Word_word,

            //patternTrie.putObjectString(

            #region Word binding phrases
            //	, word : @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                { runtime.Comma, runtime.Word_word, runtime.Colon, runtime.@raw, runtime.Comma };
                WordBindingPhrase bindWords_commaDelimited = new WordBindingPhrase(runtime.Word_phrase, commaDelimitedBindWordsPattern);
                scope.addPhrase(bindWords_commaDelimited);
            }
            //	, word +: @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                { runtime.Comma, runtime.Word_word, runtime.PlusColon, runtime.@raw, runtime.Comma };
                WordBindingPhrase bindWords_commaDelimited = new WordBindingPhrase(runtime.Word_phrase, commaDelimitedBindWordsPattern);
                scope.addPhrase(bindWords_commaDelimited);
            }
            //	, word <- @raw ,
            {
                ProseObject[] commaDelimitedBindWordsPattern = new ProseObject[]
                { runtime.Comma, runtime.Word_word, runtime.LeftArrow, runtime.@raw, runtime.Comma };
                ExclusiveWordBindingPhrase exclusiveBindWords_commaDelimited = new ExclusiveWordBindingPhrase(runtime.Word_phrase, commaDelimitedBindWordsPattern);
                scope.addPhrase(exclusiveBindWords_commaDelimited);
            }

            #endregion

            #region Phrase creation phrases

            //	Comma delimited exclusive phrase creation
            //  , word[class]: @pattern -> @prose[value] ,
            {
                ProseObject[] phrasePattern = new ProseObject[]
                { runtime.Comma, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Comma };
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            //	Semicolon delimited exclusive phrase creation
            //  ; word[class]: @pattern -> @prose[value] ;
            {
                ProseObject[] phrasePattern = new ProseObject[]
                { runtime.Semicolon, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Semicolon };
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            //	Period delimited exclusive phrase creation
            //  . word[class]: @pattern -> @prose[value] .
            {
                ProseObject[] phrasePattern = new ProseObject[]
                { runtime.Period, runtime.Word_word, runtime.Colon, runtime.@pattern, runtime.RightArrow, runtime.@prose, runtime.Period };
                ExclusivePhraseBindingPhrase phrasePhrase = new ExclusivePhraseBindingPhrase(runtime.Word_phrase, phrasePattern);
                scope.addPhrase(phrasePhrase);
            }

            #endregion

            #region Reading


            //	, read @string[x] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("read"), runtime.word("@string"), runtime.Comma };
                Phrase readPhrase = new ReadPhrase(runtime.Word_phrase, p);
                scope.addPhrase(readPhrase);
            }


            //	contents of text file @string[file_name]
            {
                ProseObject[] p = new ProseObject[]
                { runtime.word("contents"), runtime.word("of"), runtime.word("text"), runtime.word("file"), runtime.word("@string") };
                Phrase readFilePhrase = new ContentsOfTextFilePhrase(runtime.Word_phrase, p);
                scope.addPhrase(readFilePhrase);
            }

            runtime.read("phrase: , read file @string[path] ,  ->  , read contents of text file path ,", runtime.GlobalClient);

            #endregion

            #region Foreign Function Interface

            //	Load an assembly and bind it to a name
            //  , load assembly : @string[file_name] <- @raw[new_assembly_word] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("load"), runtime.word("assembly"), runtime.Colon,
                  runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma };
                BindAssemblyPhrase asmPhrase = new BindAssemblyPhrase(runtime.Word_phrase, p);
                scope.addPhrase(asmPhrase);
            }

            //	Load a type and bind it to a name
            //  , @assembly[asm_name] type : @string[type_name] <- @raw[new_type_word] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("@assembly"), runtime.word("type"), runtime.Colon,
                  runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma };
                BindTypePhrase typePhrase = new BindTypePhrase(runtime.Word_phrase, p);
                scope.addPhrase(typePhrase);
            }

            //	Load a method and bind it to a name
            //  , @type[type_name] method : @string[method_name] <- @raw[new_method_word] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("@type"), runtime.word("method"), runtime.Colon,
                  runtime.@string, runtime.LeftArrow, runtime.@raw, runtime.Comma };
                BindMethodPhrase methodPhrase = new BindMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(methodPhrase);
            }

            //	Apply a method to some arguments to produce an action
            //	, @method[method_name] @prose[args] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("@method"), runtime.@prose, runtime.Comma };
                Phrase applyMethodPhrase = new ApplyMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(applyMethodPhrase);
            }

            //	Apply a method with no arguments to produce an action
            //	, @method[method_name] ,
            {
                ProseObject[] p = new ProseObject[]
                { runtime.Comma, runtime.word("@method"), runtime.Comma };
                Phrase applyMethodPhrase = new ApplyMethodPhrase(runtime.Word_phrase, p);
                scope.addPhrase(applyMethodPhrase);
            }

            #endregion

            //	Add a breakpoint
            {
                ProseObject[] p = new ProseObject[]
                { runtime.@break };
                Phrase addBreakpointPhrase = new BreakPointPhrase(runtime.Word_phrase, p);
                scope.addPhrase(addBreakpointPhrase);
            }

            #region Debugger

            #endregion


            #region Experimental
            //	, -> @pattern -> ,
            {
                ProseObject[] test = new ProseObject[]
                { runtime.Comma, runtime.RightArrow, runtime.@pattern, runtime.RightArrow, runtime.Comma };
                DebugOutputPhrase dbg = new DebugOutputPhrase("Carlybou", runtime.Word_phrase, test);
                scope.addPhrase(dbg);
            }
            #endregion
        }
예제 #8
0
 public MethodNameWord(RawWord[] words, ProseRuntime runtime, ProseLanguage.ActionDelegate delegateMethod)
     : base(words)
 {
     this.delegateMethod = delegateMethod;
     isa = new Word[] { runtime.word("@method") };
 }