Сценарий: Блок переменных
Этот коммит содержится в:
родитель
0addf00c20
коммит
bd58013fcd
3 изменённых файлов: 24 добавлений и 8 удалений
|
@ -19,4 +19,23 @@ const int c1 = 4;
|
|||
const int c2 = 5;
|
||||
const double c3 = 5.5;
|
||||
const std::string s1 = "privet";
|
||||
```
|
||||
|
||||
Сценарий: Блок переменных
|
||||
* Исходник:
|
||||
```
|
||||
package test
|
||||
var (
|
||||
c1 = 4
|
||||
c2 = 5
|
||||
c3 = 5.5
|
||||
s1 = "privet"
|
||||
)
|
||||
```
|
||||
* Результат:
|
||||
```
|
||||
int c1 = 4;
|
||||
int c2 = 5;
|
||||
double c3 = 5.5;
|
||||
std::string s1 = "privet";
|
||||
```
|
||||
|
|
|
@ -21,11 +21,10 @@ func handleGenDecl(decl ast.Decl) string {
|
|||
return code
|
||||
}
|
||||
|
||||
func handleSpecs(specs []ast.Spec) string {
|
||||
code := ""
|
||||
func handleSpecs(specs []ast.Spec) (code string) {
|
||||
for _, spec := range specs {
|
||||
if InConstBlock {
|
||||
code += "const"
|
||||
code += "const "
|
||||
}
|
||||
|
||||
switch s := spec.(type) {
|
||||
|
@ -37,7 +36,7 @@ func handleSpecs(specs []ast.Spec) string {
|
|||
code += handleTypeSpec(spec)
|
||||
}
|
||||
}
|
||||
return code
|
||||
return
|
||||
}
|
||||
|
||||
func handleImportSpec(spec ast.Spec) string {
|
||||
|
|
|
@ -35,7 +35,6 @@ func addTypeByValue(s *ast.ValueSpec) (code string) {
|
|||
|
||||
switch v := value.(type) {
|
||||
case *ast.BasicLit:
|
||||
code += " "
|
||||
code += handleBasicLitType(v)
|
||||
}
|
||||
return
|
||||
|
@ -56,8 +55,7 @@ func handleValueSpecNames(names []*ast.Ident) (code string) {
|
|||
return
|
||||
}
|
||||
|
||||
func handleValueSpecType(expr ast.Expr) string {
|
||||
code := ""
|
||||
func handleValueSpecType(expr ast.Expr) (code string) {
|
||||
switch t := expr.(type) {
|
||||
case *ast.SelectorExpr:
|
||||
code += handleSelectorExpr(t)
|
||||
|
@ -66,7 +64,7 @@ func handleValueSpecType(expr ast.Expr) string {
|
|||
case *ast.StarExpr:
|
||||
code += handleStarExpr(t)
|
||||
}
|
||||
return code
|
||||
return
|
||||
}
|
||||
|
||||
func handleValueSpecValues(values []ast.Expr) string {
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче