Compare commits

..

634 Commits

Author SHA1 Message Date
Matthew Butterick 7d41a489c6 ensure prev-indent is an exact-nonnegative-integer 2 years ago
Matthew Butterick b0d133f4ba suppress testing of indenter due to CI issue 4 years ago
Matthew Butterick 07ef0ea181
badge harder 4 years ago
Matthew Butterick c71303e5f5
badge it 4 years ago
Matthew Butterick a2d7349459
Update README.md 4 years ago
Bogdan Popa 216536ef29
improve CI workflow (#23)
* ci: run a single Xvfb instance for all tests

* ci: add 8.0 and 8.1

* ci: skip failures on 6.7 BC, 7.{7,8,9} CS, currenct BC&CS
4 years ago
Matthew Butterick 7f1f62d714
Update README.md 4 years ago
Matthew Butterick d75a344bee
Update module.rkt 4 years ago
Matthew Butterick f0e2cb5b32 doc fix (closes #22) 4 years ago
Matthew Butterick 68bafddd61
Update ci.yml 4 years ago
Matthew Butterick bac21d8849 Revert "allow false"
This reverts commit dfef06c967.
4 years ago
Matthew Butterick 08698d0573
Update ci.yml 4 years ago
Matthew Butterick 9d86c43758 change CI action 4 years ago
Matthew Butterick bc67284dfc switch Travis for GH actions 4 years ago
Matthew Butterick dfef06c967 allow false 4 years ago
Matthew Butterick db99679d5e less def 5 years ago
Matthew Butterick bf374b1514 missing import 5 years ago
Matthew Butterick f86e14d579 update travis 5 years ago
Matthew Butterick 2aa3dbade1 move br/macro to separate package 5 years ago
Matthew Butterick 1f571fc8de unnecessary predicate 5 years ago
Matthew Butterick 6ec0d25f5d
Update LICENSE.md 5 years ago
Matthew Butterick 853e791e84 new xvfb notation for travis 5 years ago
Matthew Butterick f2eb41aab9 disable @ command char 5 years ago
Matthew Butterick e65ef99a06 touchup 5 years ago
Matthew Butterick 5fc143c123 fix negativity, more 5 years ago
Matthew Butterick 9c168fbd98 fix negativity 5 years ago
Ryan Davis 83206c4521 Extended report-datum to be friendly to eof.
read-syntax returns either a syntax or eof. This allows report-datum
to be used to debug read-syntax issues.
5 years ago
Ryan Davis d0f5fa76a9 strip trailing whitespace
separate from my content commit so you can skip this if you want
5 years ago
Matthew Butterick 0a625a17ee simplify 5 years ago
Matthew Butterick 310651e374 newline 5 years ago
Matthew Butterick 7547324037 omit srcloc 5 years ago
Matthew Butterick efa9ce3264 strip-bindings 5 years ago
Matthew Butterick 3999b3515b tacopocalypse sample 5 years ago
Matthew Butterick 1fe93f59a2 bump version to v1.6 5 years ago
Matthew Butterick 4f3db25a0b adjust numbers 5 years ago
Matthew Butterick 7ea139ac4f refinement 5 years ago
Matthew Butterick d649998e74 omit 5 years ago
Matthew Butterick a948725d58
Update .travis.yml 5 years ago
Matthew Butterick 8677730d47
Update .travis.yml 5 years ago
Matthew Butterick ad48faa13d demo details 5 years ago
Matthew Butterick e0944fea24 update scriptish 5 years ago
Matthew Butterick 944c543db7 refac scriptish 6 years ago
Matthew Butterick 37bc753b27 add `lexer-file-path` 6 years ago
Matthew Butterick 0a0d5831a7 refactor 6 years ago
Matthew Butterick ac5daac9ea more consistent 6 years ago
Matthew Butterick 06a0c155ab update algebra & precalc demos 6 years ago
Matthew Butterick 684abfc3e6 update algebra demo 6 years ago
Matthew Butterick 6d4f0a7b69 changes 6 years ago
Matthew Butterick 0fededb98a use lozenge 6 years ago
Matthew Butterick 5f98d03dab add mb 6 years ago
Matthew Butterick e88e9b164e refac solution 6 years ago
Matthew Butterick d116cfcb82 self-expanding 6 years ago
Matthew Butterick 02a4d9a50e touchup 6 years ago
Matthew Butterick 6024945967 touchup 6 years ago
Matthew Butterick b4c69df771 reversal 6 years ago
Matthew Butterick 5adc13ec08 touchup demos 6 years ago
Matthew Butterick 70acaa4394 omit 6 years ago
Matthew Butterick 081561e9cd add loc 6 years ago
Matthew Butterick 0b24352082 put on source locations 6 years ago
Matthew Butterick 177f0bbb09 scriptish demo 6 years ago
Matthew Butterick 5c40ca6279 loop touchup 6 years ago
Matthew Butterick 57522a1be9 read, expand, conjunction 6 years ago
Matthew Butterick 3c97c01b62 adjust txtadv 6 years ago
Matthew Butterick 67e0064c45 numberstring demo 6 years ago
Matthew Butterick 89c652afd6 mirror demo 6 years ago
Matthew Butterick e5523b2835 dyadic demo 6 years ago
Matthew Butterick c883cb05b2
Update README.md 6 years ago
Matthew Butterick 8744265a90 move it 6 years ago
Matthew Butterick cd68f12985 correct output contracts (fixes #19) 6 years ago
Matthew Butterick 52a91b7183 add dep 6 years ago
Matthew Butterick 1116d43e58 note 6 years ago
Matthew Butterick 15b00031e8 retry 6 years ago
Matthew Butterick 6b4743728b Revert "Update .travis.yml"
This reverts commit f138f7a22a.
6 years ago
Matthew Butterick 9e6349d602 also bump 6 years ago
Matthew Butterick f138f7a22a
Update .travis.yml 6 years ago
Matthew Butterick db0dedfbcf also bump 6 years ago
Matthew Butterick eec4502c4c bump to 1.5; min version 6.7 6 years ago
Matthew Butterick 90c45a7ed6 and quicklang 6 years ago
Matthew Butterick 0bd5c4c09d put debug in default environment 6 years ago
Matthew Butterick 87ce53e51e update info 6 years ago
Matthew Butterick 715bdc66d2 oh, paren 6 years ago
Matthew Butterick a1c4af04aa reorg 6 years ago
Matthew Butterick 60cdb5bf2f figures 6 years ago
Matthew Butterick c1cc8557e8 make arg names consistent 6 years ago
Matthew Butterick eeaa9a41ed
Update README.md 6 years ago
Matthew Butterick b8eb7f14e6 consistency 6 years ago
Matthew Butterick 3003bc61c3 don't forget this case 6 years ago
Matthew Butterick 1d2b75456e correct contract on indenter 6 years ago
Matthew Butterick bac7990c43 space 6 years ago
Matthew Butterick 065364999e
Update .travis.yml 6 years ago
Matthew Butterick ae6303b237 conform names 6 years ago
Matthew Butterick bee6cd8ec1 repair unit tests 6 years ago
Matthew Butterick d92e06231a fix grammar bug 6 years ago
Matthew Butterick 28bc51a793 edits 6 years ago
Matthew Butterick f21e0f7c20 touchups 6 years ago
Matthew Butterick 545b4229fb burnish 6 years ago
Matthew Butterick 1826f8a00f nits 6 years ago
Matthew Butterick fe20dade03 correction 6 years ago
Matthew Butterick ddd430ff75 corrections 6 years ago
Matthew Butterick fb3db2b415 remove a modulo 6 years ago
Matthew Butterick 30200b7551 indent 6 years ago
Matthew Butterick 498a7b2fd0 indents 6 years ago
Matthew Butterick 26f79d4776 indent 6 years ago
Matthew Butterick f4cbcc0ac5 shorten 6 years ago
Matthew Butterick b4588a7767 shorten 6 years ago
Matthew Butterick 9d4292ac85 nits 6 years ago
Matthew Butterick d05ac2ac6a precalc 6 years ago
Matthew Butterick b13ae90903 nudges 6 years ago
Matthew Butterick 8cc09d217c rename simplex 6 years ago
Matthew Butterick 4b5098415d nit 6 years ago
Matthew Butterick 900a7d08f5 bump to 1.4 6 years ago
Matthew Butterick 380f4a2d37 nits 6 years ago
Matthew Butterick 2b776d8ee0 nits 6 years ago
Matthew Butterick 95bfa95b5d demo langs for Racket School 6 years ago
Matthew Butterick b39a1200c3 remove arg 6 years ago
Matthew Butterick cfa5a3598e
Update README.md 6 years ago
Matthew Butterick b3d1d0aaed add an export 7 years ago
Matthew Butterick 2ade55b7ed bump to 1.3 7 years ago
Matthew Butterick 35a4a18976 refactor wires 7 years ago
Matthew Butterick 2e61ddab8d missing `val` 7 years ago
Matthew Butterick ac8aadb6bf with promises 7 years ago
Matthew Butterick 6e1a849339 include promises 7 years ago
Matthew Butterick fadbca3fd2 use guard expr 7 years ago
Matthew Butterick b98131f98a and one more 7 years ago
Matthew Butterick f1969cebd1 change update rule 7 years ago
Matthew Butterick f5b300f6d1 delete unneeded `eof` rules 7 years ago
Matthew Butterick 32f915a844 return #f for line with no indent 7 years ago
Matthew Butterick 51ec447991 return #f not #\nul 7 years ago
Matthew Butterick 8a11393b03 update deps 7 years ago
Matthew Butterick 594ac04ff9
Update .travis.yml 7 years ago
Matthew Butterick 0f002c5586 enable at-reader in `br` languages 7 years ago
Matthew Butterick b2c3988d81 rename `test-reader` → `apply-reader` 7 years ago
Matthew Butterick ece33a624e put `br/module` in #lang br 7 years ago
Matthew Butterick 46a0614a3e provisional `br/module` module 7 years ago
Matthew Butterick 72d551b38b reorder 7 years ago
Matthew Butterick 91f38b554c
Add Rackets 6.11 & 6.12 7 years ago
Matthew Butterick 2f69dda794 unless → when 7 years ago
Matthew Butterick 86b788a304 further simplify literalization 7 years ago
Matthew Butterick 6866c79327 add deps 7 years ago
Matthew Butterick 2912d8392f handle pair patterns 7 years ago
Matthew Butterick 35c7fe7a7a better literal detection 7 years ago
Matthew Butterick 3a6f7c407a nit 7 years ago
Matthew Butterick 5e859a7440 update README 7 years ago
Matthew Butterick 66a826d6f6 edit parser-tester 7 years ago
Matthew Butterick 9c97fe31d7 code typo 7 years ago
Matthew Butterick 6b9dd5a011 test JSON using jsexpr 7 years ago
Matthew Butterick 3cf4fe260e test demo languages 7 years ago
Matthew Butterick b16e11a8a2 source typo 7 years ago
Matthew Butterick 73fb09a017 test that 7 years ago
Matthew Butterick c8bac11d8b check for identifier (fixes #15) 7 years ago
Matthew Butterick 33acb10b31 omit bound id from generated literals (fixes #14) 7 years ago
Matthew Butterick 4bea7423b1 bump to v1.1 7 years ago
Matthew Butterick d4585d825a still more degeneracy 7 years ago
Matthew Butterick 587f5ef946 pair repair 7 years ago
Matthew Butterick f0ec809502 repair 7 years ago
Matthew Butterick 94e19b851e farewell 7 years ago
Matthew Butterick 50bbc22164 prevent `let` collapse 7 years ago
Matthew Butterick d177a7f06f finicky kitty 7 years ago
Matthew Butterick 177dae090f remove duplicates 7 years ago
Matthew Butterick 3c452e4d90 use more `syntax-parse` 7 years ago
Matthew Butterick 91281379f3 correct indenter contract 7 years ago
Matthew Butterick 0af8f1aeeb correct missing `datum?` 7 years ago
Ben Greenman 8000d41389 define-macro: check that ... only follow wildcards 7 years ago
Matthew Butterick 2101e8e9b8 Test Rackets 6.7–6.10 7 years ago
Matthew Butterick b665cd72db naming glitch 8 years ago
Matthew Butterick e4a39ee906 `generate-literals`: treat nonalphabetic identifiers as literals 8 years ago
Matthew Butterick a5dc7b4ea7 nit, picked 8 years ago
Matthew Butterick d5079d88ce fix test file 8 years ago
Matthew Butterick 85759404e9 don't actually install jsonic docs 8 years ago
Matthew Butterick 95fec6d45d allow demo languages to be compiled 8 years ago
Matthew Butterick 2353267090 Update README.md 8 years ago
Matthew Butterick 7c0f97c8ca change linebreak 8 years ago
Matthew Butterick bf8d332bc9 groovier 8 years ago
Matthew Butterick 1b4ef83c1e restore test-reader 8 years ago
Matthew Butterick 6c52696bfb trim 8 years ago
Matthew Butterick 101ec6c41a line breaks 8 years ago
Matthew Butterick 8e405f6287 renames 8 years ago
Matthew Butterick f955987e2b rename predicate 8 years ago
Matthew Butterick 2f1a2b4520 defense 8 years ago
Matthew Butterick bb4dce853c improve test message 8 years ago
Matthew Butterick 25c760a74e bump versions 8 years ago
Matthew Butterick b5f01e1e85 change indenting 8 years ago
Matthew Butterick 242c3dc64e change indenting of while & until 8 years ago
Matthew Butterick 40786d7010 edits 8 years ago
Matthew Butterick b2ad7fbd25 Update README.md 8 years ago
Matthew Butterick c3b8660e1f fixup 8 years ago
Matthew Butterick f7eedcef6f move clargs into runtime 8 years ago
Matthew Butterick 59a63f71dc refactor 8 years ago
Matthew Butterick 5a90f14d0c improve colorer 8 years ago
Matthew Butterick ee35d0d287 reformats 8 years ago
Matthew Butterick db957f3041 samplers 8 years ago
Matthew Butterick eb100cd545 refactor 8 years ago
Matthew Butterick a9b6cb6181 touchup 8 years ago
Matthew Butterick 10bd6435d4 nicer 8 years ago
Matthew Butterick dfe6ef6ffd straighten out lexing 8 years ago
Matthew Butterick c35b02c986 add new token 8 years ago
Matthew Butterick bf76152db6 new sample 8 years ago
Matthew Butterick 0202647959 tokenize only dialect 8 years ago
Matthew Butterick dccdc4ae1d adjustments 8 years ago
Matthew Butterick 04b52e473e better exports 8 years ago
Matthew Butterick 5613323df7 tighten 8 years ago
Matthew Butterick d60ef52e2b resume in parser 8 years ago
Matthew Butterick f5dd28cd05 fix lexer 8 years ago
Matthew Butterick 5c817a33b7 not quite there 8 years ago
Matthew Butterick 76fea3c627 del 8 years ago
Matthew Butterick 2e69bbda33 fix sample 8 years ago
Matthew Butterick e9c10a236e change rule name 8 years ago
Matthew Butterick 42d3eaac68 change error msg 8 years ago
Matthew Butterick 565eb81179 use ID 8 years ago
Matthew Butterick 8452fdfded better error 8 years ago
Matthew Butterick 6acea5ed3d tidying 8 years ago
Matthew Butterick 3dbddf6d1d ignore 8 years ago
Matthew Butterick 199a4a5d8c update docs 8 years ago
Matthew Butterick 198757a437 stub out lang docs 8 years ago
Matthew Butterick 7ede91d508 update repl handling 8 years ago
Matthew Butterick 92a949c08e add `pattern-case` and `pattern-case-filter` 8 years ago
Matthew Butterick 41a898b268 more generous repl 8 years ago
Matthew Butterick 634c1d1f51 update 8 years ago
Matthew Butterick 965ebdde57 add #:context argument to prefix-id et al 8 years ago
Matthew Butterick c1e2939aa6 simplify runtime config 8 years ago
Matthew Butterick 5cc0f73028 repl setup 8 years ago
Matthew Butterick 8be5afd15c remove comment 8 years ago
Matthew Butterick e571d9b372 support shell args 8 years ago
Matthew Butterick 29f13113f7 resume in runtime repl 8 years ago
Matthew Butterick 841f12e09a start demo 3 8 years ago
Matthew Butterick bfbdee9f79 stx-flatten 8 years ago
Matthew Butterick c3eed21f32 Update README.md 8 years ago
Matthew Butterick 05319d0b2f don't test brag 8 years ago
Matthew Butterick 9279ac21da correction 8 years ago
Matthew Butterick b799b4ee28 Update `brag` paths 8 years ago
Matthew Butterick 48cd7f0082 move brag 8 years ago
Matthew Butterick 1dc08fbe92 tidy 8 years ago
Matthew Butterick 5b894d8ae8 tidying 8 years ago
Matthew Butterick 18081e6d6e tidying 8 years ago
Matthew Butterick 50bd8e6301 copy edits 8 years ago
Matthew Butterick d4d5ea638d document push! and pop! 8 years ago
Matthew Butterick f932378a9d touchups 8 years ago
Matthew Butterick 706e20b5fb fiddle with `case-pattern` 8 years ago
Matthew Butterick 17785714fe deletion 8 years ago
Matthew Butterick 86e19e0c0e document `stx-flatten` 8 years ago
Matthew Butterick 92c5eb8a4d tidier 8 years ago
Matthew Butterick 86c57d32dd fix mod 8 years ago
Matthew Butterick c85b0e5cc9 take account of hide property in rule flattening (fixes #8) 8 years ago
Matthew Butterick cf505f2995 improve code comments 8 years ago
Matthew Butterick 711fa643bf null 8 years ago
Matthew Butterick 0652df09eb edits 8 years ago
Matthew Butterick 32acbeb501 updates 8 years ago
Matthew Butterick 33fe21405f add debug dialects 8 years ago
Matthew Butterick 4e5f6d9acd move 8 years ago
Matthew Butterick 1f770220b7 modularize run 8 years ago
Matthew Butterick 26dd72cb7a whitespace 8 years ago
Matthew Butterick c8979b15b8 update docs 8 years ago
Matthew Butterick 024d826003 update docs link 8 years ago
Matthew Butterick 6c3c0940ad rename some identifiers 8 years ago
Matthew Butterick e054cc1273 update sample files 8 years ago
Matthew Butterick 7b573be83c updates 8 years ago
Matthew Butterick 1902d283c9 adjust colorer 8 years ago
Matthew Butterick fad102d545 adjust rem semantics 8 years ago
Matthew Butterick f49f42003a reorg 8 years ago
Matthew Butterick acf9e65315 reorg 8 years ago
Matthew Butterick 715b9c0f1d tiny renaming 8 years ago
Matthew Butterick 422b3d105d update lexer test 8 years ago
Matthew Butterick a48b7824f1 add multiple print args 8 years ago
Matthew Butterick f9d6aa5d18 add basic colorer 8 years ago
Matthew Butterick 31220fc2db add `apply-colorer` 8 years ago
Matthew Butterick 4462141a41 remove `b-func` 8 years ago
Matthew Butterick 0ad47dd273 tweak 8 years ago
Matthew Butterick cc4b7d358c consolidate 8 years ago
Matthew Butterick 696a73052b tidying 8 years ago
Matthew Butterick 12bc37145a handle negative numbers, for / next 8 years ago
Matthew Butterick d0ced4022f remove tech links 8 years ago
Matthew Butterick db8346ceac doc corrections 8 years ago
Matthew Butterick 1f1ea325ec document cuts & splices 8 years ago
Matthew Butterick c5a1126754 new sample grammar 8 years ago
Matthew Butterick 3bc9fc3173 update docs 8 years ago
Matthew Butterick 7ddf8b594d update docs 8 years ago
Matthew Butterick 4c02bf36cd rename `parse-tree` as `parse-to-datum` 8 years ago
Matthew Butterick c58ac2a806 set up basic-demo-2 8 years ago
Matthew Butterick d0f83eb24a add `push!` and `pop!` 8 years ago
Matthew Butterick a0c9de7535 improve error reporting in `with-pattern` 8 years ago
Matthew Butterick 41bf0b964a adjust 8 years ago
Matthew Butterick 42d14dec74 update 8 years ago
Matthew Butterick c43a486f9d add literal generator to `with-pattern` 8 years ago
Matthew Butterick 347722bc27 rearrangements 8 years ago
Matthew Butterick 88b731cb72 detail 8 years ago
Matthew Butterick de98d96c74 basic updates 8 years ago
Matthew Butterick 2392559263 edit 8 years ago
Matthew Butterick c149b13003 edits 8 years ago
Matthew Butterick bd180e6ed6 update lexer 8 years ago
Matthew Butterick 46f6ab0c36 use newlines in lexer 8 years ago
Matthew Butterick 8504cd4d80 stricter about line breaks, less finicky about blank statements 8 years ago
Matthew Butterick eab018a9a2 add `from/stop-before` 8 years ago
Matthew Butterick 0f576805ac Update .travis.yml 8 years ago
Matthew Butterick d1205bb8c2 add `lexer-file-path` 8 years ago
Matthew Butterick 728a06cf0e change doc title 8 years ago
Matthew Butterick 509de033a0 tweakage 8 years ago
Matthew Butterick 85ecc17a9d more 8 years ago
Matthew Butterick 4032a65eb8 add `apply-lexer` 8 years ago
Matthew Butterick d4fe2c92ea return-without-srcloc 8 years ago
Matthew Butterick 5ef1a11a2b quick fix 8 years ago
Matthew Butterick c4f90daf74 spaces 8 years ago
Matthew Butterick 6221ca5959 refactor 8 years ago
Matthew Butterick 50eb4964cd bf-loop nits 8 years ago
Matthew Butterick f25679622a updates 8 years ago
Matthew Butterick 87009e367b changes 8 years ago
Matthew Butterick aa43154777 the tightening 8 years ago
Matthew Butterick afa9af72d8 better names in jsonic 8 years ago
Matthew Butterick 2eb46aaa81 change op & loop to use bf- prefix 8 years ago
Matthew Butterick 7a7e162988 update reader & tokenizer 8 years ago
Matthew Butterick 3347a86c0d update reader & tokenizer 8 years ago
Matthew Butterick fb26d2b7cd change name 8 years ago
Matthew Butterick 5607a7aa02 update docs 8 years ago
Matthew Butterick d20c328d93 renames 8 years ago
Matthew Butterick 1f9b0db91d adjust funstacker module name 8 years ago
Matthew Butterick 5197b0b82f adjust deps 8 years ago
Matthew Butterick 4e950845d6 adjust deps 8 years ago
Matthew Butterick db8f029d5c adjust deps 8 years ago
Matthew Butterick 8a8a780936 delete local docs 8 years ago
Matthew Butterick 906215d03e Update .travis.yml 8 years ago
Matthew Butterick 9e0e64f6d2 Update .travis.yml 8 years ago
Matthew Butterick 5723af898e use br-parser-tools 8 years ago
Matthew Butterick 86df35057c fork parser tools 8 years ago
Matthew Butterick 2f5923e670 fewer requires 8 years ago
Matthew Butterick 52874c63d5 use lexer-srloc 8 years ago
Matthew Butterick 6613a3e62c resolve 8 years ago
Matthew Butterick d8fa50d8ea better idea 8 years ago
Matthew Butterick 47fc5e8155 simpler 8 years ago
Matthew Butterick 3c74bc5f47 delete reference 8 years ago
Matthew Butterick 1eb4ddee40 Update .travis.yml 8 years ago
Matthew Butterick c33146bdb8 remove python test & dependency 8 years ago
Matthew Butterick dc84d05764 info.rkt 8 years ago
Matthew Butterick 96a0cf31b3 update 8 years ago
Matthew Butterick 28d8a93dbe update 8 years ago
Matthew Butterick 8a7504ac97 correct 3D syntax 8 years ago
Matthew Butterick 6e5a3f49d9 touchup 8 years ago
Matthew Butterick 15675c7558 boom 8 years ago
Matthew Butterick bc5bcad98c update brag docs 8 years ago
Matthew Butterick 4b8d5ed12e unbreak BNF grammar example 8 years ago
Matthew Butterick 96a5875e7c simpler 8 years ago
Matthew Butterick 0dd59d8c13 simpler 8 years ago
Matthew Butterick bfd3690eca start basic colorer 8 years ago
Matthew Butterick 726bca2542 add `caseq` and `casev` 8 years ago
Matthew Butterick 626e8f4fd4 fix 8 years ago
Matthew Butterick 330d822f9f fixes 8 years ago
Matthew Butterick 3d8f7f2ded fixes 8 years ago
Matthew Butterick 5d7242fccb finish info.rkt 8 years ago
Matthew Butterick 8bb1dc4cc2 update deps 8 years ago
Matthew Butterick 11dd0885f6 finish scrbl 8 years ago
Matthew Butterick 46f389f64d start jsonic-demo-3 8 years ago
Matthew Butterick 763bb5165e correct macro 8 years ago
Matthew Butterick 10730b5bfd use `br/list` in docs 8 years ago
Matthew Butterick f7a960db8f add `br/list` 8 years ago
Matthew Butterick 02d912b564 omit some compiles 8 years ago
Matthew Butterick d031040262 renamings 8 years ago
Matthew Butterick 6259bbdd0c Revert "suppress testing of demo dirs"
This reverts commit 3b8d370ec3.
8 years ago
Matthew Butterick 3b8d370ec3 suppress testing of demo dirs 8 years ago
Matthew Butterick 13e7f3ee97 use `contract-out` instead of `define/contract` 8 years ago
Matthew Butterick 642ebc436a rearrangements 8 years ago
Matthew Butterick ff4bda8ee3 add -demo suffix to test langs to avoid name collisions 8 years ago
Matthew Butterick bba9e09f37 update info 8 years ago
Matthew Butterick 2963ed6860 update info 8 years ago
Matthew Butterick 51f2e7c5c3 update dependencies 8 years ago
Matthew Butterick b1f70be0f9 move demos to `beautiful-racket-demo` pkg 8 years ago
Matthew Butterick a331e63aac touchups 8 years ago
Matthew Butterick 451c006d40 revise buttons 8 years ago
Matthew Butterick c0f33dac9a more docs 8 years ago
Matthew Butterick 5ce9a0df37 better buttons 8 years ago
Matthew Butterick 23b3b2e56c document br/indent 8 years ago
Matthew Butterick ed4d054f3d add drracket module 8 years ago
Matthew Butterick 73341bb5a2 simplify buttons file 8 years ago
Matthew Butterick 093ac69a6a br/indent adjustments 8 years ago
Matthew Butterick 2f177edb5d improve contracts 8 years ago
Matthew Butterick 4f3e6ff4fc doc edit 8 years ago
Matthew Butterick ec6b858f39 move fix upstream 8 years ago
Matthew Butterick ae07f3da64 add support for newline & tab literals in grammars 8 years ago
Matthew Butterick 273753f1d5 add contracts for br/indent (also need docs) 8 years ago
Matthew Butterick 5465cae6c9 changes 8 years ago
Matthew Butterick 747657e6e0 adjust 8 years ago
Matthew Butterick 640c716758 adjust source 8 years ago
Matthew Butterick 522057f692 adjusts 8 years ago
Matthew Butterick 09297e0cad restore standard token-struct printing 8 years ago
Matthew Butterick 8c1cba99ed rearrangement 8 years ago
Matthew Butterick 58ae9d5c08 repair read-syntax 8 years ago
Matthew Butterick 869f59cc1c fix parser 8 years ago
Matthew Butterick 676e79dcea more source loc 8 years ago
Matthew Butterick 960c721e30 adjust 8 years ago
Matthew Butterick 71ace522c6 simplify macros 8 years ago
Matthew Butterick 101a60f0f4 source pos added 8 years ago
Matthew Butterick 5fd9b540e5 use `position` rather than `offset` 8 years ago
Matthew Butterick 9ac0a29049 change token-struct printing to go in srcloc order 8 years ago
Matthew Butterick 1d482ffcbf make some alias names 8 years ago
Matthew Butterick ed19d85278 omit a file from testing 8 years ago
Matthew Butterick 2be7726c88 handle position-tokens correctly in `apply-tokenizer` 8 years ago
Matthew Butterick 747e59ebc5 parser test 8 years ago
Matthew Butterick b6a45815ab updates 8 years ago
Matthew Butterick 6184ebb3e1 add contracts 8 years ago
Matthew Butterick 1f8e1520da rename 8 years ago
Matthew Butterick e66b7acad1 jsonic2: setup 8 years ago
Matthew Butterick 1a033e7980 fix 16bit 8 years ago
Matthew Butterick 7e4d33176a rearrangements 8 years ago
Matthew Butterick 54f1703eb2 add `strip-bindings` and `replace-bindings` 8 years ago
Matthew Butterick 0bc28672f9 combine files 8 years ago
Matthew Butterick f021c09f25 touchup 8 years ago
Matthew Butterick ea28427d86 solve puzzle 8 years ago
Matthew Butterick a4474340b5 update wires 8 years ago
Matthew Butterick fb4aad70e9 delete old stackers 8 years ago
Matthew Butterick fa912ad762 put `strip-context` in br/syntax 8 years ago
Matthew Butterick 8e32cf31f7 rename 8 years ago
Matthew Butterick 83c83dd350 rename more 8 years ago
Matthew Butterick 7f08f2e2c8 rename 8 years ago
Matthew Butterick cacbd37b14 typo 8 years ago
Matthew Butterick 5f72ee4215 reorg 8 years ago
Matthew Butterick 65b34b8409 improve jsonic 8 years ago
Matthew Butterick da2bdce15a improve tokenizer macros 8 years ago
Matthew Butterick ece5a5c290 jsonic alternate 8 years ago
Matthew Butterick 3a6c74360c update 8 years ago
Matthew Butterick 586189012f updates 8 years ago
Matthew Butterick 72bbaa6d53 tweak 8 years ago
Matthew Butterick 1c3f8781f7 improve jsonic 8 years ago
Matthew Butterick e1eee81b03 add `brag/lexer-support` 8 years ago
Matthew Butterick 9e00c6dcf8 split jsonic & jsonic-pro 8 years ago
Matthew Butterick 0cc0929ebc doc fix 8 years ago
Matthew Butterick 0d55aeac82 updates 8 years ago
Matthew Butterick c0508aaea3 add `with-pattern` to docs 8 years ago
Matthew Butterick 9014efcb53 renames 8 years ago
Matthew Butterick 961d3f94de allow numeral-prefixed wildcards 8 years ago
Matthew Butterick 91155648a4 note 8 years ago
Matthew Butterick 5911ee74fe add `racket/vector` to `br` 8 years ago
Matthew Butterick 62e0623bcc Update .travis.yml 8 years ago
Matthew Butterick a4fb46cc4f Update .travis.yml 8 years ago
Matthew Butterick 444b211d7e restore test file 8 years ago
Matthew Butterick b23b8ae957 improve jsonic 8 years ago
Matthew Butterick bb364013ce Merge branch 'master' of https://github.com/mbutterick/beautiful-racket 8 years ago
Matthew Butterick 0e2804fbf2 Update .travis.yml 8 years ago
Matthew Butterick 50162c0307 better 8 years ago
Matthew Butterick 5daa221ea4 better 8 years ago
Matthew Butterick 5e4ed4a89e improve indenter 8 years ago
Matthew Butterick 3fca4ac779 start `br/indent` 8 years ago
Matthew Butterick 1682ef12fc improve indenter 8 years ago
Matthew Butterick ee71ebdc50 note to self 8 years ago
Matthew Butterick 6b30895974 reorg, add toolbar 8 years ago
Matthew Butterick d656b4cf7a improve indenter 8 years ago
Matthew Butterick 5b8d5ec2cb add codepict sample 8 years ago
Matthew Butterick 4a195ef050 start indenter 8 years ago
Matthew Butterick dd67b321d5 improve jsonic coloring lexer 8 years ago
Matthew Butterick 2ae113481c Merge branch 'master' of https://github.com/mbutterick/beautiful-racket 8 years ago
Matthew Butterick 9e02db875f rudimentary jsonic lexer 8 years ago
Matthew Butterick ce5110961d Merge pull request #2 from jsmaniac/doc-fixes
A few tweaks in the docs
8 years ago
Matthew Butterick aa1194f0df Update br.scrbl 8 years ago
Georges Dupéron c6c1e70cab Removed spurious space in @seclink[…] <space here> {text} 8 years ago
Georges Dupéron 229ed0c70d In the documentation for define-macro, use syntax-object instead of (syntax result-expr), as that's the way it is documented below 8 years ago
Matthew Butterick 9e8135ee05 some things 8 years ago
Matthew Butterick 53668f770e use next-token rather than #:skip 8 years ago
Matthew Butterick 474dddf9b3 replace missing line 8 years ago
Matthew Butterick d4ac779fa9 more typo 8 years ago
Matthew Butterick c5cf417b99 typo 8 years ago
Matthew Butterick 7712ab31d4 update brag docs 8 years ago
Matthew Butterick c8899a603b add get-info 8 years ago
Matthew Butterick d6370a7f98 tuneup jsonic 8 years ago
Matthew Butterick e792346b96 simplify jsonic 8 years ago
Matthew Butterick 2c6d8a781a more 8 years ago
Matthew Butterick cd936ae09b how to do this with at-exp reader 8 years ago
Matthew Butterick a3f434c551 resume in lexing comments 8 years ago
Matthew Butterick 12438d2900 notes for later 8 years ago
Matthew Butterick f30922a7dc add `verbose-app` 8 years ago
Matthew Butterick 9a8b95a9f0 add `evaluate` 8 years ago
Matthew Butterick 42d0dacb5b fix `with-shared-id` 8 years ago
Matthew Butterick e2df4fee70 update func expander 8 years ago
Matthew Butterick 90ec2a1244 update func expander 8 years ago
Matthew Butterick 5ba6234a08 resume in bf functions 8 years ago
Matthew Butterick b4a47b754f resume in stx pattern 8 years ago
Matthew Butterick 7e367b3d8d closer 8 years ago
Matthew Butterick 1b1aecbb84 old bf expander 8 years ago
Matthew Butterick 202f6c9c12 rewrite bf expander 8 years ago
Matthew Butterick 8e917003bc add `parse-tree` 8 years ago
Matthew Butterick c0a3020947 resume in hdl-tst 8 years ago
Matthew Butterick f02e605a9c refactory 8 years ago
Matthew Butterick 4847adf7e9 fixup 8 years ago
Matthew Butterick 4c46f9849f reorg 8 years ago
Matthew Butterick b9a1f73036 docs build without error 8 years ago
Matthew Butterick 8fc3cd4f4d touchup 8 years ago
Matthew Butterick e865961c8c gbye 8 years ago
Matthew Butterick 0571f4ebdb more docs 8 years ago
Matthew Butterick ebae6bd11d add case 8 years ago
Matthew Butterick da3ee27045 update define 8 years ago
Matthew Butterick 6fefd30ca7 doc update 8 years ago
Matthew Butterick c1469ee195 update 8 years ago
Matthew Butterick adda7adb88 updates 8 years ago
Matthew Butterick f5078fb50b remove `shared-syntax` 8 years ago
Matthew Butterick 460efbf3dc more cleanup 8 years ago
Matthew Butterick 066ea559cf new syntax 8 years ago
Matthew Butterick 9a1b621969 more cleanup 8 years ago
Matthew Butterick 0ce28acafd cleanup 8 years ago
Matthew Butterick fe100e2ba5 goodbye eopl 8 years ago
Matthew Butterick 47859baa37 doc updates 8 years ago
Matthew Butterick 9a746eeac9 minor updates 8 years ago
Matthew Butterick eeaba0f7c3 test doc linking into br 8 years ago
Matthew Butterick 2df0d0d870 update stackerizer 8 years ago
Matthew Butterick 6af77e0ce5 update funstacker 8 years ago
Matthew Butterick 86ceb297e6 funstacker 8 years ago
Matthew Butterick 48c17bd852 make `format-datum` return void on empty input 8 years ago
Matthew Butterick 9cee43af40 touch 8 years ago
Matthew Butterick ff24afea7b add funstacker & stackerizer 8 years ago
Matthew Butterick 68922b0cb5 update stacker source 8 years ago
Matthew Butterick 7d5a6d45a5 test 6.5 and 6.6 8 years ago
Matthew Butterick 8475995ab2 update 8 years ago
Matthew Butterick 32a7765ac3 tighten 8 years ago
Matthew Butterick 99ebc4f804 add `format-datums` 8 years ago
Matthew Butterick 37951c7198 update bf 8 years ago
Matthew Butterick bc489f37ab the decider 9 years ago
Matthew Butterick 90b8680bd7 compress 9 years ago
Matthew Butterick 3f295b66fa update stacker versions 9 years ago
Matthew Butterick 6a1b143f3f add `strip-identifier-bindings` 9 years ago
Matthew Butterick bc47acd4d4 revise 9 years ago
Matthew Butterick fc1b5659ee make non-mutating `stacker` 9 years ago
Matthew Butterick e0b5855e3e add `br/quicklang` 9 years ago
Matthew Butterick 08dcc922d9 `begin-label` 9 years ago
Matthew Butterick 8135a722ee start `begin-label` experiment 9 years ago
Matthew Butterick 1391c2abae fix amazing and bounce 9 years ago
Matthew Butterick 3bbbf45358 need separate namespace for dim vars 9 years ago
Matthew Butterick 7903287fa2 remove version dependency (fixes #1) 9 years ago
Matthew Butterick b83a09e6af improve handling of negative numbers; add `DEF` 9 years ago
Matthew Butterick ce1b56d019 indenter fix 9 years ago
Matthew Butterick c1b9497b33 start adding keyword arg support to brag (broken) 9 years ago
Matthew Butterick 6ad59477cd nits 9 years ago
Matthew Butterick 83a1090754 more continuations 9 years ago
Matthew Butterick 93db2015af make gosub a continuation 9 years ago
Matthew Butterick 574bb06fb7 add custom indenter 9 years ago
Matthew Butterick b3deb1ed02 a matter of trying harder 9 years ago
Matthew Butterick 146e460a8f refactoring 9 years ago
Matthew Butterick 12f7a3d332 simplify 9 years ago
Matthew Butterick 67ac247f41 add `syntax-flatten` 9 years ago
Matthew Butterick 157787a99f add `syntax-property` annotations to parse tree 9 years ago
Matthew Butterick 281bd09e25 comments 9 years ago
Matthew Butterick 9c9b0e598d improve introduction of identifiers 9 years ago
Matthew Butterick 481cbab336 finish for-next loops 9 years ago
Matthew Butterick 30fa41f05f start implementing for–next loops with continuations 9 years ago
Matthew Butterick 0ad719ce4a edit basic 9 years ago
Matthew Butterick aed79823ea void 9 years ago
Matthew Butterick 3bdde5e129 split out bus properties 9 years ago
Matthew Butterick 24317fc860 chip8 9 years ago
Matthew Butterick 918efa4609 notes 9 years ago
Matthew Butterick ae24f3a10b bye 9 years ago
Matthew Butterick 5c15093fc9 lessons learned 9 years ago
Matthew Butterick 991f052049 renamings 9 years ago
Matthew Butterick 6adee321c0 experiment 9 years ago
Matthew Butterick 3e036415b2 stacks 9 years ago
Matthew Butterick 4bccc6c034 trudge 9 years ago
Matthew Butterick d9e8be7544 rerefactoring 9 years ago
Matthew Butterick fc826f9269 refactoring 9 years ago
Matthew Butterick 4e0e306777 renamings 9 years ago
Matthew Butterick a36fbc2df6 cleaner 9 years ago
Matthew Butterick 7dcce997d0 touchups 9 years ago
Matthew Butterick e85bf68fa7 cleanup 9 years ago
Matthew Butterick 5a78b92d92 rewrite hdl-test language 9 years ago
Matthew Butterick f9f79d63f6 destroy 9 years ago
Matthew Butterick e1e091421e stash 9 years ago
Matthew Butterick 084fb8ace2 mysteries 9 years ago
Matthew Butterick 3516555682 scope experiments 9 years ago
Matthew Butterick 9b47039c0a add `report-datum` 9 years ago
Matthew Butterick fad5a4fce8 `syntax-property*` and other improvements 9 years ago
Matthew Butterick 51ff735f7d fixes 9 years ago
Matthew Butterick 2d5db8afb5 id manipulation, `inject-syntax*` 9 years ago
Matthew Butterick c59b34f868 simpler 9 years ago
Matthew Butterick 187230041e syntaxing 9 years ago
Matthew Butterick 1f0e0eec61 `partition-syntax-case` 9 years ago
Matthew Butterick c53414285f improvements 9 years ago
Matthew Butterick 4e5c5247fa finish experiment 9 years ago
Matthew Butterick 76d1e0ef69 output bus experiment 9 years ago
Matthew Butterick 7617fbb94d adjust parser 9 years ago
Matthew Butterick 6a351e1f0f note 9 years ago
Matthew Butterick b1afb39b78 resume in dmux4way 9 years ago
Matthew Butterick fdc8f6831f adjust output bus 9 years ago
Matthew Butterick cd16f2992d touchup 9 years ago
Matthew Butterick 124c83d34e resume in dmux 9 years ago
Matthew Butterick 1e6407bd1a resume in mux 9 years ago
Matthew Butterick 2fc5f63185 resume in bit subscripts / write into input bus 9 years ago
Matthew Butterick e3334e6498 resume in bit subscripts 9 years ago
Matthew Butterick 0d676282ec halfadder 9 years ago
Matthew Butterick e734151311 fanout 9 years ago
Matthew Butterick 1f805852f0 resume in hdl-test 9 years ago
Matthew Butterick fd4297ddc8 resume in require transformer for Not2 9 years ago
Matthew Butterick 8f434331c1 add 9 years ago
Matthew Butterick 99158a360a adjust 9 years ago
Matthew Butterick e631c39bf2 renames 9 years ago
Matthew Butterick 3af79f911f further 9 years ago
Matthew Butterick 32a14d78af exploration 9 years ago
Matthew Butterick 33e71f260b quiet error 9 years ago
Matthew Butterick 5ea796cbcd one more 9 years ago
Matthew Butterick e3b7495a7a scopes 9 years ago
Matthew Butterick cdda2224da scopes 9 years ago
Matthew Butterick 12f8b3d0a5 simplify 9 years ago
Matthew Butterick 9b2fa914f5 simplify grammar 9 years ago
Matthew Butterick c574ce3b54 use cleaner grammar notation 9 years ago
Matthew Butterick 17d9f17f4e add some notes 9 years ago
Matthew Butterick 61890e18ee refactor ; change hiding char to slash 9 years ago
Matthew Butterick 975d0da0f5 improve txtadv parser with hiding & splicing 9 years ago
Matthew Butterick e435574b9f repair parser & parser tests 9 years ago
Matthew Butterick f57653c43d add splicing for right-hand ids 9 years ago
Matthew Butterick 7c21df6ed4 use new splice & hide chars 9 years ago
Matthew Butterick c985805703 add @ prefix for splicing 9 years ago
Matthew Butterick f312677216 use ! instead of <> for grammar hiding 9 years ago
Matthew Butterick 5d73d41174 adjust 9 years ago
Matthew Butterick d9a33c7948 adjust 9 years ago
Matthew Butterick 086c0aa359 scopes 9 years ago
Matthew Butterick 0a5ef3e4dc scope composition 9 years ago
Matthew Butterick 99951f2f07 Merge branch 'master' of https://github.com/mbutterick/beautiful-racket 9 years ago
Matthew Butterick 6d0ec53400 typos 9 years ago
Matthew Butterick 6a3d4c5c15 syntaxing 9 years ago
Matthew Butterick 245a488ac0 note 9 years ago
Matthew Butterick fd5c53f019 victory 9 years ago
Matthew Butterick 0f9e8018ea whoops 9 years ago
Matthew Butterick feec0f85d5 better regexp 9 years ago
Matthew Butterick 87f5b186a2 more cleanup 9 years ago
Matthew Butterick 7a4999ee36 cleanup 9 years ago
Matthew Butterick 07350988e7 make hider/splicer tests 9 years ago
Matthew Butterick 992fccdb1d change lhs-id key from 'hide to 'splice 9 years ago
Matthew Butterick f6181b90d7 lhs-id splicing works ; tests pass 9 years ago
Matthew Butterick 6d80193419 lhs-id modifications ; tests pass 9 years ago
Matthew Butterick 2026c603de make ids hideable 9 years ago
Matthew Butterick f072c9f808 angle-hiding in parser 9 years ago
Matthew Butterick 8dea96894b add dependency 9 years ago
Matthew Butterick e86208b131 Merge branch 'master' of https://github.com/mbutterick/beautiful-racket into dev-elider 9 years ago
Matthew Butterick b55d290fe9 rename `br/ragg` as `brag` 9 years ago
Matthew Butterick a5e5a8ece6 provide br/debug for syntax in #lang br 9 years ago
Matthew Butterick 09ac200d0d provide br/debug for syntax in #lang br 9 years ago
Matthew Butterick 2d44750221 hiding works for literals and tokens ; tests pass ; resume in ids 9 years ago
Matthew Butterick 44d25659de tests still pass 9 years ago
Matthew Butterick 3504667b83 change elide to struct / syntax prop ; tests pass 9 years ago
Matthew Butterick 7bf8a29bd3 elide works like seq (better) ; tests pass 9 years ago
Matthew Butterick 9babe76e3c resume in syntaxification of rule 9 years ago
Matthew Butterick 12a04bbc6a elider brackets work like sequence parens ; tests pass 9 years ago
Matthew Butterick e4a3255f6c angle brackets behave ; tests pass 9 years ago
Matthew Butterick 831d5cca35 `elide` token added with no functional changes; all tests still pass 9 years ago

@ -0,0 +1,72 @@
name: CI
on: [push, pull_request]
jobs:
run:
name: "Build using Racket '${{ matrix.racket-version }}' (${{ matrix.racket-variant }})"
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.xfail == 'yes' }}
strategy:
fail-fast: false
matrix:
racket-version: ["6.7", "6.8", "6.9", "6.11", "6.12", "7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "7.7", "7.8", "7.9", "8.0", "8.1", "current"]
racket-variant: ["BC", "CS"]
# CS builds are only provided for versions 7.4 and up so avoid
# running the job for prior versions.
exclude:
- {racket-version: "6.6", racket-variant: "CS"}
- {racket-version: "6.7", racket-variant: "CS"}
- {racket-version: "6.8", racket-variant: "CS"}
- {racket-version: "6.9", racket-variant: "CS"}
- {racket-version: "6.10.1", racket-variant: "CS"}
- {racket-version: "6.11", racket-variant: "CS"}
- {racket-version: "6.12", racket-variant: "CS"}
- {racket-version: "7.0", racket-variant: "CS"}
- {racket-version: "7.1", racket-variant: "CS"}
- {racket-version: "7.2", racket-variant: "CS"}
- {racket-version: "7.3", racket-variant: "CS"}
include:
- {racket-version: "6.7", racket-variant: "BC", xfail: "yes"}
- {racket-version: "7.7", racket-variant: "CS", xfail: "yes"}
- {racket-version: "7.8", racket-variant: "CS", xfail: "yes"}
- {racket-version: "7.9", racket-variant: "CS", xfail: "yes"}
- {racket-version: "current", racket-variant: "BC", xfail: "yes"}
- {racket-version: "current", racket-variant: "CS", xfail: "yes"}
env:
DISPLAY: :99
steps:
- name: Checkout
uses: actions/checkout@master
- uses: Bogdanp/setup-racket@v0.11
with:
distribution: 'full'
version: ${{ matrix.racket-version }}
variant: ${{ matrix.racket-variant }}
- name: Install package and its dependencies
run: raco pkg install --deps search-auto https://github.com/mbutterick/br-parser-tools.git?path=br-parser-tools-lib
- name: install brag
run: raco pkg install --deps search-auto https://github.com/mbutterick/brag.git?path=brag
- name: install br-macro
run: raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-macro
- name: install br lib
run: raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-lib
- name: install br demo
run: raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-demo
- name: install br
run: raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket
- name: Start virtual framebuffer
run: Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
- name: Run the brm tests
run: raco test -p beautiful-racket-macro
- name: Run the lib tests
run: raco test -p beautiful-racket-lib
- name: Run the demo tests
run: raco test -p beautiful-racket-demo
- name: Run the br tests
run: raco test -p beautiful-racket

3
.gitignore vendored

@ -21,4 +21,5 @@ scribblings/*.css
!scribblings/mb.css !scribblings/mb.css
scribblings/*.html scribblings/*.html
scribblings/pollen/* scribblings/pollen/*
doc/* beautiful-racket-lib/br/doc/*
beautiful-racket-demo/jsonic-demo-3/doc/*

@ -1,42 +0,0 @@
# adapted from
# https://github.com/greghendershott/travis-racket/blob/master/.travis.yml
# Thanks Greg!
language: c
sudo: false
env:
global:
- RACKET_DIR=~/racket
matrix:
# - RACKET_VERSION=6.0
# - RACKET_VERSION=6.1
# - RACKET_VERSION=6.2
- RACKET_VERSION=6.3
- RACKET_VERSION=6.4
- RACKET_VERSION=HEAD
# You may want to test against certain versions of Racket, without
# having them count against the overall success/failure.
matrix:
allow_failures:
#- env: RACKET_VERSION=HEAD
# Fast finish: Overall build result is determined as soon as any of
# its rows have failed, or, all of its rows that aren't allowed to
# fail have succeeded.
fast_finish: true
before_install:
- git clone https://github.com/mbutterick/travis-racket.git
- cat travis-racket/install-racket.sh | bash # pipe to bash not sh!
- export PATH="${RACKET_DIR}/bin:${PATH}" #install-racket.sh can't set for us
script:
- cd .. # Travis did a cd into the dir. Back up, for the next:
# don't rely on package server
- travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-lib
- raco test -p beautiful-racket-lib
- travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket-ragg
- raco test -p beautiful-racket-ragg
- travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/beautiful-racket.git?path=beautiful-racket
- raco test -p beautiful-racket

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

@ -1,3 +0,0 @@
Beautiful Racket
© 2016 Matthew Butterick
Licensed under the LGPL (see "LGPL.txt")

@ -0,0 +1,9 @@
MIT License for `beautiful-racket`
© 2016-2019 Matthew Butterick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,7 +1,7 @@
beautiful-racket [![Build Status](https://travis-ci.org/mbutterick/beautiful-racket.svg?branch=master)](https://travis-ci.org/mbutterick/beautiful-racket) ## beautiful-racket [![Build Status](https://github.com/mbutterick/beautiful-racket/workflows/CI/badge.svg)](https://github.com/mbutterick/beautiful-racket/actions)
-
Resources for the upcoming “Beautiful Racket” book, including:
Resources for the “Beautiful Racket” book, including:
* `#lang br` teaching language * `#lang br` teaching language
@ -10,11 +10,25 @@ Resources for the upcoming “Beautiful Racket” book, including:
* sample languages * sample languages
Installation: ## Installation
`raco pkg install beautiful-racket` `raco pkg install beautiful-racket`
Update: ## Update
`raco pkg update --update-deps beautiful-racket`
## Documentation
http://docs.racket-lang.org/br
## License
MIT
## Project status
`raco pkg update beautiful-racket` Complete. I will maintain the code but no major updates are planned.

@ -0,0 +1,6 @@
#lang brag
top : (fun | app)*
fun : /"fun" ID /"(" ID [/"," ID] /")" /"=" expr
expr : ID /"+" ID | app
app : ID /"(" (ID | INT) [/"," ID] /")"

@ -0,0 +1,36 @@
#lang br/quicklang
(require brag/support "grammar.rkt")
(provide top fun expr app)
(module+ reader
(provide read-syntax))
(define-lex-abbrev reserved-toks
(:or "fun" "(" ")" "=" "+" ","))
(define tokenize-1
(lexer
[whitespace (token lexeme #:skip? #t)]
[(from/stop-before "#" "\n") (token 'COMMENT #:skip? #t)]
[reserved-toks lexeme]
[(:+ alphabetic) (token 'ID (string->symbol lexeme))]
[(:+ (char-set "0123456789")) (token 'INT (string->number lexeme))]))
(define-macro top #'#%module-begin)
(define-macro-cases fun
[(_ VAR ARG0 EXPR) #'(define (VAR ARG0) EXPR)]
[(_ VAR ARG0 ARG1 EXPR) #'(define (VAR ARG0 ARG1) EXPR)])
(define-macro-cases expr
[(_ LEFT RIGHT) #'(+ LEFT RIGHT)]
[(_ OTHER) #'OTHER])
(define-macro app #'#%app)
(define (read-syntax src ip)
(define parse-tree (parse src (λ () (tokenize-1 ip))))
(strip-bindings
(with-syntax ([PT parse-tree])
#'(module algebra-mod algebra-demo
PT))))

@ -0,0 +1,6 @@
#lang algebra-demo
fun f(x,y) = x + y
# fun f(x,y) = x * y
fun g(zz) = f(zz,zz)
g(10)
g(23)

@ -0,0 +1,16 @@
#lang br
(provide #%top-interaction #%module-begin
(rename-out [my-datum #%datum]
[my-datum #%top]
[my-app #%app]))
(define-syntax (my-datum stx)
(syntax-case stx ()
[(_ . THING) #''taco]))
(define-syntax (my-app stx)
(syntax-case stx ()
[(_ FUNC . ARGS) #'(list (my-datum) . ARGS)]))
(module reader syntax/module-reader
atomic-taco-demo)

@ -0,0 +1,4 @@
#lang atomic-taco-demo
"hello world"
(+ 1 (* 2 (- x)))

@ -0,0 +1,32 @@
#lang br
(require "lexer.rkt" brag/support)
(provide basic-colorer)
(define (basic-colorer port)
(define (handle-lexer-error excn)
(define excn-srclocs (exn:fail:read-srclocs excn))
(srcloc-token (token 'ERROR) (car excn-srclocs)))
(define srcloc-tok
(with-handlers ([exn:fail:read? handle-lexer-error])
(basic-lexer port)))
(match srcloc-tok
[(? eof-object?) (values srcloc-tok 'eof #f #f #f)]
[else
(match-define
(srcloc-token
(token-struct type val _ _ _ _ _)
(srcloc _ _ _ posn span)) srcloc-tok)
(define start posn)
(define end (+ start span))
(match-define (list cat paren)
(match type
['STRING '(string #f)]
['REM '(comment #f)]
['ERROR '(error #f)]
[else (match val
[(? number?) '(constant #f)]
[(? symbol?) '(symbol #f)]
["(" '(parenthesis |(|)]
[")" '(parenthesis |)|)]
[else '(no-color #f)])]))
(values val cat paren start end)]))

@ -0,0 +1,41 @@
#lang br
(require "go.rkt")
(provide b-if b-or-expr b-and-expr b-not-expr b-comp-expr)
(define (bool->int val) (if val 1 0))
(define nonzero? (compose1 not zero?))
(define-macro-cases b-or-expr
[(_ VAL) #'VAL]
[(_ LEFT "or" RIGHT)
#'(bool->int (or (nonzero? LEFT) (nonzero? RIGHT)))])
(define-macro-cases b-and-expr
[(_ VAL) #'VAL]
[(_ LEFT "and" RIGHT)
#'(bool->int (and (nonzero? LEFT) (nonzero? RIGHT)))])
(define-macro-cases b-not-expr
[(_ VAL) #'VAL]
[(_ "not" VAL) #'(if (nonzero? VAL) 0 1)])
(define b= (compose1 bool->int =))
(define b< (compose1 bool->int <))
(define b> (compose1 bool->int >))
(define b<> (compose1 bool->int not =))
(define-macro-cases b-comp-expr
[(_ VAL) #'VAL]
[(_ LEFT "=" RIGHT) #'(b= LEFT RIGHT)]
[(_ LEFT "<" RIGHT) #'(b< LEFT RIGHT)]
[(_ LEFT ">" RIGHT) #'(b> LEFT RIGHT)]
[(_ LEFT "<>" RIGHT) #'(b<> LEFT RIGHT)])
(define-macro-cases b-if
[(_ COND-EXPR THEN-EXPR) #'(b-if COND-EXPR THEN-EXPR (void))]
[(_ COND-EXPR THEN-EXPR ELSE-EXPR)
#'(let ([result (if (nonzero? COND-EXPR)
THEN-EXPR
ELSE-EXPR)])
(when (exact-positive-integer? result)
(b-goto result)))])

@ -0,0 +1,6 @@
#lang br
(require "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt" "cond.rkt")
(provide
(all-from-out "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt" "cond.rkt"))

@ -0,0 +1,26 @@
#lang br/quicklang
(require "struct.rkt" "run.rkt" "elements.rkt")
(provide (rename-out [b-module-begin #%module-begin])
(all-from-out "elements.rkt"))
(define-macro (b-module-begin (b-program LINE ...))
(with-pattern
([((b-line NUM STMT ...) ...) #'(LINE ...)]
[(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))]
[(VAR-ID ...) (find-unique-var-ids #'(LINE ...))])
#'(#%module-begin
(define VAR-ID 0) ...
LINE ...
(define line-table
(apply hasheqv (append (list NUM LINE-FUNC) ...)))
(void (run line-table)))))
(begin-for-syntax
(require racket/list)
(define (find-unique-var-ids line-stxs)
(remove-duplicates
(for/list ([stx (in-list (stx-flatten line-stxs))]
#:when (syntax-property stx 'b-id))
stx)
#:key syntax->datum)))

@ -0,0 +1,24 @@
#lang br
(provide b-expr b-sum b-product b-neg b-expt)
(define (b-expr expr)
(if (integer? expr) (inexact->exact expr) expr))
(define-macro-cases b-sum
[(_ VAL) #'VAL]
[(_ LEFT "+" RIGHT) #'(+ LEFT RIGHT)]
[(_ LEFT "-" RIGHT) #'(- LEFT RIGHT)])
(define-macro-cases b-product
[(_ VAL) #'VAL]
[(_ LEFT "*" RIGHT) #'(* LEFT RIGHT)]
[(_ LEFT "/" RIGHT) #'(/ LEFT RIGHT 1.0)]
[(_ LEFT "mod" RIGHT) #'(modulo LEFT RIGHT)])
(define-macro-cases b-neg
[(_ VAL) #'VAL]
[(_ "-" VAL) #'(- VAL)])
(define-macro-cases b-expt
[(_ VAL) #'VAL]
[(_ LEFT "^" RIGHT) #'(expt LEFT RIGHT)])

@ -0,0 +1,52 @@
#lang br
(require "struct.rkt" "line.rkt" "misc.rkt")
(provide b-end b-goto b-gosub b-return b-for b-next)
(define (b-end) (raise (end-program-signal)))
(define (b-goto num-expr)
(raise (change-line-signal num-expr)))
(define return-ccs empty)
(define (b-gosub num-expr)
(let/cc this-cc
(push! return-ccs this-cc)
(b-goto num-expr)))
(define (b-return)
(when (empty? return-ccs)
(raise-line-error "return without gosub"))
(define top-cc (pop! return-ccs))
(top-cc (void)))
(define next-funcs (make-hasheq))
(define-macro-cases b-for
[(_ LOOP-ID START END) #'(b-for LOOP-ID START END 1)]
[(_ LOOP-ID START END STEP)
#'(b-let LOOP-ID
(let/cc loop-cc
(hash-set! next-funcs
'LOOP-ID
(λ ()
(define next-val
(+ LOOP-ID STEP))
(if (next-val
. in-closed-interval? .
START END)
(loop-cc next-val)
(hash-remove! next-funcs
'LOOP-ID))))
START))])
(define (in-closed-interval? x start end)
((if (< start end) <= >=) start x end))
(define-macro (b-next LOOP-ID)
#'(begin
(unless (hash-has-key? next-funcs 'LOOP-ID)
(raise-line-error
(format "`next ~a` without for" 'LOOP-ID)))
(define func (hash-ref next-funcs 'LOOP-ID))
(func)))

@ -0,0 +1,4 @@
#lang info
(define compile-omit-paths '("private"))
(define test-omit-paths '("private" "sample-input.rkt"))

@ -0,0 +1,25 @@
#lang br
(require brag/support)
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" ";" "let" "=" "input" "-" "*" "/" "^" "mod" "(" ")" "if" "then" "else" "<" ">" "<>" "and" "or" "not" "gosub" "return" "for" "to" "step" "next"))
(define basic-lexer
(lexer-srcloc
["\n" (token 'NEWLINE lexeme)]
[whitespace (token lexeme #:skip? #t)]
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
[reserved-terms (token lexeme lexeme)]
[(:seq alphabetic (:* (:or alphabetic numeric "$")))
(token 'ID (string->symbol lexeme))]
[digits (token 'INTEGER (string->number lexeme))]
[(:or (:seq (:? digits) "." digits)
(:seq digits "."))
(token 'DECIMAL (string->number lexeme))]
[(:or (from/to "\"" "\"") (from/to "'" "'"))
(token 'STRING
(substring lexeme
1 (sub1 (string-length lexeme))))]))
(provide basic-lexer)

@ -0,0 +1,22 @@
#lang br
(require "struct.rkt")
(provide b-line raise-line-error)
(define-macro (b-line NUM STATEMENT ...)
(with-pattern ([LINE-NUM (prefix-id "line-" #'NUM
#:source #'NUM)])
(syntax/loc caller-stx
(define (LINE-NUM #:error [msg #f])
(with-handlers
([line-error?
(λ (le) (handle-line-error NUM le))])
(when msg (raise-line-error msg))
STATEMENT ...)))))
(define (raise-line-error error-msg)
(raise (line-error error-msg)))
(define (handle-line-error num le)
(error (format "error in line ~a: ~a"
num (line-error-msg le))))

@ -0,0 +1,19 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(module+ reader
(provide read-syntax get-info))
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-mod basic-demo-2/expander
#,parse-tree)))
(define (get-info port src-mod src-line src-col src-pos)
(define (handle-query key default)
(case key
[(color-lexer)
(dynamic-require 'basic-demo-2/colorer 'basic-colorer)]
[else default]))
handle-query)

@ -0,0 +1,15 @@
#lang br
(require "struct.rkt")
(provide b-rem b-print b-let b-input)
(define (b-rem val) (void))
(define (b-print . vals)
(displayln (string-append* (map ~a vals))))
(define-macro (b-let ID VAL) #'(set! ID VAL))
(define-macro (b-input ID)
#'(b-let ID (let* ([str (read-line)]
[num (string->number (string-trim str))])
(or num str))))

@ -0,0 +1,14 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-parser-mod basic-demo-2/parse-only
#,parse-tree)))
(module+ reader (provide read-syntax))
(define-macro (parser-only-mb PARSE-TREE)
#'(#%module-begin
'PARSE-TREE))
(provide (rename-out [parser-only-mb #%module-begin]))

@ -0,0 +1,15 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-parser-mod basic-demo-2/parse-stx
#'#,parse-tree)))
(module+ reader (provide read-syntax))
(define-macro (parser-only-mb PARSE-STX)
#'(#%module-begin
PARSE-STX))
(provide (rename-out [parser-only-mb #%module-begin]))
(provide syntax)

@ -0,0 +1,32 @@
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
b-rem : REM
@b-statement : b-end | b-print | b-goto
| b-let | b-input | b-if
| b-gosub | b-return | b-for | b-next
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-let : [/"let"] b-id /"=" (STRING | b-expr)
b-if : /"if" b-expr /"then" (b-statement | b-expr)
[/"else" (b-statement | b-expr)]
b-input : /"input" b-id
@b-id : ID
b-gosub : /"gosub" b-expr
b-return : /"return"
b-for : /"for" b-id /"=" b-expr /"to" b-expr [/"step" b-expr]
b-next : /"next" b-id
b-expr : b-or-expr
b-or-expr : [b-or-expr "or"] b-and-expr
b-and-expr : [b-and-expr "and"] b-not-expr
b-not-expr : ["not"] b-comp-expr
b-comp-expr : [b-comp-expr ("="|"<"|">"|"<>")] b-sum
b-sum : [b-sum ("+"|"-")] b-product
b-product : [b-product ("*"|"/"|"mod")] b-neg
b-neg : ["-"] b-expt
b-expt : [b-expt ("^")] b-value
@b-value : b-number | b-id | /"(" b-expr /")"
@b-number : INTEGER | DECIMAL

@ -0,0 +1,8 @@
(define (30) (rem print "'ignored'"))
(define (35) (void))
(define (50) (print "never gets here"))
(define (40) (end))
(define (60) (print "three") (print (+ 1.0 3)))
(define (70) (goto (+ 11 18.5 0.5)))
(define (10) (print "one"))
(define (20) (print) (goto 60) (end))

@ -0,0 +1,23 @@
#lang br
(require "line.rkt" "struct.rkt")
(provide run)
(define (run line-table)
(define line-vec
(list->vector (sort (hash-keys line-table) <)))
(with-handlers ([end-program-signal? (λ (exn-val) (void))])
(for/fold ([line-idx 0])
([i (in-naturals)]
#:break (>= line-idx (vector-length line-vec)))
(define line-num (vector-ref line-vec line-idx))
(define line-func (hash-ref line-table line-num))
(with-handlers
([change-line-signal?
(λ (cls)
(define clsv (change-line-signal-val cls))
(or
(and (exact-positive-integer? clsv)
(vector-member clsv line-vec))
(line-func #:error (format "line ~a not found" clsv))))])
(line-func)
(add1 line-idx)))))

@ -0,0 +1,8 @@
#lang basic-demo-2
10 rem all results should be 1
20 a = 5
30 b = 10
40 print a > 4
50 print b = 10
60 print b < 11
70 print rem (b = 100)

@ -0,0 +1,6 @@
#lang basic-demo-2
10 for a = 1 to 3
21 for b = 9 to 7 step -1
22 print a ; b
23 next b
30 next a

@ -0,0 +1,10 @@
#lang basic-demo-2
10 gosub 41
20 print "world"
30 gosub 100
31 print "hi"
35 end
40 return
41 print "hello" : return
100 print "third"
110 goto 40

@ -0,0 +1,4 @@
#lang basic-demo-2
5 print "enter your name: "
10 input A$
20 print "hello, " ; A$ ; "!"

@ -0,0 +1,9 @@
#lang basic-demo-2
10 rem all results should be 1
20 print 1 - 2 * 3 + 4 * 5 - 6 = 9
30 print (1 - 2) * (3 + 4) * (5 - 6) = 7
40 print 1 / 4 = .25
50 print 2 ^ 3 = 8
60 print 9 ^ 0.5 = 3
70 print 6 mod 2 = 0
80 print 5 mod 2 = 1

@ -0,0 +1,8 @@
#lang basic-demo-2
10 a = 1 : a = 5
20 gosub 150
30 a = 25
40 gosub 150
50 end
150 print a + a + a
160 return

@ -0,0 +1,9 @@
#lang basic-demo-2
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end

@ -0,0 +1,8 @@
#lang br
(provide (struct-out end-program-signal)
(struct-out change-line-signal)
(struct-out line-error))
(struct end-program-signal ())
(struct change-line-signal (val))
(struct line-error (msg))

@ -0,0 +1,34 @@
#lang at-exp br
(require br/test rackunit)
(check-equal? (run-source "sample.rkt") "one
three
4
")
(check-equal? (run-source "sample-var.rkt") "15
75
")
(check-equal? (run-source "sample-math.rkt") "1
1
1
1
1
1
1
")
(check-equal? (run-source "sample-gosub.rkt") "hello
world
third
hi
")
(check-equal? (run-source "sample-for.rkt") "19
18
17
29
28
27
39
38
37
")

@ -0,0 +1,10 @@
#lang br
(require "lexer.rkt" brag/support)
(define (make-tokenizer ip [path #f])
(port-count-lines! ip)
(lexer-file-path path)
(define (next-token) (basic-lexer ip))
next-token)
(provide make-tokenizer)

@ -0,0 +1,6 @@
#lang br
(require "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt")
(provide
(all-from-out "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt"))

@ -0,0 +1,16 @@
#lang br/quicklang
(require "struct.rkt" "run.rkt" "elements.rkt")
(provide (rename-out [b-module-begin #%module-begin])
(all-from-out "elements.rkt"))
(define-macro (b-module-begin (b-program LINE ...))
(with-pattern
([((b-line NUM STMT ...) ...) #'(LINE ...)]
[(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))])
#'(#%module-begin
LINE ...
(define line-table
(apply hasheqv (append (list NUM LINE-FUNC) ...)))
(void (run line-table)))))

@ -0,0 +1,7 @@
#lang br
(provide b-sum b-expr)
(define (b-sum . vals) (apply + vals))
(define (b-expr expr)
(if (integer? expr) (inexact->exact expr) expr))

@ -0,0 +1,8 @@
#lang br
(require "struct.rkt" "line.rkt")
(provide b-end b-goto)
(define (b-end) (raise (end-program-signal)))
(define (b-goto num-expr)
(raise (change-line-signal num-expr)))

@ -0,0 +1,22 @@
#lang br
(require brag/support)
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define basic-lexer
(lexer-srcloc
["\n" (token 'NEWLINE lexeme)]
[whitespace (token lexeme #:skip? #t)]
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
[(:or "print" "goto" "end"
"+" ":" ";") (token lexeme lexeme)]
[digits (token 'INTEGER (string->number lexeme))]
[(:or (:seq (:? digits) "." digits)
(:seq digits "."))
(token 'DECIMAL (string->number lexeme))]
[(:or (from/to "\"" "\"") (from/to "'" "'"))
(token 'STRING
(substring lexeme
1 (sub1 (string-length lexeme))))]))
(provide basic-lexer)

@ -0,0 +1,9 @@
#lang br
(require "struct.rkt")
(provide b-line)
(define-macro (b-line NUM STATEMENT ...)
(with-pattern ([LINE-NUM (prefix-id "line-" #'NUM
#:source #'NUM)])
(syntax/loc caller-stx
(define (LINE-NUM) (void) STATEMENT ...))))

@ -0,0 +1,11 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(module+ reader
(provide read-syntax))
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-mod basic-demo-2a/expander
#,parse-tree)))

@ -0,0 +1,8 @@
#lang br
(require "struct.rkt")
(provide b-rem b-print)
(define (b-rem val) (void))
(define (b-print . vals)
(displayln (string-append* (map ~a vals))))

@ -0,0 +1,13 @@
#lang brag
b-program : [b-line] (/NEWLINE [b-line])*
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
@b-statement : b-end | b-print | b-goto
b-rem : REM
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-expr : b-sum
b-sum : b-number (/"+" b-number)*
@b-number : INTEGER | DECIMAL

@ -0,0 +1,24 @@
#lang br
(require "line.rkt" "struct.rkt")
(provide run)
(define (run line-table)
(define line-vec
(list->vector (sort (hash-keys line-table) <)))
(with-handlers ([end-program-signal? (λ (exn-val) (void))])
(for/fold ([line-idx 0])
([i (in-naturals)]
#:break (>= line-idx (vector-length line-vec)))
(define line-num (vector-ref line-vec line-idx))
(define line-func (hash-ref line-table line-num))
(with-handlers
([change-line-signal?
(λ (cls)
(define clsv (change-line-signal-val cls))
(or
(and (exact-positive-integer? clsv)
(vector-member clsv line-vec))
(error (format "error in line ~a: line ~a not found"
line-num clsv))))])
(line-func)
(add1 line-idx)))))

@ -0,0 +1,9 @@
#lang basic-demo
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end

@ -0,0 +1,6 @@
#lang br
(provide (struct-out end-program-signal)
(struct-out change-line-signal))
(struct end-program-signal ())
(struct change-line-signal (val))

@ -0,0 +1,8 @@
#lang at-exp br
(require br/test rackunit)
(check-equal? (run-source "sample.rkt") "one
three
4
")

@ -0,0 +1,10 @@
#lang br
(require "lexer.rkt" brag/support)
(define (make-tokenizer ip [path #f])
(port-count-lines! ip)
(lexer-file-path path)
(define (next-token) (basic-lexer ip))
next-token)
(provide make-tokenizer)

@ -0,0 +1,2 @@
#lang br
(current-command-line-arguments)

@ -0,0 +1,32 @@
#lang br
(require "lexer.rkt" brag/support)
(provide basic-colorer)
(define (basic-colorer port)
(define (handle-lexer-error excn)
(define excn-srclocs (exn:fail:read-srclocs excn))
(srcloc-token (token 'ERROR) (car excn-srclocs)))
(define srcloc-tok
(with-handlers ([exn:fail:read? handle-lexer-error])
(basic-lexer port)))
(match srcloc-tok
[(? eof-object?) (values srcloc-tok 'eof #f #f #f)]
[else
(match-define
(srcloc-token
(token-struct type val _ _ _ _ _)
(srcloc _ _ _ posn span)) srcloc-tok)
(define start posn)
(define end (+ start span))
(match-define (list cat paren)
(match type
['STRING '(string #f)]
['REM '(comment #f)]
['ERROR '(error #f)]
[else (match val
[(? number?)'(constant #f)]
[(? symbol?) '(symbol #f)]
["(" '(parenthesis |(|)]
[")" '(parenthesis |)|)]
[else '(no-color #f)])]))
(values val cat paren start end)]))

@ -0,0 +1,41 @@
#lang br
(require "go.rkt")
(provide b-if b-or-expr b-and-expr b-not-expr b-comp-expr)
(define (bool->int val) (if val 1 0))
(define nonzero? (compose1 not zero?))
(define-macro-cases b-or-expr
[(_ VAL) #'VAL]
[(_ LEFT "or" RIGHT)
#'(bool->int (or (nonzero? LEFT) (nonzero? RIGHT)))])
(define-macro-cases b-and-expr
[(_ VAL) #'VAL]
[(_ LEFT "and" RIGHT)
#'(bool->int (and (nonzero? LEFT) (nonzero? RIGHT)))])
(define-macro-cases b-not-expr
[(_ VAL) #'VAL]
[(_ "not" VAL) #'(if (nonzero? VAL) 0 1)])
(define b= (compose1 bool->int =))
(define b< (compose1 bool->int <))
(define b> (compose1 bool->int >))
(define b<> (compose1 bool->int not =))
(define-macro-cases b-comp-expr
[(_ VAL) #'VAL]
[(_ LEFT "=" RIGHT) #'(b= LEFT RIGHT)]
[(_ LEFT "<" RIGHT) #'(b< LEFT RIGHT)]
[(_ LEFT ">" RIGHT) #'(b> LEFT RIGHT)]
[(_ LEFT "<>" RIGHT) #'(b<> LEFT RIGHT)])
(define-macro-cases b-if
[(_ COND-EXPR THEN-EXPR) #'(b-if COND-EXPR THEN-EXPR (void))]
[(_ COND-EXPR THEN-EXPR ELSE-EXPR)
#'(let ([result (if (nonzero? COND-EXPR)
THEN-EXPR
ELSE-EXPR)])
(when (exact-positive-integer? result)
(b-goto result)))])

@ -0,0 +1,6 @@
#lang br
(require "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt" "cond.rkt")
(provide
(all-from-out "line.rkt" "go.rkt"
"expr.rkt" "misc.rkt" "cond.rkt"))

@ -0,0 +1,58 @@
#lang br/quicklang
(require "struct.rkt" "run.rkt" "elements.rkt" "setup.rkt")
(provide (rename-out [b-module-begin #%module-begin])
(all-from-out "elements.rkt"))
(define-macro (b-module-begin (b-program LINE ...))
(with-pattern
([((b-line NUM STMT ...) ...) #'(LINE ...)]
[(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))]
[(VAR-ID ...) (find-property 'b-id #'(LINE ...))]
[(IMPORT-NAME ...)
(find-property 'b-import-name #'(LINE ...))]
[(EXPORT-NAME ...)
(find-property 'b-export-name #'(LINE ...))]
[((SHELL-ID SHELL-IDX) ...)
(make-shell-ids-and-idxs caller-stx)]
[(UNIQUE-ID ...)
(unique-ids
(syntax->list #'(VAR-ID ... SHELL-ID ...)))])
#'(#%module-begin
(module configure-runtime br
(require basic-demo-3/setup)
(do-setup!))
(require IMPORT-NAME) ...
(provide EXPORT-NAME ...)
(define UNIQUE-ID 0) ...
(let ([clargs (current-command-line-arguments)])
(set! SHELL-ID (get-clarg clargs SHELL-IDX)) ...)
LINE ...
(define line-table
(apply hasheqv (append (list NUM LINE-FUNC) ...)))
(parameterize
([current-output-port (basic-output-port)])
(void (run line-table))))))
(define (get-clarg clargs idx)
(if (<= (vector-length clargs) idx)
0
(let ([val (vector-ref clargs idx)])
(or (string->number val) val))))
(begin-for-syntax
(require racket/list)
(define (unique-ids stxs)
(remove-duplicates stxs #:key syntax->datum))
(define (find-property which line-stxs)
(unique-ids
(for/list ([stx (in-list (stx-flatten line-stxs))]
#:when (syntax-property stx which))
stx)))
(define (make-shell-ids-and-idxs ctxt)
(define arg-count 10)
(for/list ([idx (in-range arg-count)])
(list (suffix-id #'arg idx #:context ctxt) idx))))

@ -0,0 +1,45 @@
#lang br
(require "line.rkt")
(provide b-expr b-sum b-product b-neg b-expt b-def b-func)
(define (b-expr expr)
(if (integer? expr) (inexact->exact expr) expr))
(define-macro-cases b-sum
[(_ VAL) #'VAL]
[(_ LEFT "+" RIGHT) #'(+ LEFT RIGHT)]
[(_ LEFT "-" RIGHT) #'(- LEFT RIGHT)])
(define-macro-cases b-product
[(_ VAL) #'VAL]
[(_ LEFT "*" RIGHT) #'(* LEFT RIGHT)]
[(_ LEFT "/" RIGHT) #'(/ LEFT RIGHT 1.0)]
[(_ LEFT "mod" RIGHT) #'(modulo LEFT RIGHT)])
(define-macro-cases b-neg
[(_ VAL) #'VAL]
[(_ "-" VAL) #'(- VAL)])
(define-macro-cases b-expt
[(_ VAL) #'VAL]
[(_ LEFT "^" RIGHT) #'(expt LEFT RIGHT)])
(define-macro (b-def FUNC-ID VAR-ID ... EXPR)
(syntax-local-lift-expression
#'(set! FUNC-ID (λ (VAR-ID ...) EXPR))))
(define-macro (b-func FUNC-ID ARG ...)
#'(if (procedure? FUNC-ID)
(convert-result (FUNC-ID ARG ...))
(raise-line-error
(format "expected ~a to be a function, got ~v"
'FUNC-ID FUNC-ID))))
(define (convert-result result)
(cond
[(number? result) (b-expr result)]
[(string? result) result]
[(boolean? result) (if result 1 0)]
[else
(raise-line-error
(format "unknown data type: ~v" result))]))

@ -0,0 +1,52 @@
#lang br
(require "struct.rkt" "line.rkt" "misc.rkt")
(provide b-end b-goto b-gosub b-return b-for b-next)
(define (b-end) (raise (end-program-signal)))
(define (b-goto num-expr)
(raise (change-line-signal num-expr)))
(define return-ccs empty)
(define (b-gosub num-expr)
(let/cc this-cc
(push! return-ccs this-cc)
(b-goto num-expr)))
(define (b-return)
(when (empty? return-ccs)
(raise-line-error "return without gosub"))
(define top-cc (pop! return-ccs))
(top-cc (void)))
(define next-funcs (make-hasheq))
(define-macro-cases b-for
[(_ LOOP-ID START END) #'(b-for LOOP-ID START END 1)]
[(_ LOOP-ID START END STEP)
#'(b-let LOOP-ID
(let/cc loop-cc
(hash-set! next-funcs
'LOOP-ID
(λ ()
(define next-val
(+ LOOP-ID STEP))
(if (next-val
. in-closed-interval? .
START END)
(loop-cc next-val)
(hash-remove! next-funcs
'LOOP-ID))))
START))])
(define (in-closed-interval? x start end)
((if (< start end) <= >=) start x end))
(define-macro (b-next LOOP-ID)
#'(begin
(unless (hash-has-key? next-funcs 'LOOP-ID)
(raise-line-error
(format "`next ~a` without for" 'LOOP-ID)))
(define func (hash-ref next-funcs 'LOOP-ID))
(func)))

@ -0,0 +1,4 @@
#lang info
(define compile-omit-paths '("private"))
(define test-omit-paths '("private" "sample-input.rkt"))

@ -0,0 +1,31 @@
#lang br
(require brag/support)
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" ";" "let" "=" "input" "-" "*" "/" "^" "mod" "(" ")" "if" "then" "else" "<" ">" "<>" "and" "or" "not" "gosub" "return" "for" "to" "step" "next" "def" "," "import" "export"))
(define-lex-abbrev racket-id-kapu
(:or whitespace (char-set "()[]{}\",'`;#|\\")))
(define basic-lexer
(lexer-srcloc
["\n" (token 'NEWLINE lexeme)]
[whitespace (token lexeme #:skip? #t)]
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
[(:seq "[" (:+ (:~ racket-id-kapu)) "]")
(token 'RACKET-ID
(string->symbol (trim-ends "[" lexeme "]")))]
[reserved-terms (token lexeme lexeme)]
[(:seq alphabetic (:* (:or alphabetic numeric "$")))
(token 'ID (string->symbol lexeme))]
[digits (token 'INTEGER (string->number lexeme))]
[(:or (:seq (:? digits) "." digits)
(:seq digits "."))
(token 'DECIMAL (string->number lexeme))]
[(:or (from/to "\"" "\"") (from/to "'" "'"))
(token 'STRING
(substring lexeme
1 (sub1 (string-length lexeme))))]))
(provide basic-lexer)

@ -0,0 +1,22 @@
#lang br
(require "struct.rkt")
(provide b-line raise-line-error)
(define-macro (b-line NUM STATEMENT ...)
(with-pattern ([LINE-NUM (prefix-id "line-" #'NUM
#:source #'NUM)])
(syntax/loc caller-stx
(define (LINE-NUM #:error [msg #f])
(with-handlers
([line-error?
(λ (le) (handle-line-error NUM le))])
(when msg (raise-line-error msg))
STATEMENT ...)))))
(define (raise-line-error error-msg)
(raise (line-error error-msg)))
(define (handle-line-error num le)
(error (format "error in line ~a: ~a"
num (line-error-msg le))))

@ -0,0 +1,19 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(module+ reader
(provide read-syntax get-info))
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-mod basic-demo-3/expander
#,parse-tree)))
(define (get-info port src-mod src-line src-col src-pos)
(define (handle-query key default)
(case key
[(color-lexer)
(dynamic-require 'basic-demo-3/colorer 'basic-colorer)]
[else default]))
handle-query)

@ -0,0 +1,34 @@
#lang br
(require "struct.rkt" "expr.rkt")
(provide b-rem b-print b-let b-input b-import b-export b-repl)
(define (b-rem val) (void))
(define (b-print . vals)
(displayln (string-append* (map ~a vals))))
(define-macro (b-let ID VAL) #'(set! ID VAL))
(define-macro (b-input ID)
#'(b-let ID (let* ([str (read-line)]
[num (string->number (string-trim str))])
(or num str))))
(define-macro (b-import NAME) #'(void))
(define-macro (b-export NAME) #'(void))
(define-macro (b-repl . ALL-INPUTS)
(with-pattern
([INPUTS (pattern-case-filter #'ALL-INPUTS
[(b-print . PRINT-ARGS)
#'(b-print . PRINT-ARGS)]
[(b-expr . EXPR-ARGS)
#'(b-print (b-expr . EXPR-ARGS))]
[(b-let ID VAL)
#'(define ID VAL)]
[(b-def FUNC-ID VAR-ID ... EXPR)
#'(define (FUNC-ID VAR-ID ...) EXPR)]
[ANYTHING-ELSE
#'(error 'invalid-repl-input)])])
#'(begin . INPUTS)))

@ -0,0 +1,14 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-parser-mod basic-demo-3/parse-only
#,parse-tree)))
(module+ reader (provide read-syntax))
(define-macro (parser-only-mb PARSE-TREE)
#'(#%module-begin
'PARSE-TREE))
(provide (rename-out [parser-only-mb #%module-begin]))

@ -0,0 +1,15 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port path)))
(strip-bindings
#`(module basic-parser-mod basic-demo-3/parse-stx
#'#,parse-tree)))
(module+ reader (provide read-syntax))
(define-macro (parser-only-mb PARSE-STX)
#'(#%module-begin
PARSE-STX))
(provide (rename-out [parser-only-mb #%module-begin]))
(provide syntax)

@ -0,0 +1,40 @@
#lang brag
b-program : [b-line] (/NEWLINE [b-line])* | b-statement /NEWLINE
b-line : b-line-num [b-statement] (/":" [b-statement])* [b-rem]
@b-line-num : INTEGER
b-rem : REM
@b-statement : b-end | b-print | b-goto
| b-let | b-input | b-if
| b-gosub | b-return | b-for | b-next
| b-def | b-import | b-export
b-end : /"end"
b-print : /"print" [b-printable] (/";" [b-printable])*
@b-printable : STRING | b-expr
b-goto : /"goto" b-expr
b-let : [/"let"] b-id /"=" (STRING | b-expr)
b-if : /"if" b-expr /"then" (b-statement | b-expr)
[/"else" (b-statement | b-expr)]
b-input : /"input" b-id
@b-id : ID
b-gosub : /"gosub" b-expr
b-return : /"return"
b-for : /"for" b-id /"=" b-expr /"to" b-expr [/"step" b-expr]
b-next : /"next" b-id
b-def : /"def" b-id /"(" ID [/"," ID]* /")" /"=" b-expr
b-import : /"import" b-import-name
@b-import-name : RACKET-ID | STRING
b-export : /"export" b-export-name
@b-export-name : ID
b-expr : b-or-expr
b-or-expr : [b-or-expr "or"] b-and-expr
b-and-expr : [b-and-expr "and"] b-not-expr
b-not-expr : ["not"] b-comp-expr
b-comp-expr : [b-comp-expr ("="|"<"|">"|"<>")] b-sum
b-sum : [b-sum ("+"|"-")] b-product
b-product : [b-product ("*"|"/"|"mod")] b-neg
b-neg : ["-"] b-expt
b-expt : [b-expt ("^")] b-value
@b-value : b-number | b-id | /"(" b-expr /")" | b-func
b-func : (ID | RACKET-ID) /"(" b-expr [/"," b-expr]* /")"
@b-number : INTEGER | DECIMAL
b-repl : (b-statement | b-expr) (/":" [@b-repl])*

@ -0,0 +1,8 @@
(define (30) (rem print "'ignored'"))
(define (35) (void))
(define (50) (print "never gets here"))
(define (40) (end))
(define (60) (print "three") (print (+ 1.0 3)))
(define (70) (goto (+ 11 18.5 0.5)))
(define (10) (print "one"))
(define (20) (print) (goto 60) (end))

@ -0,0 +1,5 @@
#lang basic-demo-3
10 print "arg0 is " ; arg0
20 print "arg1 + arg1 is " ; arg1 + arg1
40 print "arg3 is " ; arg3
50 print "arg4 is " ; arg4

@ -0,0 +1,23 @@
#lang br
(require "line.rkt" "struct.rkt")
(provide run)
(define (run line-table)
(define line-vec
(list->vector (sort (hash-keys line-table) <)))
(with-handlers ([end-program-signal? (λ (exn-val) (void))])
(for/fold ([line-idx 0])
([i (in-naturals)]
#:break (>= line-idx (vector-length line-vec)))
(define line-num (vector-ref line-vec line-idx))
(define line-func (hash-ref line-table line-num))
(with-handlers
([change-line-signal?
(λ (cls)
(define clsv (change-line-signal-val cls))
(or
(and (exact-positive-integer? clsv)
(vector-member clsv line-vec))
(line-func #:error (format "line ~a not found" clsv))))])
(line-func)
(add1 line-idx)))))

@ -0,0 +1,8 @@
#lang basic-demo-3
10 rem all results should be 1
20 a = 5
30 b = 10
40 print a > 4
50 print b = 10
60 print b < 11
70 print rem (b = 100)

@ -0,0 +1,7 @@
#lang basic-demo-3
10 x = 2 : y = 3 : z = 5
20 print f(3, 4)
30 print f(f(3, g(2)), 2)
40 def f(x, y) = x * y * z
50 def g(i) = i + i
60 print y

@ -0,0 +1,9 @@
#lang basic-demo-3
10 def div(num, denom) = num / denom
20 x = 5 : y = 10
30 print x - 4
40 x = 15 : y = 30
50 print div(y, x)
60 x = 20
70 print div((x + x + x), x)
80 export div : export x

@ -0,0 +1,6 @@
#lang basic-demo-3
10 for a = 1 to 3
21 for b = 9 to 7 step -1
22 print a : print b
23 next b
30 next a

@ -0,0 +1,10 @@
#lang basic-demo-3
10 gosub 41
20 print "second"
30 gosub 100
31 print "fourth"
35 end
40 return
41 print "first" : return
100 print "third"
110 goto 40

@ -0,0 +1,7 @@
#lang basic-demo-3
10 import [math/number-theory]
20 print [nth-prime](15)
30 print [prime?](24)
40 import [racket/base]
50 print [max](f(1), f(2), f(5), f(4))
60 def f(x) = x + x

@ -0,0 +1,5 @@
#lang br
(require basic-demo-3/sample-exporter)
div
x
(div x 10)

@ -0,0 +1,4 @@
#lang basic-demo-3
5 print "enter your name: "
10 input A$
20 print "hello, " ; A$ ; "!"

@ -0,0 +1,9 @@
#lang basic-demo-3
10 rem all results should be 1
20 print 1 - 2 * 3 + 4 * 5 - 6 = 9
30 print (1 - 2) * (3 + 4) * (5 - 6) = 7
40 print 1 / 4 = .25
50 print 2 ^ 3 = 8
60 print 9 ^ 0.5 = 3
70 print 6 mod 2 = 0
80 print 5 mod 2 = 1

@ -0,0 +1,6 @@
#lang br
(require "sample-exporter.rkt")
(provide (all-from-out "sample-exporter.rkt"))
div
x
(div x 10)

@ -0,0 +1,2 @@
#lang basic-demo-3
10 print "got shell args: " ; arg0 ; arg1 ; arg2

@ -0,0 +1,9 @@
#lang basic-demo-3
30 rem print 'ignored'
35
50 print "never gets here"
40 end
60 print 'three' : print 1.0 + 3
70 goto 11. + 18.5 + .5 rem ignored
10 print "o" ; "n" ; "e"
20 print : goto 60.0 : end

@ -0,0 +1,19 @@
#lang br
(require "parser.rkt" "tokenizer.rkt")
(provide basic-output-port do-setup!)
(define basic-output-port
(make-parameter (open-output-nowhere)))
(define repl-parse (make-rule-parser b-repl))
(define (read-one-line origin port)
(define one-line (read-line port))
(if (eof-object? one-line)
eof
(repl-parse
(make-tokenizer (open-input-string one-line)))))
(define (do-setup!)
(basic-output-port (current-output-port))
(current-read-interaction read-one-line))

@ -0,0 +1,8 @@
#lang br
(provide (struct-out end-program-signal)
(struct-out change-line-signal)
(struct-out line-error))
(struct end-program-signal ())
(struct change-line-signal (val))
(struct line-error (msg))

@ -0,0 +1,7 @@
#lang br
(provide (all-defined-out))
(struct end-program-signal ())
(struct change-line-signal (val))
(struct line-error (msg))

@ -0,0 +1,72 @@
#lang at-exp br
(require br/test rackunit)
(check-equal? (run-source "sample.rkt") "one
three
4
")
(check-equal? (run-source "sample-cond.rkt") "1
1
1
")
(check-equal? (run-source "sample-def.rkt") "60
600
3
")
(check-equal? (run-source "sample-exporter.rkt") "1
2
3
")
(check-equal? (run-source "sample-for.rkt") "1
9
1
8
1
7
2
9
2
8
2
7
3
9
3
8
3
7
")
(check-equal? (run-source "sample-gosub.rkt") "first
second
third
fourth
")
(check-equal? (run-source "sample-import.rkt") "53
0
10
")
(check-equal? (run-source "sample-importer.rkt") "#<procedure:div>
20
2
")
(check-equal? (run-source "sample-math.rkt") "1
1
1
1
1
1
1
")
(check-equal? (run-source "sample-shell.rkt") "got shell args: 000\n")

@ -0,0 +1,14 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt" brag/support)
(define (read-syntax path port)
(define tokens (apply-tokenizer-maker make-tokenizer port))
(strip-bindings
#`(module basic-parser-mod basic-demo-3/parse-only
'#,tokens)))
(module+ reader (provide read-syntax))
(define-macro (mb PARSE-TREE)
#'(#%module-begin
'PARSE-TREE))
(provide (rename-out [mb #%module-begin]))

@ -0,0 +1,10 @@
#lang br
(require "lexer.rkt" brag/support)
(define (make-tokenizer ip [path #f])
(port-count-lines! ip)
(lexer-file-path path)
(define (next-token) (basic-lexer ip))
next-token)
(provide make-tokenizer)

@ -0,0 +1,19 @@
#lang basic-demo-nth
1 PRINT TAB(32);"3D PLOT"
2 PRINT TAB(20);"RACKET COMPUTING · HOLLYWOOD"
3 PRINT:PRINT:PRINT
5 DEF FNA(Z)=30*EXP(-Z*Z/100)
100 PRINT
110 FOR X=-30 TO 30 STEP 1.5
120 L=0
130 Y1=5*INT(SQR(900-X*X)/5)
140 FOR Y=Y1 TO -Y1 STEP -5
150 Z=INT(25+FNA(SQR(X*X+Y*Y))-.7*Y)
160 IF Z<=L THEN 190
170 L=Z
180 PRINT TAB(Z);"*";
190 NEXT Y
200 PRINT
210 NEXT X
300 END

@ -1,4 +1,4 @@
#lang br/demo/basic #lang basic-demo-nth
10 PRINT TAB(26);"ACEY DUCEY CARD GAME" 10 PRINT TAB(26);"ACEY DUCEY CARD GAME"
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
21 PRINT 21 PRINT

@ -0,0 +1,140 @@
#lang basic-demo-nth
10 PRINT TAB(28);"AMAZING PROGRAM"
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT:PRINT
100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH";HMAX,VMAX
102 IF HMAX<>1 AND VMAX<>1 THEN 110
104 PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN.":GOTO 100
110 DIM W(HMAX,VMAX),V(HMAX,VMAX)
120 PRINT
130 PRINT
140 PRINT
150 PRINT
160 Q=0:Z=0:X=INT(RND(1)*HMAX+1)
165 FOR I=1 TO HMAX
170 IF I=X THEN 173
171 PRINT "+--";:GOTO 180
173 PRINT "+ ";
180 NEXT I
190 PRINT "+"
195 C=1:W(X,1)=C:C=C+1
200 R=X:S=1:GOTO 260
210 IF R<>HMAX THEN 240
215 IF S<>VMAX THEN 230
220 R=1:S=1:GOTO 250
230 R=1:S=S+1:GOTO 250
240 R=R+1
250 IF W(R,S)=0 THEN 210
260 IF R-1=0 THEN 530
265 IF W(R-1,S)<>0 THEN 530
270 IF S-1=0 THEN 390
280 IF W(R,S-1)<>0 THEN 390
290 IF R=HMAX THEN 330
300 IF W(R+1,S)<>0 THEN 330
310 X=INT(RND(1)*3+1)
320 ON X GOTO 790,820,860
330 IF S<>HMAX THEN 340
334 IF Z=1 THEN 370
338 Q=1:GOTO 350
340 IF W(R,S+1)<>0 THEN 370
350 X=INT(RND(1)*3+1)
360 ON X GOTO 790,820,910
370 X=INT(RND(1)*2+1)
380 ON X GOTO 790,820
390 IF R=HMAX THEN 470
400 IF W(R+1,S)<>0 THEN 470
405 IF S<>VMAX THEN 420
410 IF Z=1 THEN 450
415 Q=1:GOTO 430
420 IF W(R,S+1)<>0 THEN 450
430 X=INT(RND(1)*3+1)
440 ON X GOTO 790,860,910
450 X=INT(RND(1)*2+1)
460 ON X GOTO 790,860
470 IF S<>VMAX THEN 490
480 IF Z=1 THEN 520
485 Q=1:GOTO 500
490 IF W(R,S+1)<>0 THEN 520
500 X=INT(RND(1)*2+1)
510 ON X GOTO 790,910
520 GOTO 790
530 IF S-1=0 THEN 670
540 IF W(R,S-1)<>0 THEN 670
545 IF R=HMAX THEN 610
547 IF W(R+1,S)<>0 THEN 610
550 IF S<>VMAX THEN 560
552 IF Z=1 THEN 590
554 Q=1:GOTO 570
560 IF W(R,S+1)<>0 THEN 590
570 X=INT(RND(1)*3+1)
580 ON X GOTO 820,860,910
590 X=INT(RND(1)*2+1)
600 ON X GOTO 820,860
610 IF S<>VMAX THEN 630
620 IF Z=1 THEN 660
625 Q=1:GOTO 640
630 IF W(R,S+1)<>0 THEN 660
640 X=INT(RND(1)*2+1)
650 ON X GOTO 820,910
660 GOTO 820
670 IF R=HMAX THEN 740
680 IF W(R+1,S)<>0 THEN 740
685 IF S<>VMAX THEN 700
690 IF Z=1 THEN 730
695 Q=1:GOTO 830
700 IF W(R,S+1)<>0 THEN 730
710 X=INT(RND(1)*2+1)
720 ON X GOTO 860,910
730 GOTO 860
740 IF S<>VMAX THEN 760
750 IF Z=1 THEN 780
755 Q=1:GOTO 770
760 IF W(R,S+1)<>0 THEN 780
770 GOTO 910
780 GOTO 1000
790 W(R-1,S)=C
800 C=C+1:V(R-1,S)=2:R=R-1
810 IF C=HMAX*VMAX+1 THEN 1010
815 Q=0:GOTO 260
820 W(R,S-1)=C
830 C=C+1
840 V(R,S-1)=1:S=S-1:IF C=HMAX*VMAX+1 THEN 1010
850 Q=0:GOTO 260
860 W(R+1,S)=C
870 C=C+1:IF V(R,S)=0 THEN 880
875 V(R,S)=3:GOTO 890
880 V(R,S)=2
890 R=R+1
900 IF C=HMAX*VMAX+1 THEN 1010
905 GOTO 530
910 IF Q=1 THEN 960
920 W(R,S+1)=C:C=C+1:IF V(R,S)=0 THEN 940
930 V(R,S)=3:GOTO 950
940 V(R,S)=1
950 S=S+1:IF C=HMAX*VMAX+1 THEN 1010
955 GOTO 260
960 Z=1
970 IF V(R,S)=0 THEN 980
975 V(R,S)=3:Q=0:GOTO 1000
980 V(R,S)=1:Q=0:R=1:S=1:GOTO 250
1000 GOTO 210
1010 FOR J=1 TO VMAX
1011 PRINT "|";
1012 FOR I=1 TO HMAX
1013 IF V(I,J)<2 THEN 1030
1020 PRINT " ";
1021 GOTO 1040
1030 PRINT " |";
1040 NEXT I
1041 PRINT
1043 FOR I=1 TO HMAX
1045 IF V(I,J)=0 THEN 1060
1050 IF V(I,J)=2 THEN 1060
1051 PRINT "+ ";
1052 GOTO 1070
1060 PRINT "+--";
1070 NEXT I
1071 PRINT "+"
1072 NEXT J
1073 END

@ -0,0 +1,4 @@
#lang basic-demo-nth
10 rem 20
20 x = 42
25 print x

@ -0,0 +1,55 @@
#lang basic-demo-nth
10 PRINT TAB(33);"BOUNCE"
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT
90 DIM T(20)
100 PRINT "THIS SIMULATION LETS YOU SPECIFY THE INITIAL VELOCITY"
110 PRINT "OF A BALL THROWN STRAIGHT UP, AND THE COEFFICIENT OF"
120 PRINT "ELASTICITY OF THE BALL. PLEASE USE A DECIMAL FRACTION"
130 PRINT "COEFFICIENCY (LESS THAN 1)."
131 PRINT
132 PRINT "YOU ALSO SPECIFY THE TIME INCREMENT TO BE USED IN"
133 PRINT "'STROBING' THE BALL'S FLIGHT (TRY .1 INITIALLY)."
134 PRINT
135 INPUT "TIME INCREMENT (SEC)";S2
140 PRINT
150 INPUT "VELOCITY (FPS)";V
160 PRINT
170 INPUT "COEFFICIENT";C
180 PRINT
182 PRINT "FEET"
184 PRINT
186 S1=INT(70/(V/(16*S2)))
190 FOR I=1 TO S1
200 T(I)=V*C^(I-1)/16
210 NEXT I
220 FOR H=INT(-16*(V/32)^2+V^2/32+.5) TO 0 STEP -.5
221 IF INT(H)<>H THEN 225
222 PRINT H;
225 L=0
230 FOR I=1 TO S1
240 FOR TI=0 TO T(I) STEP S2
245 L=L+S2
250 IF ABS(H-(.5*(-32)*TI^2+V*C^(I-1)*TI))>.25 THEN 270
260 PRINT TAB(L/S2);"0";
270 NEXT TI
275 TI=T(I+1)/2
276 IF -16*TI^2+V*C^(I-1)*TI<H THEN 290
280 NEXT I
290 PRINT
300 NEXT H
310 PRINT TAB(1);
320 FOR I=1 TO INT(L+1)/S2+1
330 PRINT ".";
340 NEXT I
350 PRINT
355 PRINT " 0";
360 FOR I=1 TO INT(L+.9995)
380 PRINT TAB(INT(I/S2));I;
390 NEXT I
400 PRINT
410 PRINT TAB(INT(L+1)/(2*S2)-2);"SECONDS"
420 PRINT
430 GOTO 135
440 END

@ -1,4 +1,4 @@
#lang br/demo/basic #lang basic-demo-nth
2 PRINT TAB(33);"CHANGE" 2 PRINT TAB(33);"CHANGE"
4 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 4 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
5 PRINT:PRINT:PRINT 5 PRINT:PRINT:PRINT

@ -0,0 +1,30 @@
#lang basic-demo-nth
3 print TAB(33);"Chemist"
6 print TAB(15);"Creative Computing | Morristown, New Jersey"
8 print:print:print
10 print "The fictitious chemical kryptocyanic acid can only be"
20 print "diluted by the ratio of 7 parts water to 3 parts acid."
30 print "if any other ratio is attempted, the acid becomes unstable"
40 print "and soon explodes. Given the amount of acid, you must"
50 print "decide who much water to add for dilution. If you miss,"
60 print "you face the consequences."
100 A=INT(RND(50))
110 W=7*A/3
115 if A=1 then P="liter" else P="liters"
120 print A; " "; P ; " of kryptocyanic acid. How much water?";
130 input R
140 D=ABS(W-R)
150 if D>W/20 then 200
160 print "Good job! You may breathe now, but don't inhale the fumes!"
170 print
180 goto 100
200 print "Sizzle! You have just been desalinated into a blob"
210 print "of quivering protoplasm!"
220 T=T+1
230 if T=3 then 260
240 print "However, you may try again with another life."
250 goto 100
260 print "Your 3 lives are used, but you will be long remembered for"
270 print "your contributions to the field of comic-book chemistry."
280 end

@ -0,0 +1,51 @@
#lang br
(require brag/support syntax-color/racket-lexer racket/contract
basic-demo/tokenizer sugar/coerce)
(define (color-basic ip)
(define postok (basic-lexer ip))
(define tok (position-token-token postok))
(define-values (type val)
(cond
[(eof-object? tok) (values eof eof)]
[(string? tok) (values 'string tok)]
[else (values (token-struct-type tok)
(format "~a" (token-struct-val tok)))]))
(values val
(caseq type
[(WHITE) 'white-space]
[(COMMENT) 'comment]
[(NUMBER) 'constant]
[(STRING) 'string]
[else 'keyword])
#f
(position-offset (position-token-start-pos postok))
(position-offset (position-token-end-pos postok))))
#;(provide
(contract-out
[color-basic
(input-port? . -> . (values
(or/c string? eof-object?)
symbol?
(or/c symbol? #f)
(or/c exact-positive-integer? #f)
(or/c exact-positive-integer? #f)))]))
(define (apply-colorer colorer-proc str)
(let loop ([p (open-input-string str)][color-recs empty])
(define color-rec (values->list (colorer-proc p)))
(if (eof-object? (car color-rec))
(reverse color-recs)
(loop p (cons color-rec color-recs)))))
(module+ main
(define str #<<HERE
10 rem 20
20 x = 42
30 print x
HERE
)
(apply-colorer color-basic str))

@ -0,0 +1,7 @@
#lang basic-demo-nth
5 A=5
10 DIM A(A)
20 PRINT A /* this should print 5 */
30 PRINT A(0)
40 PRINT A(5)

@ -0,0 +1,260 @@
#lang br/quicklang
(require (for-syntax syntax/strip-context))
(provide #%top-interaction #%app #%datum
(rename-out [basic-module-begin #%module-begin])
(all-defined-out))
; BASIC implementation details
; http://www.atariarchives.org/basicgames/showpage.php?page=i12
(begin-for-syntax
(require racket/list)
(define (gather-unique-ids stx)
(remove-duplicates (map syntax->datum (filter (λ(s) (syntax-property s 'id)) (syntax-flatten stx))) eq?)))
(define-macro (basic-module-begin (basic-program PROGRAM-LINE ...))
(with-pattern ([(UNIQUE-ID ...)
(map (compose1 syntax-local-introduce (λ(id) (datum->syntax #f id)))
(gather-unique-ids #'(PROGRAM-LINE ...)))])
#'(#%module-begin
(define UNIQUE-ID 0) ...
(provide UNIQUE-ID ...)
(run (sort (cons (line +inf.0 (statement "end"))
(list PROGRAM-LINE ...)) #:key $line-number <)))))
(struct exn:line-not-found exn:fail ())
(define (raise-line-not-found-error ln)
(raise
(exn:line-not-found
(format "line number ~a not found in program" ln)
(current-continuation-marks))))
(struct end-program-signal exn:fail ())
(define (raise-end-program-signal)
(raise (end-program-signal "" (current-continuation-marks))))
(struct end-line-signal exn:fail ())
(define (raise-end-line-signal)
(raise (end-line-signal "" (current-continuation-marks))))
(define (run line-list)
(define lines (list->vector line-list))
(define (find-index ln)
(or
(for/or ([idx (in-range (vector-length lines))])
(and (= ($line-number (vector-ref lines idx)) ln)
idx))
(raise-line-not-found-error ln)))
(void
(with-handlers ([end-program-signal? void])
(for/fold ([program-counter 0])
([i (in-naturals)])
(let* ([line-thunk ($line-thunk (vector-ref lines program-counter))]
[maybe-line-number (line-thunk)])
(if (number? maybe-line-number)
(find-index maybe-line-number)
(add1 program-counter)))))))
(define current-return-stack (make-parameter empty))
(define (basic:gosub where)
(let/cc return-k
(current-return-stack (cons return-k (current-return-stack)))
(basic:goto where)))
(define current-line (make-parameter #f))
(struct $line (number thunk) #:transparent)
(define-macro (line NUMBER . STATEMENTS)
#'($line NUMBER (λ ()
(current-line NUMBER)
(with-handlers ([end-line-signal? (λ _ #f)]
[end-program-signal? raise]
[exn:fail? (λ(exn)
(displayln (format "in line ~a" NUMBER))
(raise exn))])
. STATEMENTS))))
(define-macro-cases statement
[(statement ID "=" EXPR) #'(basic:let ID EXPR)]
[(statement PROC-NAME . ARGS)
(with-pattern
([PROC-ID (prefix-id "basic:" #'PROC-NAME)])
#'(PROC-ID . ARGS))])
(define-macro-cases basic:let
[(_ (id-expr ID) EXPR)
#'(set! ID EXPR)]
[(_ (id-expr ID DIM-IDX ...) EXPR)
#'(array-set! ID DIM-IDX ... EXPR)])
(define-macro-cases basic:if
[(_ COND-EXPR TRUE-EXPR FALSE-EXPR)
#'(if (true? COND-EXPR)
TRUE-EXPR
FALSE-EXPR)]
[(_ COND-EXPR TRUE-EXPR)
#'(if (true? COND-EXPR)
TRUE-EXPR
(raise-end-line-signal))]) ; special short-circuit rule for one-armed conditional
(define true? (compose1 not zero?))
(define (cond->int cond) (if cond 1 0))
(define (basic:and . args) (cond->int (andmap true? args)))
(define (basic:or . args) (cond->int (ormap true? args)))
(define-macro-cases id-expr
[(_ ID) #'(cond
[(procedure? ID) (ID)]
[(array? ID) (array-ref ID (make-vector (array-rank ID) 0))] ; no subscript => zeroth element
[else ID])]
[(_ ID EXPR0 EXPR ...) #'(cond
[(procedure? ID) (ID EXPR0 EXPR ...)]
[(array? ID) (array-ref ID EXPR0 EXPR ...)]
[else (error 'id-expr-confused)])])
(define-macro-cases expr
[(_ COMP-EXPR) #'COMP-EXPR]
[(_ COMP-EXPR "and" SUBEXPR) #'(basic:and COMP-EXPR SUBEXPR)]
[(_ COMP-EXPR "or" SUBEXPR) #'(basic:or COMP-EXPR SUBEXPR)])
(define-macro-cases comp-expr
[(_ SUM) #'SUM]
[(_ SUM "=" COMP-EXPR)
#'(cond->int (equal? SUM COMP-EXPR))] ; special case because `=` is overloaded in basic
[(_ SUM OP-STR COMP-EXPR)
(with-pattern
([OP (replace-context #'here (prefix-id #'OP-STR))])
#'(cond->int (OP SUM COMP-EXPR)))])
(define <> (compose1 not equal?))
(define-macro-cases sum
[(_ SUM) #'SUM]
[(_ SUM "+" PRODUCT) #'(+ SUM PRODUCT)]
[(_ SUM "-" PRODUCT) #'(- SUM PRODUCT)])
(define-macro-cases product
[(_ "-" VALUE) #'(- VALUE)]
[(_ VALUE) #'VALUE]
[(_ PRODUCT "*" VALUE) #'(* PRODUCT VALUE)]
[(_ PRODUCT "/" VALUE) #'(/ PRODUCT VALUE)])
(define-macro-cases power
[(_ BASE) #'BASE]
[(_ BASE POWER) #'(expt BASE POWER)])
(define-macro-cases maybe-negative-val
[(_ "-" ID) #'(- ID)]
[(_ ID) #'ID])
(define print-list list)
(define (basic:print [args #f])
(define (println [x ""])
(define xstr (format "~a" x))
(displayln xstr)
(current-print-position 0))
(define (print x)
(define xstr (format "~a" x))
(display xstr)
(current-print-position (+ (current-print-position) (string-length xstr))))
(match args
[#f (println)]
[(list print-list-items ... ";" pl)
(begin
(for-each
(λ(pli)
(print (if (number? pli)
(format "~a " pli)
pli)))
print-list-items)
(basic:print pl))]
[(list print-list-items ... ";") (for-each print print-list-items)]
[(list print-list-items ...)
(for-each println print-list-items)]))
(define current-print-position (make-parameter 0))
(define (TAB num) (make-string (max 0 (INT (- num (current-print-position)))) #\space))
(define (INT num) (inexact->exact (truncate num)))
(define (SIN num) (sin num))
(define (ABS num) (inexact->exact (abs num)))
(define (RND num) (* (random) num))
(define (EXP num) (exp num))
(define (SQR num) (sqrt num))
(define-macro-cases basic:input
[(_ (print-list . PL-ITEMS) ID ...)
#'(begin
(basic:print (append (print-list . PL-ITEMS) (list ";")))
(basic:input ID) ...)]
[(_ ID ...) #'(begin
(set! ID (let* ([str (read-line)]
[num (string->number (string-trim str))])
(or num str))) ...)])
(define (basic:goto where) where)
(define-macro-cases basic:on
[(_ TEST-EXPR "goto" OPTION ...)
#'(basic:goto (list-ref (list OPTION ...) (sub1 TEST-EXPR)))]
[(_ TEST-EXPR "gosub" OPTION ...)
#'(basic:gosub (list-ref (list OPTION ...) (sub1 TEST-EXPR)))])
(define (basic:return)
(define return-k (car (current-return-stack)))
(current-return-stack (cdr (current-return-stack)))
(return-k #f))
(define (basic:stop) (basic:end))
(define (basic:end) (raise-end-program-signal))
(require srfi/25)
(define-macro (basic:dim (id-expr ID EXPR ...) ...)
#'(begin
(set! ID (make-array (apply shape (append (list 0 (add1 EXPR)) ...)))) ...))
(define current-for-stack (make-parameter empty))
(define (push-for-stack thunk)
(current-for-stack (cons thunk (current-for-stack))))
(define (pop-for-stack)
(current-for-stack (cdr (current-for-stack))))
(define (in-closed-interval? x left right)
(define cmp (if (< left right) <= >=))
(cmp left x right))
(define-macro-cases basic:for
[(_ VAR START-VALUE END-VALUE)
#'(basic:for VAR START-VALUE END-VALUE 1)]
[(_ VAR START-VALUE END-VALUE STEP-VALUE)
#'(begin
(statement (id-expr VAR) "=" START-VALUE) ; initialize the loop counter
(let/cc return-k ; create a return point
(push-for-stack (cons 'VAR
(λ () ; thunk that increments counter & teleports back to beginning of loop
(define next-val (+ VAR STEP-VALUE))
(if (next-val . in-closed-interval? . START-VALUE END-VALUE)
(begin
(set! VAR next-val)
(return-k #f)) ; return value for subsequent visits to line
(pop-for-stack)))))
#f))]) ; return value for first visit to line
(define (handle-next [which #f])
(unless (pair? (current-for-stack)) (error 'next "for-stack is empty"))
(define for-thunk (cdr (if which
(assq which (current-for-stack))
(car (current-for-stack)))))
(for-thunk))
(define-macro (basic:next VAR ...)
#'(handle-next 'VAR ...))
(define-macro (basic:def DEF-ID LAMBDA-ID EXPR)
#'(set! DEF-ID (λ (LAMBDA-ID) EXPR)))

@ -0,0 +1,8 @@
#lang basic-demo-nth
10 for A=1 to 3
20 print A
21 for B=5 to 8
22 print B
23 next B
30 next A
40 print "yay"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save