├── examples ├── print-number.ds ├── print-string.ds ├── print-variable.ds ├── hello-world.ds ├── print-operator.ds └── variable.ds ├── logo.png ├── poster.jpg ├── LICENSE ├── DotWhitespace.py └── README.md /examples/print-number.ds: -------------------------------------------------------------------------------- 1 | # PRINT ('NUM', 10) 2 | .. . . 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaseMax/DotWhitespace/HEAD/logo.png -------------------------------------------------------------------------------- /examples/print-string.ds: -------------------------------------------------------------------------------- 1 | # PRINT ('STR', 'abcd') 2 | .. . . . . . 3 | -------------------------------------------------------------------------------- /poster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaseMax/DotWhitespace/HEAD/poster.jpg -------------------------------------------------------------------------------- /examples/print-variable.ds: -------------------------------------------------------------------------------- 1 | # DEFINE abcd ('NUM', 1230) 2 | . . . . . . . . . 3 | # PRINT ('VAR', 'abcd') 4 | .. . . . . 5 | -------------------------------------------------------------------------------- /examples/hello-world.ds: -------------------------------------------------------------------------------- 1 | # PRINT 'hello world' 2 | .. . . . . . .. . . . . . 3 | -------------------------------------------------------------------------------- /examples/print-operator.ds: -------------------------------------------------------------------------------- 1 | # PRINT ('NUM', 100*20 = 2000) 2 | .. . . . . . 3 | # PRINT ('NUM', 100-20 = 80) 4 | .. . . . . . 5 | # PRINT ('NUM', 100+20 = 120) 6 | .. . . . . . 7 | # PRINT ('NUM', 100+20+40 = 160) 8 | .. . . . . . . . 9 | # PRINT ('NUM', 100/20 = 5) 10 | .. . . . . . 11 | # PRINT ('NUM', 100/20/20 = 0.25) 12 | .. . . . . . . . 13 | # PRINT ('NUM', 100/20/2 = 2.5) 14 | .. . . . . . . 15 | -------------------------------------------------------------------------------- /examples/variable.ds: -------------------------------------------------------------------------------- 1 | # DEFINE abc ('STR', 'ccd') 2 | . . . . . . . . . 3 | # PRINT ('VAR', 'abc') 4 | .. . . . . 5 | 6 | # DEFINE abc ('STR', 'abd') 7 | . . . . . . . . . 8 | # PRINT ('VAR', 'abc') 9 | .. . . . . 10 | 11 | # DEFINE abd ('VAR', 'abc') 12 | . . . . . . . . . 13 | # PRINT ('VAR', 'abd') 14 | .. . . . . 15 | 16 | # DEFINE abc ('NUM', 1230) 17 | . . . . . . . . . 18 | # PRINT ('VAR', 'abc') 19 | .. . . . . 20 | 21 | # DEFINE abc ('NUM', 123) 22 | . . . . . . . . 23 | # PRINT ('VAR', 'abc') 24 | .. . . . . 25 | 26 | # DEFINE abc ('NUM', 12) 27 | . . . . . . . 28 | # PRINT ('VAR', 'abc') 29 | .. . . . . 30 | 31 | # DEFINE abc ('NUM', 52) 32 | . . . . . . . 33 | # PRINT ('VAR', 'abc') 34 | .. . . . . 35 | 36 | # DEFINE abc ('NUM', 52*12=624) 37 | . . . . . . . . . 38 | # PRINT ('VAR', 'abc') 39 | .. . . . . 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Max Base 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /DotWhitespace.py: -------------------------------------------------------------------------------- 1 | # Max Base 2 | # DotWhitespace Interpreter 3 | # https://github.com/BaseMax/DotWhitespace 4 | # Date: 2020-07-17, 2020-07-23 5 | import sys 6 | import string 7 | 8 | debug=False 9 | chars=' '+string.ascii_lowercase+string.ascii_uppercase+'0123456789!@#$%^&*()_-=+?<>[]{}' 10 | ops='+-*/^%' 11 | variable={} 12 | ''' 13 | T + 14 | TT - 15 | TTT * 16 | TTTT / 17 | TTTTT ** 18 | TTTTTT % 19 | . 20 | ''' 21 | ''' 22 | .S.SS.SSS T .SS.S ; ABC = 'BA' 23 | .S.SS.SSS T T SS . S ; ABC = 10 24 | 25 | ..S T .S.SS.SSS ; PRINT ABC 26 | ..S .SS.S ; PRINT 'BA' 27 | ..ST SS.S ; PRINT 10 28 | ..ST SS.S ; PRINT 10 29 | ..ST SS.S T SSS.S ; PRINT 10 + 20 30 | ... 31 | ''' 32 | 33 | def calculate_number(values): 34 | result=0 35 | i=0 36 | # for value in values: 37 | while i 8 | 9 |

