Timbre LC. User Manual for V.14 - PDF

Please download to get full document.

View again

of 50
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

Marketing

Published:

Views: 5 | Pages: 50

Extension: PDF | Download: 0

Share
Related documents
Description
Timbre LC User Manual for V.14 PREFACE This manual is intended to provide instruction on how to use Timbre. Timbre runs on Macs and Windows and Unix or Linux platforms. V.11 is a big change in that all
Transcript
Timbre LC User Manual for V.14 PREFACE This manual is intended to provide instruction on how to use Timbre. Timbre runs on Macs and Windows and Unix or Linux platforms. V.11 is a big change in that all words have been changed to lower case. The information contained in this document is subject to change without notice. No warranty is made of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. There is no liability for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material. Copyright TimbreWorks Engineering Table Of Contents 1 Introduction Rules Match Phrase Action New Phrase Syntax Rule Sets Syntax Input Flow Conditional Ruling Fundamental Forms Translation Applications An Implementation Rules Simple Rules Translating Input Text Timbre as a Linguistic Solver Parsing Inline States Conditional Substitution Phrases in Forth Rule Sets Rule Sets as States Rule Set Stack Super States Application Stripdown C Parser As a Philosophy Applications Timbre LC: User Manual for V.14 3 Top Down Bottom Up Middle Out Evolution Debugging Rules Rule Sets Frame Works Applications C Code Walker Word Walker Noise Parser Stack Verifier Assembler Timbre Glossary Stacks Alu Test Memory Dictionary Environment Compilers External Interface File Interface Active Object Loader Library File as an output sink Timbre Engine Timbre LC: User Manual for V.14 4 1 Introduction In This Chapter Rules Rule Sets Input Flow Applications An Implementation Timbre LC: User Manual for V.14 5 Rules Timbre is a general purpose translation engine, whose components are: 1 a pattern matcher for matching text phrases 2 a stack engine for interacting with a computer 3 a rule compiler for defining behaviour This translation engine may be thought of as a language gate with two inputs and one output. One input controls the behaviour of the gate, and is fed rule sets. The other input is the data. The output is the modified data. Rule sets output input Timbre Meta-rules are rules which learn from the input and can edit the rule base. This allows Timbre to adapt to the input. Rules A rule is the basic component of behaviour to Timbre. Rules belong to rule-sets. A rule is three groupings of text on one line representing: 1 Match Phrase - when this phrase matches up with the input, the rule executes. 2 Action - action to take when a rule executes. 3 New Phrase - what phrase to stuff back into the input. The three groups of text are separated by curly, square and curly brackets: { match phrase }[ action ]{ new phrase } or by vertical bars, square brackets and vertical bars: match phrase [ action ] new phrase The alternate syntax allows for curly brackets to be included in rules. The two syntactic rules may be intermixed freely. Match Phrase A match phrase consists of a group of words and/or symbols which will be looked Timbre LC: User Manual for V.14 6 Rules for in the input. Once this phrase is found in the input stream, the rule will execute. The text in the phrase is interpreted as words with blanks between them. The input is parsed with blanks between words except when a rule choses to parse differently. If the match phrase of a rule is a subset of another rule then the rule with the longer match phrase will execute. If there are two rules with the same match phrase, then the first one found will execute. Action An action consists of a group of stack engine instructions 1. New phrases may also be added as part of an action. New Phrase A new phrase is the text that will be stuffed into the input. This new input will then be used for matching rules. This allows a rule to be factored into common components which are self documenting. Syntax Rules may be built using curly brackets or vertical bars to delimit the phrases. Either the action or the new phrase may be left out. New phrases can appear inside of an action. Multiple match phrases may be included within a rule. { match phrase}[ actions { new phrase } ]{ new phrase one or more alternate syntax: either: action, new phrase, or both match phrase [ actions new phrase ] new phrase Syntax Examples The following examples illustrate some of the syntactical forms: { match phrase }[ action ] { match phrase }{ new phrase } 1 See botkernel Programmer s Manual for more details on stack engine instructions. See the Glossary of this manual for the stack engine API. Timbre LC: User Manual for V.14 7 Rule Sets { match phrase 1 }{ match phrase 2 }{ match phrase 3 }[ action ] { match phrase }[ action { new phrase } ] { match phrase }[ action ]{ new phrase } { match phrase }[ action { new phrase 1 } ]{ new phrase 2 } Rule Sets A rule set is a collection of rules functionally grouped together. Rule sets are declared first and then rules are added to them. Rule sets to be matched to the input are pushed onto the rule stack. Only the rule sets on the rule stack are used to match against the input. By factoring rules into different rule sets, you can create context and run state machines on the input. Super states can be achieved by keeping common rule sets on the rule stack. The rule stack is modified by the actions of rules. Syntax Rule sets are declared by the word RULE-SET. It creates the necessary data structures to support a rule set. RULE-SET interpreting A rule set is made available by putting it on the rule stack: ruleset1 RULES Once it is on the rule stack, rules may be defined. Several rule sets may be placed on the rule stack or taken off by: ruleset1 RULES ruleset2 RULES RULES DROP Input Flow Text flows from the text input buffer (TIB) into an input queue. This input queue is filled with words parsed from TIB. Rules are matched against the words in the input queue. If a rule needs more words to complete its match phrase, then they are parsed from the TIB. When a rule s match phrase matches, all the matching words are dropped from the input queue and the rule is executed. Any remaining words and new phrases Timbre LC: User Manual for V.14 8 Input Flow in the input queue are used to match rules again. text input buffer This is text in TIB which is to be parsed. parsed text input queue This is text Rule being matched { This is text }{ This was text } After this rule has fired, we have the following picture: text input buffer in TIB which is to be parsed. input queue new phrase This was text In a rule which has more than one new phrase to stuff, the last stuffed phrase is the first accessible phrase in the input: When this rule fires, { match phrase }[ { new phrase 1 } { new phrase 2 } ]{ new phrase 3 } The input queue looks like: input queue match phrase 3 match phrase 2 match phrase 1 Timbre LC: User Manual for V.14 9 Conditional Ruling All looping, conditional or iterative, recursion and co-routine program constructs are supported by conditionally substituting a new phrase inside an action: Example: iterative looping { until 0 }[?DUP IF 1 - { until 0 } ENDIF ] Example: conditional looping { until false }[ IF { until false } ENDIF ] Example: recursion { this rule }[ MORE? IF { this rule } ENDIF ] Example: co-routines { that rule }[ OTHER? IF { other rule } ENDIF ] { other rule }[ THAT? IF { that rule } ENDIF ] are collections of rule sets which may be used to build Applications. They are developed from an application, or during its building. It is a frame of rule sets that works (i.e. nobugs )! Examples include: noise parser partial assembler infix math parser RPN math parser Fundamental Forms Here are the fundamental forms of all Timbre rules for all subsequent Frameworks and scripts augmented with a few illuminating comments: (1) { } recognition (2) [ ] control (3) { }{ } substitution (4) { }[ ] action (5) { }[ ]{ } translation (6) { }[ { } ] controlled substitution (7) [ ]{ } pattern generator (8) [ { } ] controlled pattern generator Timbre LC: User Manual for V.14 10 (9) [ { } ]{ } semi-controlled pattern generator (10) { }[ { } ]{ } transmorf Recognition pattern is parsed out of the input it is in the dictionary an empty pattern matches everything else, it is the default rule Control it runs the machinery when there is no input self sustaining default action is to continue to parse words from open files using blanks as delimiters Substitution just altering the flow optimizations self sustaining Action from the event, action, change state model states are supported as well as context nesting Translation recognition, control and substitution, what more do you need? self sustaining Controlled Substitution oh yeah, gotta control some of those substitutions self sustaining Pattern Generator gotta have one, may as well be in concert continuous Controlled Pattern Generator this is creativity, only appreciated by others self destroying second name: creativity Timbre LC: User Manual for V.14 11 Applications Semi-Controlled Pattern Generator nice to have some shorthand in the creation self destroying Transmorf I see, I channel, I add I can do it all, every thing else is just shorthand Applications Applications may be built from or from new rule sets. When building the rule sets consider what states are required in the solution. Simple states may be done with a single rule while more complex states would require a complete rule set change. Some applications are required to learn from their input. To learn, certain rules called meta-rules create new rules and or rule sets. A meta-rule can also create new metarules. An Implementation A closer look at the relationships between rules and their components brings us to the nuts & bolts level. An implementation in software of the Timbre engine lets us examine what components can be used to build rules. Rule null Match Phrase Action New Phrase null null String String String String String A rule is an array of 3 pointers. A match phrase or a new phrase is an array of pointers to strings terminated with a null. An action is code which can be exe- Timbre LC: User Manual for V.14 12 An Implementation cuted by the local stack engine. A string is an array of characters with the count in front. The strings are kept unique by keeping them in a hashed dictionary which provides fast lookup. By maintaining a single copy of an input string, it rapidly procedes through the Timbre engine with address comparisons clicking most of the time with an occasional string compare. New input or noisy input will cause more string compares. For fast rule recognition, the rules are indexed into a dictionary on the first string of the Match Phrase. Rules with a common first string are link listed together. Dictionary Rule Rule Match Phrase Rule Match Phrase Match Phrase null String Timbre LC: User Manual for V.14 13 2 Rules In This Chapter Simple Rules Inline States Conditional Substitution Phrases in Forth Timbre LC: User Manual for V.14 14 Rules Simple Rules Simple Rules Timbre rules involve an iterative thinking process. As you write out rules, you describe, understand and solve the problem you are working through. It is best to minimize your actions and stay in the editor continuously refactoring until you feel you have a firm grasp of the problem. Since Timbre is text oriented, it is a lot like writing a small story. rules breaks down into two categories. In the first type, text input is being translated. In the second type, input, which isn t necessarily text, is translated linguistically. Translating Input Text Translating input text usually has a structure which consists of a lot of parallel phrases. If you are encountering varied text phrases in the input, write a phrase that you expect to translate then write its substitution. This might involve using different forms of Timbre as described in Fundamental Forms on page 10. Timbre as a Linguistic Solver Using Timbre as a linguistic solver involves building a hierarchy of rules. The simplest way to start writing rules is to start at the highest level and describe your problem linguistically without any actions. If you are using Timbre in a mode where there is no text in the input but you are using Timbre linguistics to solve a problem, then write the phrase you expect to solve and then write the solution as a substitute phrase. You move down in the hierarchy by making sub-rules that solve portions of the initial substitute phrase by creating rules with match phrases and substitute phrases. At some point the phrases are atomic and are then described as actions linking them to the underlying computing machinery. Parsing To change from an interpreting state to a compile state the right bracket ] is used and [ is used to return to the interpret state from the compile state. In the compile state special words have been given the power to temporarily be in the interpret state while the compile state is invoked. Timbre adds one more state: Parsing. The same two symbols are used change states. The parsing state is transitioned to by using the left bracket [ and then back to the interpret state with right bracket ]. The default parser in Timbre is to use ASCII blanks to delimit non-blank sequences of characters from the input stream as strings. Different parsers are built for any rule set Timbre LC: User Manual for V.14 15 Rules Inline States by using the [ ] sequence. [ ] parsing interpreting compiling The default parser can be described as: [ bl word here unique inputq push ] ] [ Inline States { count down }[?dup if 1 - { count down } then ] This rule creates a temporary inline state that counts down the top element on the data stack till zero, and then stops. Conditional Substitution Phrases in Forth : hello-world hello world ; In the above Forth definition the phrase hello world is inserted into the input stream as two words. Timbre LC: User Manual for V.14 16 3 Rule Sets In This Chapter Rule Sets as States Rule Set Stack Super States Timbre LC: User Manual for V.14 17 Rule Sets Rule Sets as States Rule Sets as States Rule Set Stack Super States Timbre LC: User Manual for V.14 18 4 In This Chapter Application Stripdown As a Philosophy Timbre LC: User Manual for V.14 19 Application Stripdown are the scaffolding upon which applications are built from. They are a collection of rule sets with a basic behaviour. A technique for parsing, or an algorithm for code certifying. They are either built by distilling from applications or with original intent. Application Stripdown Strip extra functionality not related to a primary state diagram of the system that is not specific to a set of rules, is the distilled essence, or a FrameWork(s) for an application. A framework creates a state diagram of linguistic terms C Parser This framework was distilled from an application which was used to scan C code using rules to transit linguistic states. Addition of rules can create a host of applications involving C structure like code. Simple compilers or support for other linguistic characterstics can be added. Parser State Diagram As a Philosophy Good frameworks are the cornerstone of design amplification. Each framework captures a linguistic diagram which represents the set of states and transitions necessary to walk the states. Some states might be isolated and have zero transitions or more, in or out. It is good practice to generate frameworks from an application to give back to Timbre Zone. Different classes of Frameworks in clude a capture architecture, subsumption, motor schema, pattern finders, text parsers, etc. Timbre LC: User Manual for V.14 20 5 Applications In This Chapter Top Down Bottom Up Middle Out Evolution Timbre LC: User Manual for V.14 21 Timbre LC: User Manual for V.14 22 Applications Top Down Top Down Bottom Up Middle Out Evolution Timbre LC: User Manual for V.14 23 6 Debugging In This Chapter Rules Rule Sets Frame Works Applications Timbre LC: User Manual for V.14 24 Debugging Rules Rules Rule Sets Frame Works Applications Timbre LC: User Manual for V.14 25 7 In This Chapter Noise Parser Stack Verifier Assembler Timbre LC: User Manual for V.14 26 C Code Walker C Code Walker Word Walker Noise Parser Stack Verifier Assembler Timbre LC: User Manual for V.14 27 8 Timbre Glossary Timbre LC: User Manual for V.14 28 Rules Rule Sets Applications Debugging Timbre Glossary Stacks This glossary contains a stack comment and a simple explanation of each word available in Timbre. The words are grouped according to usage. For an alphabetical listing, refer to the index. Cell cell cells Stacks Data Stack ( -- n ) number of bytes in a memory cell ( n -- m ) number of bytes in n cells swap ( m \ n -- n \ m ) swap the top two items of the stack dup ( m -- m \ m ) duplicate the top item of the stack drop ( m -- ) drop the top item of the stack nup ( m \ n -- m \ m \ n ) duplicate the second stack item (sounds like dup) nip ( m \ n -- n ) drop the second item on the stack over ( m \ n -- m \ n \ m ) copy the second item to the top of the stack tuck ( m \ n -- n \ m \ n ) tuck a copy of the top item under the second item 2dup ( m \ n -- m \ n \ m \ n ) duplicate the top two items 2drop ( m \ n -- ) drop the top two items?dup ( n -- [n] \ n ) duplicate the top item of the stack if it is not 0 sp! (? -- ) empty the data stack depth ( -- n ) return the current depth of the data stack sp0 ( -- a ) pointer to bottom of the data stack Return Stack r ( -- m ) pop the top item off the return stack r ( m -- ) push n onto the return stack r ( -- m ) get a copy of the top item on the return stack rp! ( -- ) empty the return stack rdepth ( -- n ) return the current depth of the return stack rp0 ( -- a ) pointer to bottom of the return stack Timbre LC: User Manual for V.14 29 Rules Rule Sets Applications Debugging Alu Logic and or xor not ( m \ n -- p ) AND n with m ( m \ n -- p ) OR n with m ( m \ n -- p ) XOR n with m ( m -- n ) invert all the bits of n Timbre Glossary Alu Shift 2* ( m -- n ) shift m left one bit and set bit 0 to 0 2/ ( m -- n ) shift m right one bit but don't change msbit u2/ ( m -- n ) shift m right one bit and set msbit to 0 shift ( n \ m -- n ) shift n m bits left or right; -m is left Math + ( m \ n -- p ) add n to m - ( m \ n -- p ) subtract n from m negate ( m -- n ) take the two's complement of m /mod ( n \ m -- r \ q ) unsigned divide with remainder. devide n by m. / ( n \ m -- quot ) unsigned divide mod ( n \ m -- rem ) modulus * ( n \ m -- nm* ) signed multiply Test Flags no ( -- f ) the false flag, 0. yes ( -- t ) the true flag, -1. Zero Test 0= ( n -- flag ) return yes if n is 0, else return no 0 ( n -- flag ) return yes if n is negative, else return no non? ( f -- f ) French equivelant for 0= Timbre LC: User Manual for V.14 30 Rules Rule Sets Applications Debugging Compare Timbre Glossary Test = ( n \ m -- flag ) return yes if n is equal to m, else return no ( n \ m -- flag ) return yes if n is less than m, else return no ( n \ m -- flag ) return yes if n is greater than m, else return no u ( n \ m -- flag ) same as but unsigned and used typically for addresses u ( n \ m -- flag ) same as but unsigned and used typically for addresses differ? ( a \ a -- a+ \ a+ \ f ) compare bytes and increment to next bytes bits-differ? ( a \ a \ mask -- a+ \ a+ \ f ) differ? using a bit mask same? ( a1 \ a2 \ length -- flag ) compare length bytes at a1 to a2 compare memcmp ( string1 \ string2 -- flag ) compare two count-prefixed strings ( a \ b \ length -- flag:[ -c 0 +c ] ) compare two strings and return difference of first different character Absolute, MinMax abs ( n -- n ) take the absolute value of n ( note: 8000 abs is 8000 ) max ( n \ m -- p ) return the signed maximum of n or m min ( n \ m -- p ) return the signed minimum of n or m umax ( a \ b -- c ) return the unsigned maximum of a and b Timbre LC: User Manual for V.14 31 Rules Rule Sets Applications Debugging Memory Cells Timbre Glossary ( a -- n ) read the cell at address a! ( n \ a -- ) store n into the cell at address ( a -- n\ a+
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks