Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

The Return of Tiny Basic


January, 2006: The Return of Tiny Basic

Grammar Fragment English Explanation Formal IL (Allison) TBIL (Pittman)
line::= Tiny Basic reads lines GETLINE GL
number possibly with a line number in front TSTL <label> BN <label>
-- insert numbered statement into program INSERT IL
* repeat as needed JMP <label> BR <label>
statement do whatever the statement rule says to do STMT: <label> :STMT
PRINT is this keyword "PRINT"? TST S8,'PRINT' BC SKIP "PR"
expr-list::= this is what you can print… --
string quoted string TST S7,'"'; PRS BC P7 '"'; PQ
expression do the expression evaluation rule CALL EXPR JS EXPR
-- print the resulting value PRN PN
IF is this keyword "IF"? TST S9,'IF' BC INPT "IF"
relop do compare operator rule CALL RELOP JS RELO
THEN error if this in not keyword "THEN"? TST S17,'THEN' BC I1 "THEN"
statement do whatever the statement rule says to do JMP STMT J STMT
GOTO is this keyword "GOTO"? if not, try another TST S3,'GO'; TST S2,'TO' BC PRNT "GO"; BC GOSB "TO"
expression do the expression evaluation rule CALL EXPR JS EXPR
-- error if not end of statement DONE BE *
-- find that line in the program, do it next XPER GO
LET is this keyword "LET"? if not, try another TST S1,'LET' BC GOTO "LET"
var save variable name; error if none TSTV S17 BV *
= error if there is no "=" here TST S17,'=' BC * "="
expression do the expression evaluation rule CALL EXPR JS EXPR
-- error if not end of statement DONE BE *
-- store the value into the variable STORE SV
-- resume with next line XPER NX

Table 1: Partial correlation between Grammar, English pseudocode, and Interpreter Language. Grammar elements in the left column, represented by English pseudocode in the next column, then IL equivalents in the last two columns, Allison's then mine.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.