semiparse

module
v0.0.0-...-7323597 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2017 License: MIT

README

Parser

package main

import "github.com/byte-mug/semiparse/scanlist"
import "github.com/byte-mug/semiparse/parser"
import "github.com/byte-mug/semiparse/cparse"
import "github.com/byte-mug/semiparse/ecparse"
import "strings"
import "fmt"
//import "text/scanner"

const src = `
//object.getX:int(arg);
i[].Array;
//a = b + c;
`


func buildParser() *parser.Parser {
	p := new(parser.Parser).Construct()
	cparse.RegisterExpr(p)
	cparse.RegisterType(p)
	cparse.RegisterExprCast(p)
	ecparse.RegisterExprOCX(p)
	return p
}

func main() {
	s := new(scanlist.BaseScanner)
	s.Init(strings.NewReader(src))
	s.Dict = cparse.CKeywords
	l := s.Next()
	p := buildParser()
	res := p.Match("Expr",l)
	fmt.Println(res.Result)
	fmt.Println(res.Data)
}

Directories

Path Synopsis
A set of parser rules for C-Like syntax.
A set of parser rules for C-Like syntax.
Extensions to the C-like parser.
Extensions to the C-like parser.
A Parser library and framework.
A Parser library and framework.
A Lazy-Evaluating Linked list around the "text/scanner" package.
A Lazy-Evaluating Linked list around the "text/scanner" package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL