Skip to content

Commit

Permalink
fix: fix #2102, #2108 (#2131)
Browse files Browse the repository at this point in the history
* g4 code generation

* Update grammar

* g4 code generation

* fix #2108

* fix #2102

* Remove comments
  • Loading branch information
kesonan committed Jul 20, 2022
1 parent d9218e1 commit 1b51d0c
Show file tree
Hide file tree
Showing 24 changed files with 2,360 additions and 2,167 deletions.
8 changes: 4 additions & 4 deletions tools/goctl/api/parser/g4/ApiLexer.g4
Expand Up @@ -16,6 +16,10 @@ LINE_VALUE: ':' [ \t]* (STRING|(~[\r\n"`]*));
ID: Letter LetterOrDigit*;
LetterOrDigit
: Letter
| [0-9]
;
fragment ExponentPart
: [eE] [+-]? Digits
;
Expand All @@ -35,10 +39,6 @@ fragment Digits
: [0-9] ([0-9_]* [0-9])?
;

fragment LetterOrDigit
: Letter
| [0-9]
;
fragment Letter
: [a-zA-Z$_] // these are the "java letters" below 0x7F
| ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
Expand Down
3 changes: 2 additions & 1 deletion tools/goctl/api/parser/g4/ApiParser.g4
Expand Up @@ -70,4 +70,5 @@ replybody: returnToken='returns' lp='(' dataType? rp=')';
kvLit: key=ID {checkKeyValue(p)}value=LINE_VALUE;

serviceName: (ID '-'?)+;
path: (('/' (ID ('-' ID)*))|('/:' (ID ('-' ID)?)))+ | '/';
path: (('/' (pathItem ('-' pathItem)*))|('/:' (pathItem ('-' pathItem)?)))+ | '/';
pathItem: (ID|LetterOrDigit)+;
2 changes: 1 addition & 1 deletion tools/goctl/api/parser/g4/ast/api.go
Expand Up @@ -210,7 +210,7 @@ func (a *Api) Format() error {

// Equal compares whether the element literals in two Api are equal
func (a *Api) Equal(v interface{}) bool {
if v == nil {
if v == nil || a == nil {
return false
}

Expand Down
4 changes: 4 additions & 0 deletions tools/goctl/api/parser/g4/gen/api/apiparser_base_visitor.go
Expand Up @@ -152,3 +152,7 @@ func (v *BaseApiParserVisitor) VisitServiceName(ctx *ServiceNameContext) interfa
func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) interface{} {
return v.VisitChildren(ctx)
}

func (v *BaseApiParserVisitor) VisitPathItem(ctx *PathItemContext) interface{} {
return v.VisitChildren(ctx)
}
280 changes: 140 additions & 140 deletions tools/goctl/api/parser/g4/gen/api/apiparser_lexer.go

Large diffs are not rendered by default.

427 changes: 223 additions & 204 deletions tools/goctl/api/parser/g4/gen/api/apiparser_parser.go

Large diffs are not rendered by default.

0 comments on commit 1b51d0c

Please sign in to comment.