Create gh-pages branch via GitHub
Cat's Eye Technologies
11 years ago
40 | 40 | |
41 | 41 | <p>Its primary goal is to allow the rapid development of <strong>parsers</strong>, |
42 | 42 | <strong>static analyzers</strong>, <strong>interpreters</strong>, and <strong>compilers</strong>, and to allow them |
43 | to be expressed <em>compactly</em>. Golf your grammar!</p> | |
43 | to be expressed <em>compactly</em>. Golf your grammar! (Or write it like a decent | |
44 | human being would.)</p> | |
44 | 45 | |
45 | 46 | <p>The current development version of Tamsin is 0.1-PRE. As indicated by the |
46 | 47 | 0.x version number, it is a <strong>work in progress</strong>, with the usual caveat that |
110 | 111 | |
111 | 112 | <p>This repository contains the reference implementation of Tamsin, called |
112 | 113 | <code>tamsin</code>, written in Python. It can interpret a Tamsin program, and compile |
113 | a program written in (core) Tamsin to C. The distribution also contains | |
114 | implementations of the Tamsin scanner and parser written in Tamsin itself | |
114 | a program written in (core) Tamsin to C. The distribution also contains an | |
115 | <a href="https://github.com/catseye/Tamsin/blob/master/eg/tamsin-parser.tamsin">implementation of the Tamsin scanner and parser written in Tamsin itself</a> | |
115 | 116 | (although we're still a ways from a fully bootrapped implementation.)</p> |
116 | 117 | |
117 | 118 | <p>While the interpreter is fine for prototyping, note that some informal |
152 | 153 | <a name="design-goals" class="anchor" href="#design-goals"><span class="octicon octicon-link"></span></a>Design Goals</h2> |
153 | 154 | |
154 | 155 | <ul> |
155 | <li> Allow writing very compact parsers, interpreters, and compilers. | |
156 | (Not <em>quite</em> to the point of being a golfing language, but nearly.)</li> | |
157 | <li> Allow parsers, interpreters, and compilers to be quickly prototyped.</li> | |
158 | <li> Allow writing (almost) anything using (almost) only recursive-descent | |
159 | parsing techniques.</li> | |
156 | <li> Allow parsers, static analyzers, interpreters, and compilers to be | |
157 | quickly prototyped. (And in the future, processor simulators and VM's | |
158 | and such things too.)</li> | |
159 | <li> Allow writing these things very compactly.</li> | |
160 | <li> Allow writing anything using only recursive-descent parsing techniques | |
161 | (insofar as this is possible.)</li> | |
160 | 162 | <li> Provide means to solve practical problems.</li> |
161 | 163 | <li> Keep the language simple (grammar should fit on a page.)</li> |
162 | 164 | <li> Recognize that the preceding two goals are in tension.</li> |
172 | 174 | <a name="related-work" class="anchor" href="#related-work"><span class="octicon octicon-link"></span></a>Related work</h2> |
173 | 175 | |
174 | 176 | <ul> |
175 | <li> <a href="http://www.scifac.ru.ac.za/coco/">CoCo/R</a> | |
176 | </li> | |
177 | <li> <a href="http://www.haskell.org/haskellwiki/Parsec">Parsec</a> | |
178 | </li> | |
179 | <li> <a href="http://perl.com/">Perl</a> | |
180 | </li> | |
181 | <li> <a href="http://erlang.org/">Erlang</a> influenced the pattern-matching (in turn, | |
182 | Erlang was influenced by Prolog in this regard)</li> | |
183 | <li> Though not a conscious influence, it has a similar feel to | |
184 | <a href="https://github.com/kevinlawler/kona">K</a>; in Kona's parlance, Tamsin | |
185 | is a <em>vertical language</em> | |
186 | </li> | |
187 | <li> Cat's Eye Technologies' esoteric and experimental languages | |
188 | <a href="http://catseye.tc/node/Squishy2K">Squishy2K</a>, | |
189 | <a href="http://catseye.tc/node/Arboretuum">Arboretuum</a>, and | |
190 | <a href="http://catseye.tc/node/Treacle">Treacle</a> | |
177 | <li> <a href="http://www.scifac.ru.ac.za/coco/">CoCo/R</a> (parser generation)</li> | |
178 | <li> <a href="http://www.haskell.org/haskellwiki/Parsec">Parsec</a> (parser combination)</li> | |
179 | <li> <a href="http://perl.com/">Perl</a> (rubbish listing)</li> | |
180 | <li> <a href="http://erlang.org/">Erlang</a> (pattern-matching) | |
181 | <a href="https://github.com/kevinlawler/kona">K</a> (similar feel; Tamsin | |
182 | is a <em>vertical language</em>)</li> | |
183 | <li> <a href="http://catseye.tc">Cat's Eye Technologies</a>' esoteric and experimental | |
184 | languages: | |
185 | ||
186 | <ul> | |
187 | <li> <a href="http://catseye.tc/node/Squishy2K">Squishy2K</a> | |
188 | </li> | |
189 | <li> <a href="http://catseye.tc/node/Arboretuum">Arboretuum</a> | |
190 | </li> | |
191 | <li> <a href="http://catseye.tc/node/Treacle">Treacle</a> | |
192 | </li> | |
193 | </ul> | |
191 | 194 | </li> |
192 | 195 | </ul> |
193 | 196 | </section> |
0 | {"name":"Tamsin","tagline":"Look! Up on Github! Is it a parser generator? Is it a programming language? Is it a rubbish lister? No... it's Tamsin!","body":"Tamsin\r\n======\r\n\r\nTamsin is an oddball little language that can't decide if it's a\r\n[meta-language](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#meta-language), a\r\n[programming language](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#programming-language), or a\r\n[rubbish lister](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#rubbish-lister).\r\n\r\nIts primary goal is to allow the rapid development of **parsers**,\r\n**static analyzers**, **interpreters**, and **compilers**, and to allow them\r\nto be expressed *compactly*. Golf your grammar!\r\n\r\nThe current development version of Tamsin is 0.1-PRE. As indicated by the\r\n0.x version number, it is a **work in progress**, with the usual caveat that\r\nthings may change rapidly (and version 0.2 might look completely different.)\r\n\r\nCode Examples\r\n-------------\r\n\r\nMake a story more exciting in **1 line of code**.\r\n\r\n main = S ← '' & {(\".\" & '!' | \"?\" & '?!' | any) → C & S ← S + C} & S.\r\n\r\nParse an algebraic expression in **4 lines of code**.\r\n\r\n main = (expr0 & eof & 'ok').\r\n expr0 = expr1 & {\"+\" & expr1}.\r\n expr1 = term & {\"*\" & term}.\r\n term = \"x\" | \"y\" | \"z\" | \"(\" & expr0 & \")\".\r\n\r\nTranslate an algebraic expression to RPN (Reverse Polish Notation) in\r\n**7 lines of code**.\r\n\r\n main = expr0 → E & walk(E).\r\n expr0 = expr1 → E1 & {\"+\" & expr1 → E2 & E1 ← add(E1,E2)} & E1.\r\n expr1 = term → E1 & {\"*\" & term → E2 & E1 ← mul(E1,E2)} & E1.\r\n term = \"x\" | \"y\" | \"z\" | \"(\" & expr0 → E & \")\" & E.\r\n walk(add(L,R)) = walk(L) → LS & walk(R) → RS & return LS+RS+' +'.\r\n walk(mul(L,R)) = walk(L) → LS & walk(R) → RS & return LS+RS+' *'.\r\n walk(X) = return ' '+X.\r\n\r\nParse a CSV file (handling quoted commas and quotes correctly) and write\r\nout the 2nd-last field of each record — in **11 lines of code**.\r\n\r\n main = line → L & L ← lines(nil, L) &\r\n {\"\\n\" & line → M & L ← lines(L, M)} & extract(L) & ''.\r\n line = field → F & {\",\" & field → G & F ← fields(G, F)} & F.\r\n field = strings | bare.\r\n strings = string → T & {string → S & T ← T + '\"' + S} & T.\r\n string = \"\\\"\" & T ← '' & {!\"\\\"\" & any → S & T ← T + S} & \"\\\"\" & T.\r\n bare = T ← '' & {!(\",\"|\"\\n\") & any → S & T ← T + S} & T.\r\n extract(lines(Lines, Line)) = extract(Lines) & extract_field(Line).\r\n extract(L) = L.\r\n extract_field(fields(Last, fields(This, X))) = print This.\r\n extract_field(X) = return X.\r\n\r\nEvaluate an (admittedly trivial) S-expression based language in\r\n**[17 lines of code](https://github.com/catseye/Tamsin/blob/master/eg/sexpr-eval.tamsin)**.\r\n\r\nFor more information\r\n--------------------\r\n\r\nIf the above has piqued your curiosity, you may want to read the specification,\r\nwhich contains many more small examples written to demonstrate (and test) the\r\nsyntax and behavior of Tamsin:\r\n\r\n* [The Tamsin v0.1-PRE Language Specification](https://github.com/catseye/Tamsin/blob/master/doc/Tamsin.markdown)\r\n\r\nQuick Start\r\n-----------\r\n\r\nThe Tamsin reference repository is [hosted on Github](https://github.com/catseye/tamsin).\r\n\r\nThis repository contains the reference implementation of Tamsin, called\r\n`tamsin`, written in Python. It can interpret a Tamsin program, and compile\r\na program written in (core) Tamsin to C. The distribution also contains\r\nimplementations of the Tamsin scanner and parser written in Tamsin itself\r\n(although we're still a ways from a fully bootrapped implementation.)\r\n\r\nWhile the interpreter is fine for prototyping, note that some informal\r\nbenchmarking revealed the compiled C programs to be about 30x faster. **Note**\r\nhowever that while the compiler passes all the tests, it currently fails to\r\ncorrectly compile the Tamsin parser written in Tamsin, so it should still be\r\nconsidered a **proof of concept**.\r\n\r\nTo start using `tamsin`,\r\n\r\n* Clone the repository — `git clone https://github.com/catseye/tamsin`\r\n* Either:\r\n * Put the repo's `bin` directory on your `$PATH`, or\r\n * Make a symbolic link to `bin/tamsin` somewhere already on your `$PATH`.\r\n* Errr... that's it.\r\n\r\n(Or, to make those steps trivial, you could use\r\n[toolshelf](https://github.com/catseye/toolshelf) and run\r\n`toolshelf dock gh:catseye/tamsin`)\r\n\r\nThen you can run `tamsin` like so:\r\n\r\n* `tamsin run eg/csv_parse.tamsin < eg/names.csv`\r\n\r\nYou can also compile to C and compile the C to an executable and run the\r\nexecutable all in one step, like so:\r\n\r\n* `tamsin loadngo eg/csv_extract.tamsin < eg/names.csv`\r\n\r\nDesign Goals\r\n------------\r\n\r\n* Allow writing very compact parsers, interpreters, and compilers.\r\n (Not *quite* to the point of being a golfing language, but nearly.)\r\n* Allow parsers, interpreters, and compilers to be quickly prototyped.\r\n* Allow writing (almost) anything using (almost) only recursive-descent\r\n parsing techniques.\r\n* Provide means to solve practical problems.\r\n* Keep the language simple (grammar should fit on a page.)\r\n* Recognize that the preceding two goals are in tension.\r\n* Have a relatively simple reference implementation (currently less than\r\n 2500 lines of code, including everything — debugging and the C runtime\r\n used by the compiler.)\r\n\r\nLicense\r\n-------\r\n\r\nBSD-style license; see the file [LICENSE](https://github.com/catseye/Tamsin/blob/master/LICENSE).\r\n\r\nRelated work\r\n------------\r\n\r\n* [CoCo/R](http://www.scifac.ru.ac.za/coco/)\r\n* [Parsec](http://www.haskell.org/haskellwiki/Parsec)\r\n* [Perl](http://perl.com/)\r\n* [Erlang](http://erlang.org/) influenced the pattern-matching (in turn,\r\n Erlang was influenced by Prolog in this regard)\r\n* Though not a conscious influence, it has a similar feel to\r\n [K](https://github.com/kevinlawler/kona); in Kona's parlance, Tamsin\r\n is a _vertical language_\r\n* Cat's Eye Technologies' esoteric and experimental languages\r\n [Squishy2K](http://catseye.tc/node/Squishy2K),\r\n [Arboretuum](http://catseye.tc/node/Arboretuum), and\r\n [Treacle](http://catseye.tc/node/Treacle)\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}⏎ | |
0 | {"name":"Tamsin","tagline":"Look! Up on Github! Is it a parser generator? Is it a programming language? Is it a rubbish lister? No... it's Tamsin!","body":"Tamsin\r\n======\r\n\r\nTamsin is an oddball little language that can't decide if it's a\r\n[meta-language](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#meta-language), a\r\n[programming language](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#programming-language), or a\r\n[rubbish lister](https://github.com/catseye/Tamsin/blob/master/doc/Philosophy.markdown#rubbish-lister).\r\n\r\nIts primary goal is to allow the rapid development of **parsers**,\r\n**static analyzers**, **interpreters**, and **compilers**, and to allow them\r\nto be expressed *compactly*. Golf your grammar! (Or write it like a decent\r\nhuman being would.)\r\n\r\nThe current development version of Tamsin is 0.1-PRE. As indicated by the\r\n0.x version number, it is a **work in progress**, with the usual caveat that\r\nthings may change rapidly (and version 0.2 might look completely different.)\r\n\r\nCode Examples\r\n-------------\r\n\r\nMake a story more exciting in **1 line of code**.\r\n\r\n main = S ← '' & {(\".\" & '!' | \"?\" & '?!' | any) → C & S ← S + C} & S.\r\n\r\nParse an algebraic expression in **4 lines of code**.\r\n\r\n main = (expr0 & eof & 'ok').\r\n expr0 = expr1 & {\"+\" & expr1}.\r\n expr1 = term & {\"*\" & term}.\r\n term = \"x\" | \"y\" | \"z\" | \"(\" & expr0 & \")\".\r\n\r\nTranslate an algebraic expression to RPN (Reverse Polish Notation) in\r\n**7 lines of code**.\r\n\r\n main = expr0 → E & walk(E).\r\n expr0 = expr1 → E1 & {\"+\" & expr1 → E2 & E1 ← add(E1,E2)} & E1.\r\n expr1 = term → E1 & {\"*\" & term → E2 & E1 ← mul(E1,E2)} & E1.\r\n term = \"x\" | \"y\" | \"z\" | \"(\" & expr0 → E & \")\" & E.\r\n walk(add(L,R)) = walk(L) → LS & walk(R) → RS & return LS+RS+' +'.\r\n walk(mul(L,R)) = walk(L) → LS & walk(R) → RS & return LS+RS+' *'.\r\n walk(X) = return ' '+X.\r\n\r\nParse a CSV file (handling quoted commas and quotes correctly) and write\r\nout the 2nd-last field of each record — in **11 lines of code**.\r\n\r\n main = line → L & L ← lines(nil, L) &\r\n {\"\\n\" & line → M & L ← lines(L, M)} & extract(L) & ''.\r\n line = field → F & {\",\" & field → G & F ← fields(G, F)} & F.\r\n field = strings | bare.\r\n strings = string → T & {string → S & T ← T + '\"' + S} & T.\r\n string = \"\\\"\" & T ← '' & {!\"\\\"\" & any → S & T ← T + S} & \"\\\"\" & T.\r\n bare = T ← '' & {!(\",\"|\"\\n\") & any → S & T ← T + S} & T.\r\n extract(lines(Lines, Line)) = extract(Lines) & extract_field(Line).\r\n extract(L) = L.\r\n extract_field(fields(Last, fields(This, X))) = print This.\r\n extract_field(X) = return X.\r\n\r\nEvaluate an (admittedly trivial) S-expression based language in\r\n**[17 lines of code](https://github.com/catseye/Tamsin/blob/master/eg/sexpr-eval.tamsin)**.\r\n\r\nFor more information\r\n--------------------\r\n\r\nIf the above has piqued your curiosity, you may want to read the specification,\r\nwhich contains many more small examples written to demonstrate (and test) the\r\nsyntax and behavior of Tamsin:\r\n\r\n* [The Tamsin v0.1-PRE Language Specification](https://github.com/catseye/Tamsin/blob/master/doc/Tamsin.markdown)\r\n\r\nQuick Start\r\n-----------\r\n\r\nThe Tamsin reference repository is [hosted on Github](https://github.com/catseye/tamsin).\r\n\r\nThis repository contains the reference implementation of Tamsin, called\r\n`tamsin`, written in Python. It can interpret a Tamsin program, and compile\r\na program written in (core) Tamsin to C. The distribution also contains an\r\n[implementation of the Tamsin scanner and parser written in Tamsin itself](https://github.com/catseye/Tamsin/blob/master/eg/tamsin-parser.tamsin)\r\n(although we're still a ways from a fully bootrapped implementation.)\r\n\r\nWhile the interpreter is fine for prototyping, note that some informal\r\nbenchmarking revealed the compiled C programs to be about 30x faster. **Note**\r\nhowever that while the compiler passes all the tests, it currently fails to\r\ncorrectly compile the Tamsin parser written in Tamsin, so it should still be\r\nconsidered a **proof of concept**.\r\n\r\nTo start using `tamsin`,\r\n\r\n* Clone the repository — `git clone https://github.com/catseye/tamsin`\r\n* Either:\r\n * Put the repo's `bin` directory on your `$PATH`, or\r\n * Make a symbolic link to `bin/tamsin` somewhere already on your `$PATH`.\r\n* Errr... that's it.\r\n\r\n(Or, to make those steps trivial, you could use\r\n[toolshelf](https://github.com/catseye/toolshelf) and run\r\n`toolshelf dock gh:catseye/tamsin`)\r\n\r\nThen you can run `tamsin` like so:\r\n\r\n* `tamsin run eg/csv_parse.tamsin < eg/names.csv`\r\n\r\nYou can also compile to C and compile the C to an executable and run the\r\nexecutable all in one step, like so:\r\n\r\n* `tamsin loadngo eg/csv_extract.tamsin < eg/names.csv`\r\n\r\nDesign Goals\r\n------------\r\n\r\n* Allow parsers, static analyzers, interpreters, and compilers to be\r\n quickly prototyped. (And in the future, processor simulators and VM's\r\n and such things too.)\r\n* Allow writing these things very compactly.\r\n* Allow writing anything using only recursive-descent parsing techniques\r\n (insofar as this is possible.)\r\n* Provide means to solve practical problems.\r\n* Keep the language simple (grammar should fit on a page.)\r\n* Recognize that the preceding two goals are in tension.\r\n* Have a relatively simple reference implementation (currently less than\r\n 2500 lines of code, including everything — debugging and the C runtime\r\n used by the compiler.)\r\n\r\nLicense\r\n-------\r\n\r\nBSD-style license; see the file [LICENSE](https://github.com/catseye/Tamsin/blob/master/LICENSE).\r\n\r\nRelated work\r\n------------\r\n\r\n* [CoCo/R](http://www.scifac.ru.ac.za/coco/) (parser generation)\r\n* [Parsec](http://www.haskell.org/haskellwiki/Parsec) (parser combination)\r\n* [Perl](http://perl.com/) (rubbish listing)\r\n* [Erlang](http://erlang.org/) (pattern-matching)\r\n [K](https://github.com/kevinlawler/kona) (similar feel; Tamsin\r\n is a _vertical language_)\r\n* [Cat's Eye Technologies](http://catseye.tc)' esoteric and experimental\r\n languages:\r\n * [Squishy2K](http://catseye.tc/node/Squishy2K)\r\n * [Arboretuum](http://catseye.tc/node/Arboretuum)\r\n * [Treacle](http://catseye.tc/node/Treacle)\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}⏎ |