From 9b674c2c12bc9e158cfca68ac615f6a659834384 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Mon, 19 Feb 2018 13:24:56 +0200 Subject: [PATCH] Add simple comments to exported methods --- node/stmt/n_alt_if.go | 2 ++ node/stmt/n_group_use.go | 1 + node/stmt/n_if.go | 2 ++ node/stmt/n_use.go | 1 + php5/parser.go | 4 +++- php7/parser.go | 2 ++ 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/node/stmt/n_alt_if.go b/node/stmt/n_alt_if.go index 6d6a656..46074ee 100644 --- a/node/stmt/n_alt_if.go +++ b/node/stmt/n_alt_if.go @@ -28,6 +28,7 @@ func (n *AltIf) Attributes() map[string]interface{} { return nil } +// AddElseIf add AltElseIf node and returns AltIf node func (n *AltIf) AddElseIf(ElseIf node.Node) node.Node { if n.ElseIf == nil { n.ElseIf = make([]node.Node, 0) @@ -38,6 +39,7 @@ func (n *AltIf) AddElseIf(ElseIf node.Node) node.Node { return n } +// SetElse set AltElse node and returns AltIf node func (n *AltIf) SetElse(Else node.Node) node.Node { n.Else = Else diff --git a/node/stmt/n_group_use.go b/node/stmt/n_group_use.go index 169a471..432f479 100644 --- a/node/stmt/n_group_use.go +++ b/node/stmt/n_group_use.go @@ -26,6 +26,7 @@ func (n *GroupUse) Attributes() map[string]interface{} { return nil } +// SetUseType set use type and returns node func (n *GroupUse) SetUseType(UseType node.Node) node.Node { n.UseType = UseType return n diff --git a/node/stmt/n_if.go b/node/stmt/n_if.go index 4a45a0c..09f8831 100644 --- a/node/stmt/n_if.go +++ b/node/stmt/n_if.go @@ -28,6 +28,7 @@ func (n *If) Attributes() map[string]interface{} { return nil } +// AddElseIf add ElseIf node and returns AltIf node func (n *If) AddElseIf(ElseIf node.Node) node.Node { if n.ElseIf == nil { n.ElseIf = make([]node.Node, 0) @@ -38,6 +39,7 @@ func (n *If) AddElseIf(ElseIf node.Node) node.Node { return n } +// SetElse set Else node and returns AltIf node func (n *If) SetElse(Else node.Node) node.Node { n.Else = Else diff --git a/node/stmt/n_use.go b/node/stmt/n_use.go index a74d617..a87846e 100644 --- a/node/stmt/n_use.go +++ b/node/stmt/n_use.go @@ -26,6 +26,7 @@ func (n *Use) Attributes() map[string]interface{} { return nil } +// SetUseType set use type and returns node func (n *Use) SetUseType(UseType node.Node) node.Node { n.UseType = UseType return n diff --git a/php5/parser.go b/php5/parser.go index dab5006..c734189 100644 --- a/php5/parser.go +++ b/php5/parser.go @@ -19,17 +19,19 @@ var positionBuilder position.Builder var parentNode node.Node +// Parse the php5 parser entrypoint func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) { yyDebug = 0 yyErrorVerbose = true rootnode = stmt.NewStmtList([]node.Node{}) //reset comments = comment.Comments{} positions = position.Positions{} - positionBuilder = position.Builder{&positions} + positionBuilder = position.Builder{Positions: &positions} yyParse(newLexer(src, fName)) return rootnode, comments, positions } +// ListGetFirstNodeComments returns comments of a first node in the list func ListGetFirstNodeComments(list []node.Node) []comment.Comment { if len(list) == 0 { return nil diff --git a/php7/parser.go b/php7/parser.go index 219c9c5..4b6f836 100644 --- a/php7/parser.go +++ b/php7/parser.go @@ -15,6 +15,7 @@ var comments comment.Comments var positions position.Positions var positionBuilder position.Builder +// Parse the php7 parser entrypoint func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) { yyDebug = 0 yyErrorVerbose = true @@ -26,6 +27,7 @@ func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.P return rootnode, comments, positions } +// ListGetFirstNodeComments returns comments of a first node in the list func ListGetFirstNodeComments(list []node.Node) []comment.Comment { if len(list) == 0 { return nil