Сценарий: Массив
Этот коммит содержится в:
родитель
bd58013fcd
коммит
46bf5129ab
3 изменённых файлов: 30 добавлений и 0 удалений
|
@ -138,3 +138,11 @@ func handleStarExpr(s *ast.StarExpr) (code string) {
|
||||||
}
|
}
|
||||||
return
|
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;
|
int c2 = 5;
|
||||||
double c3 = 5.5;
|
double c3 = 5.5;
|
||||||
std::string s1 = "privet";
|
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 += " = "
|
||||||
code += handleValueSpecValues(s.Values)
|
code += handleValueSpecValues(s.Values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, ok = s.Type.(*ast.ArrayType)
|
||||||
|
if ok {
|
||||||
|
code += "[]"
|
||||||
|
}
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +68,8 @@ func handleValueSpecType(expr ast.Expr) (code string) {
|
||||||
code += handleIdentExpr(t)
|
code += handleIdentExpr(t)
|
||||||
case *ast.StarExpr:
|
case *ast.StarExpr:
|
||||||
code += handleStarExpr(t)
|
code += handleStarExpr(t)
|
||||||
|
case *ast.ArrayType:
|
||||||
|
code += handleArray(t)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче