skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
323 stars 27 forks source link

Float handling has gone away? #31

Closed skx closed 5 years ago

skx commented 5 years ago

Somewhere along the way we lost the ability to parse floats:

  10 DUMP 0.3
  20 PRINT "OK\n"

Output is:

  NUMBER: 0.000000
  Error running program: Token not handled: {IDENT .}
skx commented 5 years ago

Yup, it's not the interpreter that is to blame, but the lexer:

   frodo ~/go/src/github.com/skx/gobasic $ ./gobasic -lex ./t.bas 
   {NEWLINE N}
   {LINENO 10}
   {IDENT DUMP}
   {INT 0}
   {IDENT .}
   {INT 3}
   {NEWLINE N}
   {LINENO 20}
   {PRINT PRINT}
   {STRING OK
   }
   {NEWLINE N}
   {NEWLINE N}

. is showing up as an IDENT which is just wrong ..

skx commented 5 years ago

Better now :)

   frodo ~/go/src/github.com/skx/gobasic $ go build . ; ./gobasic -lex ./t.bas 
   {NEWLINE N}
   {LINENO 10}
   {IDENT DUMP}
   {INT 0.3}
   {NEWLINE N}
   {LINENO 20}
   {PRINT PRINT}
   {STRING OK
   }
   {NEWLINE N}
   {NEWLINE N}