cparse

package
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 Imports: 5 Imported by: 0

Documentation

Overview

A set of parser rules for C-Like syntax.

Index

Constants

View Source
const (
	E_VAR
	E_INT
	E_FLOAT
	E_CHAR
	E_STRING

	E_INCR
	E_DECR
	E_FIELD_DOT // Expr.Field
	E_FIELD_PTR // Expr->Field
	E_UNARY_OP
	E_BINARY_OP
	E_BINARY_OP_ASSIGN
	E_COMPARE
	E_ASSIGN
	E_FUNCTION_CALL // Expr( [Expr [,Expr]* ] )
	E_CONDITIONAL
	E_CAST
	E_INDEX
)
View Source
const (
	C_IF = rune(-(100 + iota))
	C_ELSE
	C_DO
	C_WHILE
	C_FOR
	C_CONST
)
View Source
const (
	S_EXPR
	S_BLOCK
	S_VARDEC
	S_FOR
	S_IF
	S_IF_ELSE
	S_DO_WHILE
	S_WHILE
)
View Source
const (
	T_NAME  // Identifiers like "int", "float" or "string" etc...
	T_CONST // Constant value
	T_PTR   // Pointer
)

Variables

View Source
var CKeywords = scanlist.TokenDict{
	"if":    C_IF,
	"else":  C_ELSE,
	"do":    C_DO,
	"while": C_WHILE,
	"for":   C_FOR,
	"const": C_CONST,
}

Functions

func C_DeclFragment_Func

func C_DeclFragment_Func(p *parser.Parser, tokens *scanlist.Element, left interface{}) parser.ParserResult

func RegisterDeclaration

func RegisterDeclaration(p *parser.Parser)

func RegisterExpr

func RegisterExpr(p *parser.Parser)

The following expression classes are registered.

'Expr0' // Primary Expression + Suffix
'Expr1' // Unary Expression
'Expr2' // Cast Expression
'Expr3' // Multiplicative Expression
'Expr4' // Additive Expression
'Expr5' // Bitwise expression
'Expr6' // Relational expression
'Expr7' // Logical expression
'Expr8' // Conditional expression
'Expr'  // Expression

func RegisterExprCast

func RegisterExprCast(p *parser.Parser)

Should be called only after RegisterExpr()! Adds the casting operation (Type)Expr.

func RegisterStatememt

func RegisterStatememt(p *parser.Parser)

func RegisterType

func RegisterType(p *parser.Parser)

Types

type DType

type DType struct {
	Type uint
	Text string
	Data []interface{}
	Pos  scanner.Position
}

func (*DType) String

func (d *DType) String() string

type DeclCType

type DeclCType struct {
	Inner string
	CType string
}

func (*DeclCType) String

func (d *DeclCType) String() string

type DeclImplFunc

type DeclImplFunc struct {
	Type      interface{}
	Name      string
	Arguments []ParamDecl
	Body      interface{}
	Pos       scanner.Position
}

type DeclInclude

type DeclInclude struct {
	HdrName string
}

func (*DeclInclude) String

func (d *DeclInclude) String() string

type DeclNone

type DeclNone struct{}

type DeclProtoFunc

type DeclProtoFunc struct {
	Type      interface{}
	Name      string
	Arguments []ParamDecl
	Pos       scanner.Position
}

type Expr

type Expr struct {
	Type uint
	Text string
	Data []interface{}
	Pos  scanner.Position
}

func (*Expr) String

func (e *Expr) String() string

type ParamDecl

type ParamDecl struct {
	Type interface{}
	Name string
}

type Statement

type Statement struct {
	Type uint
	Text string
	Data []interface{}
	Pos  scanner.Position
}

func (*Statement) String

func (e *Statement) String() string

type VarDecl

type VarDecl struct {
	Name string
	Init interface{} // Expr
}

func (VarDecl) String

func (v VarDecl) String() string

Jump to

Keyboard shortcuts

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