Well, I'm not using any fancy lex/yacc/[insert grammar tool here] stuff.

Regardless of what tools you use to construct a lexer/parser with, you need a grammar, it should be the first thing you do. The grammar I gave you allows you to set operator precedences for addition, subtraction, multiplication and division. After tokenisations (lexer) you can parse the grammar I gave you (roughly, see below) with a simple recursive descent parser:

sub expr

term

while current = SYM_PLUS or current = SYM_MINUS

term

wend

end sub

sub term

factor

while current = SYM_TIMES or current = SYM_DIVIDE

factor

wend

end sub

sub factor

if current <> SYM_ID and current <> SYM_NUM then

print_error "Expected identifier or constant"

end if

end sub

LL(1) stands for

**L**eft to right parsed, producing a

**L**eftmost derivation and using

**1** token for lookahead. This means that you parse the grammar from left to right, and that the leftmost non-terminal will be replaced at each step. Lookahead is the number of tokens you need to be able to see to correctly parse the grammar, with 1 lookahead you only need to know the current token.

The grammar that I gave you isn't actually LL(1) because it contains left recursion, but you can rewrite left recursive grammars so they can be parsed by an LL(1) parser.

You are going to need at least a little bit of grammar theory to be able to do this, and IMHO you are better off with a book than some web tutorial. You need to construct an LL(1) grammar for the language you are trying to parse, then implementing a lexer and parser are easy.