10 | 11 | ### Hello, World in `.Whitespace` 12 | 13 | #### From a file 14 | 15 | `$ python DotWhitespace.py examples/hello-world.ds` 16 | 17 | ``` 18 | .. . . . . . .. . . . . . 19 | ``` 20 | 21 | #### From standard input 22 | 23 | ```sh 24 | $ cat examples/hello-world.ds | python DotWhitespace.py - 25 | ``` 26 | 27 | Output: `hello world` 28 | 29 | ### Sample Program 30 | 31 | ``` 32 | . . . . . . . . . 33 | . . . . . . . . . 34 | . . . . . . . . . 35 | .. . . . . 36 | .. . . . . 37 | .. . . 38 | .. . . . . . 39 | .. . . . 40 | ``` 41 | 42 | It is actually equivalent to: 43 | 44 | ``` 45 | .S.S.SS.SSS.T.S.SS.SSS. ; DEFINE abc ('STR', 'abc') 46 | .S.S.SS.SSS.TT.S.SS.SSS. ; DEFINE abc ('VAR', 'abc') 47 | .S.S.SS.SSS.TSS.SSS.SSSS.S. ; DEFINE abc ('NUM', 1230) 48 | ..ST.S.SS.SSS. ; PRINT ('VAR', 'abc') 49 | ..S.S.SS.SSS. ; PRINT ('STR', 'abc') 50 | ..SSS.S. ; PRINT ('NUM', 10) 51 | ..SSS.S.S.TSSS.S. ; PRINT ('NUM', 120) 52 | ..SSS.S.STSSS.S ; PRINT ('NUM', 120) 53 | ``` 54 | 55 | Output: 56 | 57 | ``` 58 | 1230 59 | abc 60 | 10 61 | 120 62 | 120 63 | ``` 64 | 65 | ## Whitespace 66 | 67 | This language was inspired by [Whitespace](https://en.wikipedia.org/wiki/Whitespace_(programming_language)). 68 | 69 | However DotWhitespace is not a whitespace interpreter, and the grammar is different in many ways. 70 | 71 | It also has dots, For example: 72 | 73 | ## DotWhitespace Commands 74 | 75 | There are only three types of commands in this language. 76 | 77 | `S` means whitespace character. 78 | 79 | - Print to console (String or Number directly or from a variable) 80 | ``` 81 | ..S 82 | ``` 83 | 84 | - Read input from console (not yet developed); __I need help from others.__ 85 | ``` 86 | ...S 87 | ``` 88 | 89 | - Variable definition 90 | ``` 91 | .S 92 | ``` 93 | 94 | ### Operators 95 | 96 | `T` means tab character. (`\t`) 97 | 98 | | Syntax | Operator | 99 | | ------- | -------- | 100 | | T | + | 101 | | TT | - | 102 | | TTT | * | 103 | | TTTT | / | 104 | | TTTTT | ^ | 105 | | TTTTTT | % | 106 | 107 | Note: There are no parentheses, So the priority of the operators will not support all mathematics expression. 108 | 109 | ### Debug 110 | 111 | You can pass `-debug` argument, then you will see debug information in **stout**. 112 | 113 | e.g: `$ python DotWhitespace.py examples/hello-world.ds -debug` 114 | or `$ python DotWhitespace.py -debug examples/hello-world.ds` 115 | 116 | Output: 117 | 118 | ``` 119 | ('PRINT', ('STR', 'hello world')) 120 | hello world 121 | ``` 122 | 123 | ### Examples 124 | 125 | - Input: `. . . . .\t. . . .\n` 126 | 127 | DEFINE abcd ('STR', 'abcd') 128 | 129 | - Input: `. . . . .\t\t. . . .\n` 130 | 131 | DEFINE abcd ('VAR', 'abcd') 132 | 133 | - Input: `. . . . .\t . . . .\n` 134 | 135 | DEFINE abcd ('NUM', 1230) 136 | 137 | - Input: `.. \t. . . .\n` 138 | 139 | PRINT ('VAR', 'abcd') 140 | 141 | - Input: `.. . . . .\n` 142 | 143 | PRINT ('STR', 'abcd') 144 | 145 | - Input: `.. . .\n` 146 | 147 | PRINT ('NUM', 10) 148 | 149 | - Input: `.. . . .\t . .\n` 150 | 151 | PRINT ('NUM', 120) 152 | 153 | - Input: `.. . . \t . \n` 154 | 155 | PRINT ('NUM', 120) 156 | 157 | ### Characters supported as string: 158 | 159 | `(space)abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+?<>[]{}` 160 | 161 | Note: You will not be able to print any characters other than the above. 162 | 163 | ### TODO 164 | 165 | - Implement **float number**. 166 | - Display Tree of program. 167 | - Implement Read Input. (`input()` in python or `scanf()` in c, one for read string and another for number) 168 | *What about reading a line or float number!* 169 | 170 | - Implement loop (`for`) 171 | - Implement if, and else (`if(...){} else{}`) 172 | - Implement logical operators (`> < >= <= ==`) 173 | 174 | ### ChangeLog 175 | 176 | - [x] 2020-07-23: Get filename from argument and reads from file. 177 | - [x] 2020-07-23: Adding `whitespace` (\s) as supported character. (e.g: we want to display `Hello World`, Not `HelloWorld`) 178 | 179 | ### Similar Projects 180 | 181 | - https://github.com/BaseMax/MiniCalculatorInterpreter 182 | - https://github.com/BaseMax/CFG2CNF 183 | 184 | 185 | ### Acknowledgments 186 | 187 | The grammar idea for this language was first taken from Whitespace, but these have nothing to do with each other and are different in many ways. 188 | 189 | Thanks to Prof. Jeremy Douglass for mentions this to me. [#1](https://github.com/BaseMax/DotWhitespace/issues/1) 190 | 191 | --------- 192 | 193 | # Max Base 194 | 195 | My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. ([Max Base](https://maxbase.org/)) 196 | 197 | ## Asrez Team 198 | 199 | A team includes some programmer, developer, designer, researcher(s) especially Max Base. 200 | 201 | [Asrez Team](https://www.asrez.com/) 202 | 203 | --------------------------------------------------------------------------------