basic.txt


\ basic 00.11.27 11:28 pm NAB
.( Loading Quartus Very Tiny Basic ) cr
needs infix
needs file
needs string

char ; token ';'
char " token 'quote'

bnf: <string>
  'quote'
\ Use s" type instead of ." so that the
\ same code works whether compiling
\ or not:
  [char] s b,  [char] " b,  bl b,
  [char] " parse string>buffer
  [char] " b,  ,"  type "
;bnf

bnf: <literal>
  <expression> ,"  . "
  | <string>
;bnf

bnf: <sep>  ';' | ',' ,"  4 spaces " ;bnf

bnf: <literalchain>
  <literal> <sep> recurse
  | <literal>
  | <sep> recurse
;bnf

: print ( "..." -- )
  start-parsing <literalchain> <sep>
  success @ >r
  evaluate-code
  r> 0= if  s" cr" evaluate  then
; immediate

: cls ( -- )  page ; inline
: rem ( -- )  postpone \ ; immediate

create inputbuffer 10 allot

: (input) ( addr -- )
  inputbuffer 10 accept >r
  0. inputbuffer r>
  false >r
  begin
  >number
  dup 0= >r 2over or r> or 0= while
  over c@ [char] - = r> or >r
  1 /string
  repeat
  2drop drop r> if negate then
  swap ! ;

bnf: <input>
  <string> ';' <var> ,"  (input) "
  | <var>  ,"  (input) " ;bnf

: input ( "[<string><;>]<var>" -- )
  start-parsing <input>
  evaluate-code ; immediate


  HTMLized by Forth2HTML