Skip to content

Commit

Permalink
Merge pull request #9 from alecthomas/revert-4-comment_ast_fix
Browse files Browse the repository at this point in the history
Revert "Fix parsing of comments"
  • Loading branch information
cwaeland authored Feb 16, 2024
2 parents 7a2ea75 + a21950a commit 3512342
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 496 deletions.
8 changes: 4 additions & 4 deletions parser/grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ FieldList ← fields:(Field (Whitespace / EOL)*)* {
return flds, nil
}

Field ← blockComment:(_ Comment? EOL)* _ id:IntConstant _ ':' _ req:FieldReq? _ typ:FieldType _ name:Identifier def:(__ '=' _ ConstValue)? _ annotations:TypeAnnotations? ListSeparator? _ comment:Comment? {
Field ← blockComment:(_ Comment? EOL)* _ id:IntConstant _ ':' _ req:FieldReq? _ typ:FieldType _ name:Identifier __ def:('=' _ ConstValue)? _ annotations:TypeAnnotations? ListSeparator? _ comment:Comment? {
f := &Field{
Pos : makePos(c.pos),
ID : int(id.(int64)),
Expand All @@ -326,7 +326,7 @@ Field ← blockComment:(_ Comment? EOL)* _ id:IntConstant _ ':' _ req:FieldReq?
f.Optional = true
}
if def != nil {
f.Default = def.([]interface{})[3]
f.Default = def.([]interface{})[2]
}
if comment != nil {
f.Comment = ifaceSliceToCommentString(comment)
Expand Down Expand Up @@ -371,7 +371,7 @@ EndOfServiceError ← . {
return nil, errors.New("parser: expected end of service")
}

Function ← blockComment:(_ Comment? EOL)* _ oneway:("oneway" __)? typ:FunctionType __ name:Identifier _ '(' __ arguments:FieldList ')' exceptions:(__ Throws)? _ annotations:TypeAnnotations? ListSeparator? _ comment:Comment? {
Function ← blockComment:(_ Comment? EOL)* _ oneway:("oneway" __)? typ:FunctionType __ name:Identifier _ '(' __ arguments:FieldList ')' __ exceptions:Throws? _ annotations:TypeAnnotations? ListSeparator? _ comment:Comment? {
m := &Method{
Pos: makePos(c.pos),
Name: string(name.(Identifier)),
Expand All @@ -388,7 +388,7 @@ Function ← blockComment:(_ Comment? EOL)* _ oneway:("oneway" __)? typ:Function
m.Arguments = arguments.([]*Field)
}
if exceptions != nil {
m.Exceptions = exceptions.([]interface{})[1].([]*Field)
m.Exceptions = exceptions.([]*Field)
for _, e := range m.Exceptions {
e.Optional = true
}
Expand Down
Loading

0 comments on commit 3512342

Please sign in to comment.