Right off the bat I will say this has absolutely nothing to do with Microsoft Visual Basic.

Recently I've been practicing language design and development and I've written a few basic interpreters for calculator languages and such and I've decided for some more practice I want to write a basic BASIC interpter (haha, basic basic...). After searching around I've decided this is a fairly common practice (as far as language design goes) but there's one thing I don't understand. Obviously from the original there have been TONS of BASIC dialects, I don't know which to try to implement. Is there an existing ISO or ANSI standard for example? I want a dialect as original and modern as possible, does anyone know of any documentation that exists anywhere I can read through and use to implement this? Thanks for any suggestions.

Dani AI

Generated

— three pragmatic routes when building a BASIC interpreter: implement a very small Tiny/Minimal BASIC to learn parsing/runtime basics; aim for a standards-compliant “Full BASIC” implementation if portability to a formal spec matters; or target a de‑facto dialect (QuickBASIC/GW‑BASIC style) for maximum compatibility with existing code. Tiny/Minimal sources give a tiny, manageable feature set, the ISO/ANSI Full‑BASIC work is the formal trail if needed, and projects like QB64 show what modern QuickBASIC compatibility looks like. Tiny Basic Experimenter's Kit · ISO/IEC 10279 info page · QB64. (ittybittycomputers.com)

Practical incremental workflow: pick a tiny conformance subset, write a lexer, then a simple recursive‑descent parser or direct token walker, and a small runtime that maps line numbers (or statement locations) to executable nodes. Build a minimal symbol table, an expression evaluator, and a GOSUB/RETURN call stack first; add I/O, arrays and string support afterward. For interpreter architecture patterns and worked examples, see Crafting Interpreters. (github.com)

Feature checklist and common gotchas: decide numeric model (IEEE float vs fixed/decimal), whether to support type suffixes ($, %), OPTION BASE and lower‑bound arrays, DIM semantics, PRINT with ; and ,, INPUT parsing, GOTO/GOSUB semantics and error messages, file I/O and tokenization of REM/comments. If compatibility matters, use modern compatible compilers/interpreters (e.g. FreeBASIC or QB64) as behavioural references rather than trying to chase every clause of the old standard. (freebasic.net)

Minimal tokenizer skeleton (Python) to start parsing line‑based statements:

def tokenize(line):
    tokens=[]; i=0
    while i<len(line):
        c=line[i]
        if c.isspace(): i+=1; continue
        if c.isdigit():
            j=i
            while j<len(line) and line[j].isdigit(): j+=1
            tokens.append(('NUMBER', line[i:j])); i=j; continue
        if c.isalpha():
            j=i
            while j<len(line) and line[j].isalpha(): j+=1
            tokens.append(('IDENT', line[i:j].upper())); i=j; continue
        tokens.append(('CHAR',c)); i+=1
    return tokens

Scope the first iteration small, write automated tests (tiny example programs), and add features only when you have tests exercising the runtime edge cases. Mentioned references are practical starting points for whichever path decides to follow.

Recommended Answers

All 4 Replies

Scroll near the bottom of this wiki article and you will find some references.

Oh, thanks for the link! I saw the standards on the bottom, I saw the EMCA one so I searched it up and found if anyone's curious. Thanks again!

Did you notice the date on that documet? 1986! And it was written by some european manufacturer. That's like taking Microsoft document and calling it the standard. It might have been the standard in 1986, but I suspect the language has evolved a tad since them.

yeah I've noticed to, I will just adjust lots... I kinda jumped the gun on that post xD but it still helped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.