Skip to content

Commit

Permalink
Add internal compilation step
Browse files Browse the repository at this point in the history
* Streamline what we get from "otto/parser"
* Get rid of some "otto/parser" cruft
* FunctionExpression => FunctionLiteral
* The debugger statement (debugger) should do nothing (not panic)
* Fix aspects of function expression call evaluation
  • Loading branch information
robertkrimen committed Apr 19, 2014
1 parent 0917510 commit bf7b16f
Show file tree
Hide file tree
Showing 35 changed files with 2,163 additions and 1,600 deletions.
7 changes: 6 additions & 1 deletion Makefile
@@ -1,8 +1,9 @@
.PHONY: test test-race test-release release release-check
.PHONY: test test-race test-release release release-check test-262
.PHONY: parser
.PHONY: otto assets underscore

TESTS := \
FunctionDeclarationInFunction \
~

TEST := -v --run
Expand Down Expand Up @@ -34,6 +35,10 @@ release-check: .test
$(MAKE) -C .test/test262 build test
@echo PASS

test-262: .test
$(MAKE) -C .test/test262 build test
@echo PASS

test-release:
go test -i
go test
Expand Down
8 changes: 4 additions & 4 deletions README.markdown
Expand Up @@ -370,8 +370,8 @@ always be in UTF-8.

src may also be a Script.

src may also be a node, but if the AST has been modified, then runtime behavior
is undefined.
src may also be a Program, but if the AST has been modified, then runtime
behavior is undefined.

#### func (Otto) Call

Expand Down Expand Up @@ -472,8 +472,8 @@ undefined and the parse error (nothing will be evaluated in this case).

src may also be a Script.

src may also be a node, but if the AST has been modified, then runtime behavior
is undefined.
src may also be a Program, but if the AST has been modified, then runtime
behavior is undefined.

#### func (Otto) Set

Expand Down
107 changes: 61 additions & 46 deletions ast/README.markdown
Expand Up @@ -12,13 +12,6 @@ node types are concerned) and may change in the future.

## Usage

#### func GobRegister

```go
func GobRegister()
```
GobRegister will register node types with "encoding/gob"

#### type ArrayLiteral

```go
Expand Down Expand Up @@ -343,13 +336,12 @@ func (self *DebuggerStatement) Idx1() file.Idx
#### type Declaration

```go
type Declaration struct {
Name string
Definition Node
type Declaration interface {
// contains filtered or unexported methods
}
```

FIXME
All declaration nodes implement the Declaration interface.

#### type DoWhileStatement

Expand Down Expand Up @@ -498,31 +490,40 @@ func (self *ForStatement) Idx0() file.Idx
func (self *ForStatement) Idx1() file.Idx
```

#### type FunctionExpression
#### type FunctionDeclaration

```go
type FunctionDeclaration struct {
Function *FunctionLiteral
}
```


#### type FunctionLiteral

```go
type FunctionExpression struct {
Function file.Idx
Body Statement
Source string
type FunctionLiteral struct {
Function file.Idx
Name *Identifier
ParameterList *ParameterList
Body Statement
Source string

Cache_ParameterList []string // Beware, may go away
Cache_FunctionList []Declaration // Beware, may go away
Cache_VariableList []Declaration // Beware, may go away
DeclarationList []Declaration
}
```


#### func (*FunctionExpression) Idx0
#### func (*FunctionLiteral) Idx0

```go
func (self *FunctionExpression) Idx0() file.Idx
func (self *FunctionLiteral) Idx0() file.Idx
```

#### func (*FunctionExpression) Idx1
#### func (*FunctionLiteral) Idx1

```go
func (self *FunctionExpression) Idx1() file.Idx
func (self *FunctionLiteral) Idx1() file.Idx
```

#### type Identifier
Expand Down Expand Up @@ -698,14 +699,24 @@ func (self *ObjectLiteral) Idx0() file.Idx
func (self *ObjectLiteral) Idx1() file.Idx
```

#### type ParameterList

```go
type ParameterList struct {
Opening file.Idx
List []*Identifier
Closing file.Idx
}
```


#### type Program

```go
type Program struct {
Body []Statement

FunctionList []Declaration
VariableList []Declaration
DeclarationList []Declaration
}
```

Expand Down Expand Up @@ -746,12 +757,6 @@ type RegExpLiteral struct {
```


#### func (*RegExpLiteral) Compile

```go
func (self *RegExpLiteral) Compile() *regexp.Regexp
```

#### func (*RegExpLiteral) Idx0

```go
Expand Down Expand Up @@ -956,28 +961,16 @@ func (self *UnaryExpression) Idx0() file.Idx
func (self *UnaryExpression) Idx1() file.Idx
```

#### type VarStatement
#### type VariableDeclaration

```go
type VarStatement struct {
type VariableDeclaration struct {
Var file.Idx
List []Expression
List []*VariableExpression
}
```


#### func (*VarStatement) Idx0

```go
func (self *VarStatement) Idx0() file.Idx
```

#### func (*VarStatement) Idx1

```go
func (self *VarStatement) Idx1() file.Idx
```

#### type VariableExpression

```go
Expand All @@ -1001,6 +994,28 @@ func (self *VariableExpression) Idx0() file.Idx
func (self *VariableExpression) Idx1() file.Idx
```

#### type VariableStatement

```go
type VariableStatement struct {
Var file.Idx
List []Expression
}
```


#### func (*VariableStatement) Idx0

```go
func (self *VariableStatement) Idx0() file.Idx
```

#### func (*VariableStatement) Idx1

```go
func (self *VariableStatement) Idx1() file.Idx
```

#### type WhileStatement

```go
Expand Down

0 comments on commit bf7b16f

Please sign in to comment.