#51 saving optional tokes and tokens that have different representation as meta

This commit is contained in:
z7zmey
2018-07-29 11:44:38 +03:00
parent 0138749c6d
commit 4989d31874
223 changed files with 9832 additions and 5976 deletions

View File

@@ -9,7 +9,7 @@ import (
// BitwiseAnd node
type BitwiseAnd struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseAnd) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *BitwiseAnd) GetMeta() []meta.Meta {
return n.Meta
func (n *BitwiseAnd) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// BitwiseOr node
type BitwiseOr struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseOr) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *BitwiseOr) GetMeta() []meta.Meta {
return n.Meta
func (n *BitwiseOr) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// BitwiseXor node
type BitwiseXor struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseXor) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *BitwiseXor) GetMeta() []meta.Meta {
return n.Meta
func (n *BitwiseXor) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// BooleanAnd node
type BooleanAnd struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *BooleanAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanAnd) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *BooleanAnd) GetMeta() []meta.Meta {
return n.Meta
func (n *BooleanAnd) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// BooleanOr node
type BooleanOr struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *BooleanOr) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanOr) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *BooleanOr) GetMeta() []meta.Meta {
return n.Meta
func (n *BooleanOr) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Coalesce node
type Coalesce struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Coalesce) GetPosition() *position.Position {
return n.Position
}
func (n *Coalesce) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Coalesce) GetMeta() []meta.Meta {
return n.Meta
func (n *Coalesce) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Concat node
type Concat struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Concat) GetPosition() *position.Position {
return n.Position
}
func (n *Concat) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Concat) GetMeta() []meta.Meta {
return n.Meta
func (n *Concat) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Div node
type Div struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Div) GetPosition() *position.Position {
return n.Position
}
func (n *Div) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Div) GetMeta() []meta.Meta {
return n.Meta
func (n *Div) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Equal node
type Equal struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Equal) GetPosition() *position.Position {
return n.Position
}
func (n *Equal) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Equal) GetMeta() []meta.Meta {
return n.Meta
func (n *Equal) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Greater node
type Greater struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Greater) GetPosition() *position.Position {
return n.Position
}
func (n *Greater) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Greater) GetMeta() []meta.Meta {
return n.Meta
func (n *Greater) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// GreaterOrEqual node
type GreaterOrEqual struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *GreaterOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *GreaterOrEqual) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *GreaterOrEqual) GetMeta() []meta.Meta {
return n.Meta
func (n *GreaterOrEqual) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Identical node
type Identical struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Identical) GetPosition() *position.Position {
return n.Position
}
func (n *Identical) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Identical) GetMeta() []meta.Meta {
return n.Meta
func (n *Identical) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// LogicalAnd node
type LogicalAnd struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *LogicalAnd) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalAnd) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *LogicalAnd) GetMeta() []meta.Meta {
return n.Meta
func (n *LogicalAnd) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// LogicalOr node
type LogicalOr struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *LogicalOr) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalOr) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *LogicalOr) GetMeta() []meta.Meta {
return n.Meta
func (n *LogicalOr) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// LogicalXor node
type LogicalXor struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *LogicalXor) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalXor) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *LogicalXor) GetMeta() []meta.Meta {
return n.Meta
func (n *LogicalXor) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Minus node
type Minus struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Minus) GetPosition() *position.Position {
return n.Position
}
func (n *Minus) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Minus) GetMeta() []meta.Meta {
return n.Meta
func (n *Minus) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Mod node
type Mod struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Mod) GetPosition() *position.Position {
return n.Position
}
func (n *Mod) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Mod) GetMeta() []meta.Meta {
return n.Meta
func (n *Mod) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Mul node
type Mul struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Mul) GetPosition() *position.Position {
return n.Position
}
func (n *Mul) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Mul) GetMeta() []meta.Meta {
return n.Meta
func (n *Mul) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// NotEqual node
type NotEqual struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *NotEqual) GetPosition() *position.Position {
return n.Position
}
func (n *NotEqual) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *NotEqual) GetMeta() []meta.Meta {
return n.Meta
func (n *NotEqual) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// NotIdentical node
type NotIdentical struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *NotIdentical) GetPosition() *position.Position {
return n.Position
}
func (n *NotIdentical) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *NotIdentical) GetMeta() []meta.Meta {
return n.Meta
func (n *NotIdentical) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Plus node
type Plus struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Plus) GetPosition() *position.Position {
return n.Position
}
func (n *Plus) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Plus) GetMeta() []meta.Meta {
return n.Meta
func (n *Plus) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Pow node
type Pow struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Pow) GetPosition() *position.Position {
return n.Position
}
func (n *Pow) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Pow) GetMeta() []meta.Meta {
return n.Meta
func (n *Pow) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ShiftLeft node
type ShiftLeft struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftLeft) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ShiftLeft) GetMeta() []meta.Meta {
return n.Meta
func (n *ShiftLeft) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// ShiftRight node
type ShiftRight struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftRight) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *ShiftRight) GetMeta() []meta.Meta {
return n.Meta
func (n *ShiftRight) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Smaller node
type Smaller struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Smaller) GetPosition() *position.Position {
return n.Position
}
func (n *Smaller) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Smaller) GetMeta() []meta.Meta {
return n.Meta
func (n *Smaller) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// SmallerOrEqual node
type SmallerOrEqual struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *SmallerOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *SmallerOrEqual) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *SmallerOrEqual) GetMeta() []meta.Meta {
return n.Meta
func (n *SmallerOrEqual) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -9,7 +9,7 @@ import (
// Spaceship node
type Spaceship struct {
Meta []meta.Meta
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
@@ -33,12 +33,8 @@ func (n *Spaceship) GetPosition() *position.Position {
return n.Position
}
func (n *Spaceship) AddMeta(m []meta.Meta) {
n.Meta = append(n.Meta, m...)
}
func (n *Spaceship) GetMeta() []meta.Meta {
return n.Meta
func (n *Spaceship) GetMeta() *meta.Collection {
return &n.Meta
}
// Attributes returns node attributes as map

View File

@@ -41,12 +41,20 @@ var nodes = []node.Node{
}
func TestMeta(t *testing.T) {
expected := []meta.Meta{
meta.NewComment("//comment\n", nil),
meta.NewWhiteSpace(" ", nil),
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.AddMeta(expected)
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}