Сценарий: Массив

Этот коммит содержится в:
Softonik 2024-02-08 23:56:49 +03:00 коммит произвёл Nobody
родитель bd58013fcd
коммит 46bf5129ab
3 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -138,3 +138,11 @@ func handleStarExpr(s *ast.StarExpr) (code string) {
}
return
}
func handleArray(s *ast.ArrayType) (code string) {
switch x := s.Elt.(type) {
case *ast.Ident:
code += handleIdentExpr(x)
}
return
}

Просмотреть файл

@ -38,4 +38,19 @@ int c1 = 4;
int c2 = 5;
double c3 = 5.5;
std::string s1 = "privet";
```
Сценарий: Массив
* Исходник:
```
package test
var (
a []int
b []bool
)
```
* Результат:
```
int a[];
bool b[];
```

Просмотреть файл

@ -23,6 +23,11 @@ func handleValueSpec(s *ast.ValueSpec) (code string) {
code += " = "
code += handleValueSpecValues(s.Values)
}
_, ok = s.Type.(*ast.ArrayType)
if ok {
code += "[]"
}
return code
}
@ -63,6 +68,8 @@ func handleValueSpecType(expr ast.Expr) (code string) {
code += handleIdentExpr(t)
case *ast.StarExpr:
code += handleStarExpr(t)
case *ast.ArrayType:
code += handleArray(t)
}
return
}