Documentation
¶
Overview ¶
Package parse parses an assembly program into an AST.
Index ¶
Examples ¶
Constants ¶
View Source
const ( Keyword = iota Operand String Lbrace Rbrace Endl Semi )
asm8 token types.
Variables ¶
View Source
var Types = func() *lexing.Types { ret := lexing.NewTypes() o := func(t int, name string) { ret.Register(t, name) } o(Keyword, "keyword") o(Operand, "operand") o(Lbrace, "'{'") o(Rbrace, "'}'") o(String, "string") o(Semi, "';'") o(Endl, "end-line") return ret }()
Types provides a type name querier
Functions ¶
func BareFunc ¶
BareFunc parses a file as a bare function.
func File ¶
File function parses a file into an AST.
func Tokens ¶
Tokens parses a file in a token array
Example (Badcomment) ¶
o(`/*some comment`)
Output: t.s8:1: unexpected eof in block comment 1 error(s)
Example (Badstr1) ¶
o(`"some string`)
Output: t.s8:1: unexpected eof in string 1 error(s)
Example (Badstr2) ¶
o("\"some string\n")
Output: t.s8:1: unexpected endl in string 1 error(s)
Example (Case1) ¶
o("\n")
Output: t.s8:1: endl t.s8:1: eof
Example (Case2) ¶
o("")
Output: t.s8:1: eof
Example (Case3) ¶
o("func a { // comment \n\tsyscall\n}")
Output: t.s8:1: kw - "func" t.s8:1: op - "a" t.s8:1: lb t.s8:1: cm - "// comment " t.s8:1: endl t.s8:2: op - "syscall" t.s8:2: endl t.s8:3: rb t.s8:3: eof
Example (Case4) ¶
o("func a{}") // Output // t.s8:1: kw - "func" // t.s8:1: op - "a" // t.s8:1: lb // t.s8:1: rb
Output:
Example (Comments) ¶
o("// line comment \n /* block comment */")
Output: t.s8:1: cm - "// line comment " t.s8:1: endl t.s8:2: cm - "/* block comment */" t.s8:2: eof
Example (Keywords) ¶
o("func var const import")
Output: t.s8:1: kw - "func" t.s8:1: kw - "var" t.s8:1: kw - "const" t.s8:1: kw - "import" t.s8:1: eof
Example (String) ¶
o("\"some string \\\"\\\\ here\"")
Output: t.s8:1: str - "\"some string \\\"\\\\ here\"" t.s8:1: eof
Types ¶
Click to show internal directories.
Click to hide internal directories.