First cut of a parser.

This commit is contained in:
Nigel Tao committed 2017-04-29 16:57:56 +10:00
1 parent 21c6c34d92
commit ea2bc6c10c
4 files changed
+439 -42

No files matched your search

-13
View File
@@ -8,19 +8,6 @@ import (
"fmt"
)
// nBuiltIns is the number of built-in IDs:
// - The first 128 are squiggles, such as operators and parentheses.
// - The next 128 are keywords.
// - The last 256 aren't returned by Tokenize. The space encodes ambiguous
// 1-byte operators. For example, & might be the start of &^ or &=.
const nBuiltIns = 512
type ID uint32
func (t ID) isBuiltIn() bool { return t < nBuiltIns }
func (t ID) implicitSemicolon() bool { return t >= nBuiltIns || builtInsImplicitSemicolons[t&0xFF] }
type IDMap struct {
byName map[string]ID
byID []string