func (this *CoreLexer) Match(tok int) (t *Token, ParseException error) {
	if Debug.ParserDebug {
		Debug.println("match " + strconv.Itoa(tok))
	}
	if tok > CORELEXER_START && tok < CORELEXER_END {
		if tok == CORELEXER_ID {
			if !this.StartsId() {
				return nil, errors.New("ParseException: ID expected")
			}
			id := this.GetNextId()
			this.currentMatch = &Token{}
			this.currentMatch.tokenValue = id
			this.currentMatch.tokenType = CORELEXER_ID
		} else {
			nexttok := this.GetNextId()
			cur, ok := this.currentLexer[strings.ToUpper(nexttok)]
			if !ok || cur != tok {
				return nil, errors.New("ParseException: Unexpected Token")
			}
			this.currentMatch = &Token{}
			this.currentMatch.tokenValue = nexttok
			this.currentMatch.tokenType = tok
		}
	} else if tok > CORELEXER_END {
		next, err := this.LookAheadK(0)
		if err != nil {
			return nil, errors.New("ParseException: Expecting DIGIT")
		}
		if tok == CORELEXER_DIGIT {
			if !this.IsDigit(next) {
				return nil, errors.New("ParseException: Expecting DIGIT")
			}
			this.currentMatch = &Token{}
			this.currentMatch.tokenValue = string(next)
			this.currentMatch.tokenType = tok
			this.ConsumeK(1)
		} else if tok == CORELEXER_ALPHA {
			if !this.IsAlpha(next) {
				return nil, errors.New("ParseException: Expecting ALPHA")
			}
			this.currentMatch = &Token{}
			this.currentMatch.tokenValue = string(next)
			this.currentMatch.tokenType = tok
			this.ConsumeK(1)
		}
	} else {
		ch := byte(tok)
		next, err := this.LookAheadK(0)
		if err != nil {
			return nil, errors.New("ParseException: Expecting DIGIT")
		}
		if next == ch {
			this.currentMatch = &Token{}
			this.currentMatch.tokenValue = string(ch)
			this.currentMatch.tokenType = tok
			this.ConsumeK(1)
		} else {
			return nil, errors.New("ParseException: Expecting")
		}
	}
	return this.currentMatch, nil
}
Match the given token or throw an exception if no such token
can be matched.
package core
import (
	"bytes"
	"errors"
	"strconv"
	"strings"
)
const CORELEXER_START = 2048
const CORELEXER_END = CORELEXER_START + 2048
const CORELEXER_ID = CORELEXER_END - 1  
const CORELEXER_WHITESPACE = CORELEXER_END + 1
const CORELEXER_DIGIT = CORELEXER_END + 2
const CORELEXER_ALPHA = CORELEXER_END + 3
const CORELEXER_BACKSLASH = (int)('\\')
const CORELEXER_QUOTE = (int)('\'')
const CORELEXER_AT = (int)('@')
const CORELEXER_SP = (int)(' ')
const CORELEXER_HT = (int)('\t')
const CORELEXER_COLON = (int)(':')
const CORELEXER_STAR = (int)('*')
const CORELEXER_DOLLAR = (int)('$')
const CORELEXER_PLUS = (int)('+')
const CORELEXER_POUND = (int)('#')
const CORELEXER_MINUS = (int)('-')
const CORELEXER_DOUBLEQUOTE = (int)('"')
const CORELEXER_TILDE = (int)('~')
const CORELEXER_BACK_QUOTE = (int)('`')
const CORELEXER_NULL = (int)(0)  
const CORELEXER_EQUALS = (int)('=')
const CORELEXER_SEMICOLON = (int)(';')
const CORELEXER_SLASH = (int)('/')
const CORELEXER_L_SQUARE_BRACKET = (int)('[')
const CORELEXER_R_SQUARE_BRACKET = (int)(']')
const CORELEXER_R_CURLY = (int)('}')
const CORELEXER_L_CURLY = (int)('{')
const CORELEXER_HAT = (int)('^')
const CORELEXER_BAR = (int)('|')
const CORELEXER_DOT = (int)('.')
const CORELEXER_EXCLAMATION = (int)('!')
const CORELEXER_LPAREN = (int)('(')
const CORELEXER_RPAREN = (int)(')')
const CORELEXER_GREATER_THAN = (int)('>')
const CORELEXER_LESS_THAN = (int)('<')
const CORELEXER_PERCENT = (int)('%')
const CORELEXER_QUESTION = (int)('?')
const CORELEXER_AND = (int)('&')
const CORELEXER_UNDERSCORE = (int)('_')
type CoreLexer struct {
	StringTokenizer
	globalSymbolTable map[int]string
	lexerTables       map[string]LexerMap
	currentLexer      LexerMap
	currentLexerName  string
	currentMatch      *Token
}
func NewCoreLexer(lexerName string, buffer string) *CoreLexer {
	this := &CoreLexer{}
	this.StringTokenizer.super(buffer)
	this.globalSymbolTable = make(map[int]string)
	this.lexerTables = make(map[string]LexerMap)
	this.currentLexer = make(LexerMap)
	this.currentLexerName = lexerName
	return this
}
func (this *CoreLexer) Super(lexerName, buffer string) {
	this.StringTokenizer.super(buffer)
	this.globalSymbolTable = make(map[int]string)
	this.lexerTables = make(map[string]LexerMap)
	this.currentLexer = make(LexerMap)
	this.currentLexerName = lexerName
}
func (this *CoreLexer) SetLexerName(lexerName string) {
	this.currentLexerName = lexerName
}
func (this *CoreLexer) GetLexerName() string {
	return this.currentLexerName
}
func (this *CoreLexer) AddKeyword(name string, value int) {
	this.currentLexer[name] = value
	if _, ok := this.globalSymbolTable[value]; !ok {
		this.globalSymbolTable[value] = name
	}
}
func (this *CoreLexer) LookupToken(value int) string {
	if value > CORELEXER_START {
		return this.globalSymbolTable[value]
	} else {
		return strconv.Itoa(value)
	}
}
func (this *CoreLexer) AddLexer(lexerName string) LexerMap {
	var ok bool
	this.currentLexer, ok = this.lexerTables[lexerName]
	if !ok {
		this.currentLexer = make(LexerMap)
		this.lexerTables[lexerName] = this.currentLexer
	}
	return this.currentLexer
}
func (this *CoreLexer) SelectLexer(lexerName string) {
	this.currentLexer = this.lexerTables[lexerName]
	this.currentLexerName = lexerName
}
func (this *CoreLexer) CurrentLexer() LexerMap {
	return this.currentLexer
}
func (this *CoreLexer) PeekNextId() string {
	oldPtr := this.ptr
	retval := this.Ttoken()
	this.savedPtr = this.ptr
	this.ptr = oldPtr
	return retval
}
func (this *CoreLexer) GetNextId() string {
	return this.Ttoken()
}
func (this *CoreLexer) GetNextToken() *Token {
	return this.currentMatch
}
func (this *CoreLexer) PeekNextToken() (*Token, error) {
	tok, err := this.PeekNextTokenK(1)
	if err != nil {
		return nil, err
	} else {
		return tok[0], nil
	}
}
func (this *CoreLexer) PeekNextTokenK(ntokens int) ([]*Token, error) {
	old := this.ptr
	retval := make([]*Token, ntokens)
	var err error
	for i := 0; i < ntokens; i++ {
		tok := &Token{}
		if this.StartsId() {
			id := this.Ttoken()
			tok.tokenValue = id
			if _, ok := this.currentLexer[strings.ToUpper(id)]; ok {
				tok.tokenType = this.currentLexer[strings.ToUpper(id)]
			} else {
				tok.tokenType = CORELEXER_ID
			}
		} else {
			nextChar, err := this.GetNextChar()
			if err != nil {
				break
			}
			tok.tokenValue += string(nextChar)
			if this.IsAlpha(nextChar) {
				tok.tokenType = CORELEXER_ALPHA
			} else if this.IsDigit(nextChar) {
				tok.tokenType = CORELEXER_DIGIT
			} else {
				tok.tokenType = (int)(nextChar)
			}
		}
		retval[i] = tok
	}
	this.savedPtr = this.ptr
	this.ptr = old
	return retval, err
}