ast

package
v0.0.0-...-95add9b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2016 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ast provides an Abstract Syntax Tree for the MinC language

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function struct {
	Func      scanner.Position
	Name      *Identifier
	ParamList *ParamList
	StmtBlock *StmtBlock
}

Function represents the core abstraction of a program. As the language specification describes, it consists of a return type, symobolic name, parameter list and a statement block

type Identifier

type Identifier struct {
	Pos scanner.Position
	Lit string
}

Identifier may be either a type name, like "void", or the main funciton identifier, "main"

type ParamList

type ParamList struct {
	RParen scanner.Position
	LParen scanner.Position
}

ParamList represents the "()" portion of the function declaration Neither are used but the position of both parentheses are retained Since further compilation of the language do not use these positions but they are there for scaffolding of later work

type Program

type Program struct {
	Function *Function
}

Program is the root of the AST. It has only one field, the main function, and nothing else. In the future, it will be much more complex, holding things like other functions and global variable declations

type StmtBlock

type StmtBlock struct {
	LBrace scanner.Position
	RBrace scanner.Position
}

StmtBlock represents the "{}" portion of the function declaration As with ParamList, neither are used in the rest of the compilation process

Jump to

Keyboard shortcuts

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