Advertisement
PixelatedStarfish

Mbv142

Mar 14th, 2022
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.96 KB | None | 0 0
  1.  
  2. -MacroBeep Documentation v 1.4.2-
  3.  
  4. Thank you for using MacroBeep! A language by @PixelatedStarfish on
  5. esolangs.org (Andrew Vella). This documentation provides a reference
  6. for use, and fully defines an interpreter for the language.
  7.  
  8. File Extension .mcbe
  9.  
  10. Comments and and Questions can be left on this page:
  11. https://esolangs.org/wiki/Talk:MacroBeep
  12.  
  13.  
  14. *Contents*
  15.  
  16. MacroBeep at a Glance
  17. Acknowledgements
  18. Design Philosophy
  19. Language Paradigm
  20. Limitations and Considerations
  21. Instruction Set
  22. The Preprocessor and Include Statements
  23. Libraries
  24. Program Examples
  25. Error Codes
  26. The Debugger
  27. Turing Machines and the MacroBeep Tape
  28. Proof of Turing Completeness
  29. Grammar in EBNF
  30. Test Cases
  31. ASCII Table Reference
  32. Change Log
  33. Sources
  34.  
  35.  
  36. *MacroBeep at a Glance*
  37.  
  38. Syntax
  39.  
  40. All programs start execution at the statement "macro main".
  41. Source is designed for tracing. Statements end with a newline. An
  42. instruction consists of a command and an optional argument.
  43. Commands and arguments are separated by a space. An argument can be
  44. a string or an integer. All leading whitespace is ignored. #Inline
  45. comments start with hashtags, or octothorpes, and end at a newline.
  46. ##Multi-line comments are enclosed in doubles##
  47.  
  48. Memory
  49.  
  50. Memory is stored in cells on a tape. Each cell stores a byte.
  51. The tape pointer can access cells, modify cells, and output cell values.
  52. The tape pointer always starts at cell 0, or the head. All computation
  53. in MacroBeep happens on the tape.
  54.  
  55. To improve memory management, MacroBeep features
  56. a mark stack and a strip. The mark stack is a stack of marks.
  57. Marks mark a specific cell so the tape pointer can return to it later.
  58. The strip stores data temporarily for use. So combined,
  59. these let a programmer move data from one part of the tape
  60. to another, modify the data and move it back to the last marked
  61. location. A debugger provides Information about the state of the
  62. program memory for each instruction.
  63.  
  64.  
  65. Macros
  66.  
  67. Macros are defined in source as a series of instructions. When a macro
  68. is called, the instructions that define the macro are executed.
  69. A program will implicitly run the main macro. Macros can recurse,
  70. call other macros, and terminate with a return statement.
  71. Macros modify cells directly; apart from an identifier, they do not
  72. take arguments.
  73.  
  74. Files
  75.  
  76. MacroBeep programs can be composed of several files; ".mcbe" is the
  77. extension for a MacroBeep file. Files can be run from the run directory,
  78. or any sub-directory of the run directory. Include statements link files
  79. together into one larger program.
  80.  
  81.  
  82. *Acknowledgements*
  83.  
  84. I certainly would like to thank family, friends, and of course,
  85. mademoiselle for their support and care.
  86.  
  87. Thank you to the Skidmore College faculty, O'Connell, Dufour, Eckmann,
  88. Read, Reiley, and Prasad. I am glad to have my degree in computer science!
  89. I would also like to thank Bringas, Kravsky, and Lee for their tutelage,
  90. patience, and inspiration. MacroBeep would not exist without the esolangs wiki
  91. and the work of youtuber Truttle1.
  92.  
  93.  
  94. *Design Philosophy*
  95.  
  96. Macrobeep is designed in response to common problems people face when
  97. learning to code in more conventional programming languages. The syntax is
  98. designed to communicate what the computer is doing in a clear and
  99. concise manner. For every MacroBeep program, there is an equivalent
  100. MacroBeep program that can described as a sequence of native instructions
  101. in a specific order.
  102.  
  103. A MacroBeep programmer does not have to search for the missing punctuation.
  104. They do not need to find the unmatched parenthesis, or count their braces.
  105. They do not need to deal with the particularities of data types or the
  106. difference between objects, classes, structs, and interfaces.
  107. High-level abstraction is sacrificed for clarity and traceability.
  108.  
  109. This language is not without cons. A programmer needs to manage program
  110. memory themselves. Data cannot be protected. It is up to the programmer
  111. to make sure that something is not overwritten before it should be.
  112. A MacroBeep programmer should also be familiar with Turing machines
  113. and the ASCII table. This document covers everything you need to program
  114. in MacroBeep.
  115.  
  116.  
  117. *Limitations and Considerations*
  118.  
  119. One can only go so far to ease the challenges of memory management
  120. on a global tape. In theory the tape is infinite,
  121. but cells toward the head are easier to work with, so in
  122. practice, each macro competes for space. Planning is a must.
  123. The tape is unforgiving, and this makes writing complex programs
  124. a bit tedious...
  125.  
  126. Further versions require the replacement of the global tape with
  127. isolated strips of tape for each macro. Ideally, macros would also
  128. take arguments to promote readability.
  129.  
  130. Dealing with tape pointers for each macro would prove a
  131. challenge all its own. So each cell would have an index
  132. such that an argument can refer to a cell value.
  133.  
  134. Such a version would allow for much more forgiving memory management;
  135. memory can be allocated and freed for each macro.
  136. Tape pointers are eliminated, so each macro does not need a pointer
  137. of its own.
  138.  
  139. *Language Paradigm*
  140.  
  141. MacroBeep is an assembly style language with an instruction set, such
  142. that the programmer can define macros in order to describe and implement
  143. more complex operations. There is no part of a MacroBeep program that can be
  144. considered stateless, and there are no functions in MacroBeep. Instead,
  145. a program modifies bytes on a tape using a pointer in a manner similar to bf,
  146. such that each cell on the tape can store a value between 0 and 255 inclusive.
  147. A program in MacroBeep will always run the main macro before any other
  148. macro.
  149.  
  150.  
  151. *Instruction Set*
  152.  
  153. Each operation can take an identifier or an integer value as an argument.
  154. A macro cannot be a reserved word or operation name. Operations are
  155. separated by a newline, and arguments by a space.
  156.  
  157. Before reading the table, a quick clarification should be made.
  158. A branching instruction does either of these:
  159.  
  160. - shifts execution forward by some (positive or negative) number
  161. of instructions
  162.  
  163. - starts execution at the label given
  164.  
  165. Instruction Table
  166.  
  167. macro (define macro; takes an identifier)
  168.  
  169. do (do macro identified in arg, call macro)
  170.  
  171. rt (return to macro call an execute next instruction)
  172.  
  173. null (set cell to 0)
  174.  
  175. str (store value of current cell in next cell, or offset from
  176. the current cell as specified such that -1 indicates storage
  177. in the left cell.)
  178.  
  179. stat (short for 'store at', this stores the value of the current
  180. cell at the cell given in an argument. 'stat 2' stores the
  181. value of the current cell 2 cells right of the head.
  182.  
  183. rand (set cell a random from 0 to arg or 0 to 255)
  184.  
  185. add (add to cell; 1 if no arg)
  186.  
  187. sub (take from cell; 1 if no arg)
  188.  
  189. right (move pointer to the right; by 1 if no arg is given)
  190.  
  191. left (move pointer to the left; by 1 if no arg is given)
  192.  
  193. head (go to head of tape, or to specified offset from head)
  194.  
  195. pos (get position of cell pointer on tape and print it)
  196.  
  197. inp (get input; char, int, or string by args 0, 1, 2)
  198.  
  199. out (print cell or arg)
  200.  
  201. cout (print char on cell or arg as char)
  202.  
  203. pr (print any value given as a string with a newline, newline
  204. if nothing. Use '[]' to print a space and '{}' to print a tab)
  205.  
  206. beep (it goes beep, use an argument to specify frequency in hertz.
  207. Default is 1000)
  208.  
  209. label (for an example of how to use a a label, see the false machine)
  210.  
  211. send (copy one or more cells to the head of the tape; mark the
  212. location of the first cell copied. Pushes a mark)
  213.  
  214. reply (copy one or more cells from the head of the tape to the cell
  215. location marked; this erases the strip of copied data and
  216. pops a mark of the stack.)
  217.  
  218. solar (branch if cell is greater than 0)
  219.  
  220. lunar (branch if cell is 0)
  221.  
  222. venusian (branch if cell is equal to next cell)
  223.  
  224. martian (branch if cell is not equal to next cell)
  225.  
  226. jovian (branch if cell is greater than next cell)
  227.  
  228. plutonic (branch if cell is less than next cell)
  229.  
  230. vestian (branch if cell is greater than or equal to next cell)
  231.  
  232. sednian (branch if cell is less than or equal to to next cell)
  233.  
  234. halt (end program)
  235.  
  236. wait (adds a delay of 100ms, or as specified by an argument)
  237.  
  238. include (include files at path identified)
  239.  
  240. # (inline comment)
  241.  
  242. ## (start or end a multi-line comment)
  243.  
  244.  
  245. *The Preprocessor and Include Statements*
  246.  
  247. The Preprocessor formats source code so that it can run appropriately.
  248. All leading whitespace before an instruction is removed. All blank lines
  249. are removed. If needed, all null lines are replaced with empty comments.
  250. (Comments are ignored at runtime and do not need to be removed.)
  251. Additionally, all include statements are processed. The contents of each
  252. included files are concatenated into a single set of source.
  253.  
  254. The include statement includes all the macros in a file so a program
  255. can use them. As stated above, include statements include files at the path
  256. identified. So...
  257.  
  258. include run\foo\hw.mcbe
  259.  
  260. ... includes the hw.mcbe file in a subdirectory foo, in run. Note
  261. that the run directory (or folder) is included in the file path.
  262. This ensures that the interpreter will look for files in the run directory.
  263.  
  264. The entire contents of a directory can be included using an asterisk
  265. ( * ) like so...
  266.  
  267. include run\foo\*
  268.  
  269. Now suppose that hw.mcbe also has include statements. A programmer
  270. could write paths back to run but it can be tedious if the path back
  271. to the run directory is long.
  272.  
  273. The closing angle bracket ( > ) is useful for this case.
  274. It gets replaced with the path from run to hw.mcbe. So...
  275.  
  276. include run\foo\bar\tm.mcbe
  277.  
  278. is equivalent to
  279.  
  280. include >\bar\tm.mcbe
  281.  
  282.  
  283. *Libraries*
  284.  
  285. Libraries are quite simple in MacroBeep. They are ordinary .mcbe files
  286. stored in a directory called "lib" instead of in run. You can write
  287. your own, just as you would any other MacroBeep program.
  288.  
  289. As of this version, a library called "SumDif" is included.
  290. It can calculate a sum and a difference using "SumDif.sum" and
  291. "SumDif.dif"
  292.  
  293. The convention for naming macros in libraries is to start with
  294. the name of the library, then a dot, then the rest of the macro name.
  295. For example "SumDif.sum" is the name of the sum macro in the SumDif library.
  296.  
  297. In java the dot would indicate that sum is a static method in SumDif.
  298. In MacroBeep the use of a dot is only a convention. The linker is
  299. minimal in MacroBeep; it does not enforce the use of a dot operator.
  300.  
  301.  
  302. *Program Examples*
  303.  
  304. It is good practice to indicate the scope of an instruction with tabs
  305. or spaces. This can be useful to indicate which instructions are part of a
  306. macro. Leading white space is not required. New lines are the only
  307. significant white space characters.
  308.  
  309. The end of a program is indicated by #$
  310.  
  311. Hello World
  312. macro main
  313. pr Hello[]World
  314. # Note that the [] is printed as a space
  315.  
  316. Truth Machine
  317. macro main
  318. pr Type[]a[]0[]or[]1[]into[]the[]truth[]machine.
  319. inp 1
  320. solar 3
  321. pr 0
  322. halt
  323. pr 1
  324. wait
  325. solar -3
  326. #$
  327.  
  328. False Machine
  329.  
  330. macro main
  331. pr Type[]a[]0[]or[]1[]into[]the[]false[]machine.
  332. inp 1
  333. lunar magic
  334. pr 1
  335. halt
  336. label magic
  337. pr 0
  338. wait
  339. lunar magic
  340. #$
  341.  
  342. Cat
  343.  
  344. macro main
  345. pr Give[]me[]a[]word[]and[]I[]will[]say[]it[]back!
  346. inp 2
  347. head
  348. cout
  349. right
  350. solar -3
  351. #$
  352.  
  353. C scale
  354. macro main
  355. beep 262
  356. beep 294
  357. beep 330
  358. beep 349
  359. beep 392
  360. beep 440
  361. beep 494
  362. beep 523
  363. #$
  364.  
  365. Sum of Numbers
  366.  
  367. macro sum
  368. send 2
  369.  
  370. right
  371. label WhileCellTwoIsNotZero
  372. add -1
  373. head
  374. add 1
  375. right
  376. solar WhileCellTwoIsNotZero
  377. reply
  378. rt
  379.  
  380. macro init #initialize
  381. right 2
  382. add
  383. right
  384. add 2
  385. right
  386. add 3
  387. right
  388. add 5
  389. right
  390. add 8
  391. right
  392. add 13
  393. right
  394. add 21
  395. rt
  396.  
  397. macro main
  398. do init
  399. head 2
  400.  
  401. #Loop through numbers and add them together
  402. label Loop
  403. right
  404. lunar ifTheCellIsZeroGoHere
  405. left
  406. do sum
  407. str
  408. right
  409. solar Loop
  410.  
  411. #Output
  412. label ifTheCellIsZeroGoHere
  413. left
  414. out
  415. rt
  416. #$
  417.  
  418. Note that some main macros do not include a return statement 'rt'.
  419. This is because the program ends when the macro does. A 'rt'
  420. can be added to the main macro but it is not required. A macro
  421. without an 'rt' will continue to execute until it reaches an 'rt'
  422. somewhere or gets to an End Of File. So...
  423.  
  424. macro main
  425. beep
  426. macro sub
  427. beep 555
  428. rt
  429.  
  430. ... will execute. 'do sub' will execute the macro 'sub'. 'do main'
  431. will execute from the top to the 'rt'. However, any statements
  432. after the 'rt' would not execute, since macro 'main' has finished.
  433.  
  434.  
  435. *Error Codes*
  436.  
  437. Error (0)
  438. The Generic Error Message, for errors not described below.
  439.  
  440. Undefined Instruction (1)
  441. Thrown when the interpreter encounters an instruction that is not
  442. defined in the instruction set.
  443.  
  444. File Not Found (2)
  445. Either the file does not exist, or it is in the wrong directory.
  446.  
  447. Undefined Macro or Label (3)
  448. The macro called by "do" has no matching definition; alternatively,
  449. the label branched to does not exist.
  450.  
  451. Missing Main Macro (4)
  452. "macro main" is missing, the program cannot start.
  453.  
  454. Stack Overflow (5)
  455. This error is most commonly caused by an infinite recursion. Too many
  456. macro calls on the call stack.
  457.  
  458. Not a Cell Error (6)
  459. Occurs when a program tries to modify a cell that does not exist,
  460. such as cell -1 or cell infinity.
  461.  
  462. Include Statement in Macro (7)
  463. An include statement cannot be written into a macro definition.
  464.  
  465. Preprocessor Error (8)
  466. A preprocessor error that is not caught by any other error code. Check
  467. include statements carefully.
  468.  
  469. Duplicate Macro or Label (9)
  470. A macro or label is defined more than once in the program. Calls to
  471. it are ambiguous.
  472.  
  473. Argument Error. Integer Expected (10)
  474. An instruction that only takes an integer argument was not given an
  475. integer argument.
  476.  
  477. Bad Argument (11)
  478. This is the error thrown when the interpreter reads statements that
  479. are syntactically correct, but incomputable in this language, such as
  480. "wait -100". Esoteric models of time notwithstanding, instructions that
  481. require negative time to compute would throw this error.
  482.  
  483. Astrological Error (12)
  484. This error occurs when the next instruction to execute is located
  485. outside source entirely. It is as if you gave the interpreter a To-Do list
  486. of 10 or so items in an order, and then said "Hey, no need to do that fifth
  487. thing, go do item 24, or -5 instead. " Confusion would be understandable,
  488. and nothing would get done!
  489.  
  490.  
  491. *The Debugger*
  492.  
  493. This displays the following information for each instruction:
  494. -The current instruction.
  495. -The current macro.
  496. -Position of a marked cell.
  497. -Data on the strip (used by the send and reply operations)
  498. -A section of five cells on the tape, centered on the pointer.
  499.  
  500. Every 25 steps, the debugger will stop and wait for a key press.
  501. This keeps from overloading the shell with text.
  502.  
  503.  
  504.  
  505. *Turing Machines and the MacroBeep Tape*
  506.  
  507. What is a Turing Machine?
  508.  
  509. The Turing Machine is a theoretical machine first described by Alan
  510. Turing. It consists of a tape divided into cells and a pointer that
  511. can modify cells on the tape. The tape extends without bound, so the
  512. machine never runs out of cells. (In practice, this is not possible,
  513. but such a limitation is usually ignored).
  514.  
  515. A Turing machine can do the following:
  516.  
  517. Shift the pointer left or right
  518. Read the value on the cell
  519. Write a value to a cell
  520.  
  521. The pointer can point to one cell at any given time, and it can only
  522. act on the cell at which it points. To act on another cell the pointer
  523. has to move to that cell. The pointer of a Turing Machine is programmable.
  524. It can be given instructions like: "Set the current cell to 0", or
  525. "If the current cell is one, go one cell to the right". These instructions
  526. describe something called a Finite State Machine, which is a machine
  527. that knows its current state, and decides what to do next according
  528. to its instructions.
  529.  
  530. In the case of "If the current cell is one, go one cell to the right",
  531. the pointer can read the current cell, and decide whether or not it
  532. should go to the next cell on the right. If the current cell is one, the
  533. pointer goes right (which changes its state), and if not, it stays
  534. put.
  535.  
  536. The typical Turing machine has cells that can be set to 0 or 1 (sometimes
  537. 'blank' or 'null' is included, meaning no data is on this cell).
  538. Here is a crude, plain text visual, with the pointer pointing to
  539. the second cell on the tape:
  540.  
  541.  
  542. 1 | 1 | 0 | 1 | 0 | 0 | 1
  543. ^
  544.  
  545. The first cell of the tape is called the head of the tape, all other
  546. cells are positioned right of the head.
  547.  
  548. The Turing Machine can compute anything that is computable, and anything
  549. that can simulate a Turing Machine can compute anything that is computable.
  550. To put it another way, such a machine can decide any decidable
  551. problem, or solve any solvable math problem if it is programmed to
  552. do so. Something that can simulate a Turing Machine is Turing Complete,
  553. and any Turing Complete system can simulate any other Turing Complete
  554. system.
  555.  
  556. The MacroBeep Tape
  557.  
  558. MacroBeep makes use of a Turing Machine for computation, but cells
  559. on this machine can store any integer value from 0 to 255 inclusive.
  560. In other words, each cell stores a byte of information, equivalent to
  561. 8 cells in the tape above. Many esoteric programming languages use
  562. a tape like this one. The most notable example is none other than one of
  563. the most famous, a language by Urban Muller [sic] (with a swear word in the
  564. name), which will be referred to as bf. Here is a visual of the byte tape
  565. used in bf and MacroBeep:
  566.  
  567. 000 | 255 | 023 | 150 | 045 | 213 | 010
  568. ^
  569.  
  570. Note that, as with a Turing machine, the tape extends to the right
  571. without bound. Also note that the pointer can do all of the things
  572. a pointer on a Turing machine can. Furthermore this pointer can modify
  573. bytes, adding or subtracting from them such that they can be at any
  574. integer value from 0 to 255. The initial state of the tape is such that
  575. every cell is set to 0.
  576.  
  577. In MacroBeep, 'pos' gives the pointer position, 'out' gives the current
  578. cell value; 'left' and 'right' move the pointer, 'add' and 'sub' modify
  579. cell values. Note that 'pos' and 'out' are excellent debugging
  580. operations. See the Instruction Set for more information.
  581.  
  582.  
  583. *Proof of Turing Completeness*
  584.  
  585. bf is Turing complete, and consists of only eight instructions.
  586. Given the above, by translating each bf command to MacroBeep, it can
  587. be shown that MacroBeep is also
  588. Turing complete.
  589.  
  590. This table provides a means to translate between MacroBeep and bf.
  591.  
  592. MacroBeep bf Description
  593.  
  594. right > increment
  595.  
  596. left < decrement
  597.  
  598. add + add 1 to cell
  599.  
  600. sub - take 1 from
  601. cell
  602.  
  603. cout . Output ASCII
  604. value at cell
  605.  
  606. inp , Take input at
  607. cell
  608.  
  609. lunar (by some positive number of instructions) [ jump past ]
  610. if cell is 0
  611.  
  612. solar (by some negative number of instructions) ] goto [ if cell is
  613. greater than 0
  614.  
  615.  
  616. *Grammar in EBNF*
  617.  
  618. Extended Backus-Naur Form is a metasyntax that can describe the syntax
  619. of a programming language. It is useful for understanding how the language
  620. is parsed for interpretation.
  621.  
  622. Key:
  623. ::= assignment, equivalence
  624. | or
  625. (group)
  626. {repeated at least one time}
  627. [optional]
  628. 'string literal'
  629. symbol
  630. , symbol concatenation
  631. ; symbol terminator
  632. (*comment*)
  633.  
  634. Program ::= {statement}
  635.  
  636. statement ::= macro | instruct
  637.  
  638. macro ::= 'macro', s, alnum, n, {instruct}, ['rt'];
  639. (*be careful when leaving out 'rt'*)
  640.  
  641. instruct ::= word, s, [arg], n;
  642.  
  643. arg ::= alnum | inte
  644.  
  645. alnum ::= {(lett | digit)};
  646.  
  647. word ::= {lett};
  648.  
  649. inte ::= {digit};
  650.  
  651. s ::= ' ';
  652.  
  653. n ::= '\n';
  654.  
  655. digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
  656.  
  657. lett ::= 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k'
  658. | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' |'w' |
  659. 'x' | 'y' | 'z';
  660.  
  661.  
  662. *Test Cases*
  663.  
  664. This includes various tests that a MacroBeep interpreter needs to
  665. pass to be correct. Do not assume this is an exhaustive list. Rather,
  666. use this list as a guide to understand the language.
  667.  
  668. As a general rule, each instruction needs to pass:
  669. -A test with no argument
  670. -A test with an expected argument
  671. -A test with an unexpected argument
  672.  
  673. Be sure that errors thrown are correct.
  674. An incorrect error at the right time is an easy mistake to leave in!
  675.  
  676.  
  677. Input and Output Test
  678. Test:
  679. Hello World
  680.  
  681. Desc:
  682. Tests print statements and comments
  683.  
  684. Output:
  685. Hello Worlds!
  686. Hello World
  687.  
  688. Code:
  689. macro main
  690. pr Hello[]Worlds!
  691. # include SUDDENLY A COMMENT WOAH!!
  692. pr
  693. pr Hello{}Wor##OH WOW A
  694. MULTILINER
  695. WHAT##ld
  696.  
  697. Result:
  698. PASSED
  699.  
  700.  
  701. Test:
  702. Truth Machine
  703.  
  704. Output:
  705. 0
  706. OR
  707. 111111111111111111111111111...
  708.  
  709. For the code, see program examples.
  710. Result:
  711. PASSED
  712.  
  713.  
  714. Test:
  715. False Machine
  716.  
  717. Output:
  718. 0000000000000000000...
  719. OR
  720. 1
  721.  
  722. For the code, see program examples.
  723. Result:
  724. PASSED
  725.  
  726. Test:
  727. Cat
  728.  
  729. Output:
  730. Output the given input
  731.  
  732. For the code, see program examples.
  733. Result:
  734. PASSED
  735.  
  736. Test:
  737. Beep
  738.  
  739. Output:
  740. beeps at a frequency of the argument given mod 2501
  741.  
  742. Code:
  743. macro main
  744. beep
  745. beep 3300
  746. beep 500
  747.  
  748. Result:
  749. PASSED
  750.  
  751. Test:
  752. Generalized IO test
  753. Output:
  754. The ascii value of the first character given.
  755. (Note this also applies if an inp arg that is greater than 2 is given)
  756.  
  757. Code:
  758. macro main
  759. inp
  760. out
  761.  
  762. Result:
  763. PASSED
  764.  
  765. Test:
  766. Arithmetic Operations Test
  767. Output:
  768. The sum of several numbers, 53.
  769.  
  770. For the code, see program examples
  771. Result:
  772. PASSED
  773.  
  774. Error Tests
  775.  
  776. Undefined Instruction (1) [PASSED]
  777. macro main
  778. foo
  779.  
  780. File [or in this case, directory] Not Found (2) [PASSED]
  781. include foo\*
  782. macro main
  783.  
  784. Undefined Macro or Label. (3) [PASSED]
  785. macro main
  786. do foo
  787. cosmic foo
  788. #comment out one statement to test the other
  789.  
  790. Missing Main Macro (4) [PASSED]
  791. This is not code in MacroBeep.
  792.  
  793. Stack Overflow (5) [INCONCLUSIVE]
  794. macro store
  795. do store
  796.  
  797. macro main
  798. do store
  799. #This will eventually throw the error
  800.  
  801. Not a Cell Error (6) [PASSED]
  802. macro main
  803. left
  804. add 50
  805. #no cell -1
  806.  
  807. Include Statement in Macro (7) [PASSED]
  808. macro main
  809. include foo
  810.  
  811. Preprocessor Error [Check Includes] (8) [PASSED]
  812. include
  813. macro main
  814.  
  815. Duplicate Definitions [test for macros and labels] (9) [PASSED]
  816. macro main
  817. macro foo
  818. macro foo
  819.  
  820. Argument Error: Integer Expected (10) [PASSED]
  821. macro main
  822. wait foo
  823.  
  824. Bad Argument (11) [PASSED]
  825. macro main
  826. wait -100
  827.  
  828.  
  829. Astrological Error (12) [PASSED]
  830. macro main
  831. lunar -10
  832.  
  833. Include Tests
  834.  
  835. There are six such tests, each test uses 3 files: MAIN, A, and
  836. B respectively. Each test should produce the same output, a beep at
  837. 1000 hertz and a beep at 500 hertz; excluding the first test, which should
  838. only output one beep at 1000 hertz.
  839.  
  840. Test 1
  841. MAIN
  842.  
  843. include a.mcbe
  844. macro main
  845. do b
  846.  
  847. A
  848.  
  849. macro b
  850. beep
  851. rt
  852.  
  853. Test 2
  854. MAIN
  855.  
  856. include a.mcbe
  857. include b.mcbe
  858. macro main
  859. do b
  860. do c
  861.  
  862. A
  863.  
  864. macro b
  865. beep
  866. rt
  867.  
  868. B
  869.  
  870. macro c
  871. beep 500
  872. rt
  873.  
  874. Test 3
  875. MAIN
  876.  
  877. include dir/a.mcbe
  878. include dir/b.mcbe
  879. macro main
  880. do b
  881. do c
  882.  
  883. A
  884.  
  885. macro b
  886. beep
  887. rt
  888.  
  889. B
  890.  
  891. macro c
  892. beep 500
  893. rt
  894.  
  895. Test 4
  896. MAIN
  897.  
  898. include a.mcbe
  899. macro main
  900. do b
  901. do c
  902.  
  903. A
  904.  
  905. include b.mcbe
  906. macro b
  907. beep
  908. rt
  909.  
  910. B
  911.  
  912. macro c
  913. beep 500
  914. rt
  915.  
  916. Test 5
  917. MAIN
  918.  
  919. include run\foo\*
  920.  
  921. macro main
  922. do that
  923. do this
  924.  
  925.  
  926. A (in run/foo)
  927.  
  928. macro that
  929. beep
  930. rt
  931.  
  932. B (in run/foo/bar)
  933.  
  934. macro this
  935. beep 500
  936. rt
  937.  
  938. Test 6
  939. MAIN
  940.  
  941. include run\foo\a.mcbe
  942.  
  943. macro main
  944. do that
  945. do this
  946.  
  947.  
  948. A (in run/foo)
  949.  
  950. include >\bar\bar.mcbe
  951.  
  952. macro that
  953. beep
  954. rt
  955.  
  956. B (in run/foo/bar)
  957.  
  958. macro this
  959. beep 500
  960. rt
  961.  
  962. *ASCII Table Reference*
  963.  
  964.  
  965. Characters on the ASCII table correspond to integer values. For example,
  966. "H" is equal to 72. In MacroBeep "cout 72" prints an H.
  967.  
  968. Null 0
  969.  
  970. Beep 7
  971.  
  972. Tab 9
  973.  
  974. New Line 10
  975.  
  976. Space 32
  977.  
  978. ! 33
  979.  
  980. " 34
  981.  
  982. # 35
  983.  
  984. $ 36
  985.  
  986. % 37
  987.  
  988. & 38
  989.  
  990. ' 39
  991.  
  992. ( 40
  993.  
  994. ) 41
  995.  
  996. * 42
  997.  
  998. + 43
  999.  
  1000. , 44
  1001.  
  1002. - 45
  1003.  
  1004. . 46
  1005.  
  1006. / 47
  1007.  
  1008. 0 48
  1009.  
  1010. 1 49
  1011.  
  1012. 2 50
  1013.  
  1014. 3 51
  1015.  
  1016. 4 52
  1017.  
  1018. 5 53
  1019.  
  1020. 6 54
  1021.  
  1022. 7 55
  1023.  
  1024. 8 56
  1025.  
  1026. 9 57
  1027.  
  1028. : 58
  1029.  
  1030. ; 59
  1031.  
  1032. < 60
  1033.  
  1034. = 61
  1035.  
  1036. > 62
  1037.  
  1038. ? 63
  1039.  
  1040. @ 64
  1041.  
  1042. A 65
  1043.  
  1044. B 66
  1045.  
  1046. C 67
  1047.  
  1048. D 68
  1049.  
  1050. E 69
  1051.  
  1052. F 70
  1053.  
  1054. G 71
  1055.  
  1056. H 72
  1057.  
  1058. I 73
  1059.  
  1060. J 74
  1061.  
  1062. K 75
  1063.  
  1064. L 76
  1065.  
  1066. M 77
  1067.  
  1068. N 78
  1069.  
  1070. O 79
  1071.  
  1072. P 80
  1073.  
  1074. Q 81
  1075.  
  1076. R 82
  1077.  
  1078. S 83
  1079.  
  1080. T 84
  1081.  
  1082. U 85
  1083.  
  1084. V 86
  1085.  
  1086. W 87
  1087.  
  1088. X 88
  1089.  
  1090. Y 89
  1091.  
  1092. Z 90
  1093.  
  1094. [ 91
  1095.  
  1096. \ 92
  1097.  
  1098. ] 93
  1099.  
  1100. ^ 94
  1101.  
  1102. _ 95
  1103.  
  1104. ` 96
  1105.  
  1106. a 97
  1107.  
  1108. b 98
  1109.  
  1110. c 99
  1111.  
  1112. d 100
  1113.  
  1114. e 101
  1115.  
  1116. f 102
  1117.  
  1118. g 103
  1119.  
  1120. h 104
  1121.  
  1122. i 105
  1123.  
  1124. j 106
  1125.  
  1126. k 107
  1127.  
  1128. l 108
  1129.  
  1130. m 109
  1131.  
  1132. n 110
  1133.  
  1134. o 111
  1135.  
  1136. p 112
  1137.  
  1138. q 113
  1139.  
  1140. r 114
  1141.  
  1142. s 115
  1143.  
  1144. t 116
  1145.  
  1146. u 117
  1147.  
  1148. v 118
  1149.  
  1150. w 119
  1151.  
  1152. x 120
  1153.  
  1154. y 121
  1155.  
  1156. z 122
  1157.  
  1158. { 123
  1159.  
  1160. | 124
  1161.  
  1162. } 125
  1163.  
  1164. ~ 126
  1165.  
  1166.  
  1167.  
  1168. *Change Log (changes from v1.3.0)*
  1169.  
  1170. -Added send and reply instructions
  1171. -Added tom and mark instructions
  1172. -Implemented mark stack for memory management
  1173. -Implemented a debugger
  1174. -Implemented a library called SumDif
  1175. -Implemented a Help menu to print docs by section
  1176. -Bug fixes
  1177. -Updated and expanded docs
  1178. -Removed typos
  1179.  
  1180. *Sources*
  1181.  
  1182. ASCII table. ASCII Table - ASCII Character Codes, HTML, Octal, Hex,
  1183. Decimal. (n.d.). Retrieved January 16, 2022,
  1184. from https://www.asciitable.com/
  1185.  
  1186. Bf. Esolang. (n.d.). Retrieved January 16, 2022,
  1187. from https://esolangs.org/wiki/Bf
  1188. (Swear word removed.)
  1189.  
  1190. Truth-machine. Esolang. (n.d.). Retrieved February 2, 2022,
  1191. from https://esolangs. org/wiki/Truth-machine
  1192.  
  1193. Macrobeep. Esolang. (n.d.). Retrieved January 16, 2022,
  1194. from https://esolangs.org/wiki/MacroBeep
  1195.  
  1196. Wikimedia Foundation. (2021, December 25). Extended backus-naur form.
  1197. Wikipedia. Retrieved January 17, 2022,
  1198. from https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form#Table_of_Symbols
  1199.  
  1200. Wikimedia Foundation. (2022, January 4). Turing completeness. Wikipedia.
  1201. Retrieved January 16, 2022,
  1202. from https://en.wikipedia. org/wiki/Turing_completeness
  1203.  
  1204. Wikimedia Foundation. (2022, January 14). Turing machine. Wikipedia.
  1205. Retrieved January 16, 2022,
  1206. from https://en.wikipedia.org/wiki/Turing_machine
  1207.  
  1208.  
  1209. -End of Documentation (Scroll Up)-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement