Skip to content

extensible code parser and infrastructure for C-like language.

License

Notifications You must be signed in to change notification settings

byte-mug/semiparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

extensible code parser and infrastructure for C-like language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages