not tryna work on this on my laptop rn

This commit is contained in:
Sasha Koshka 2022-09-15 22:43:02 -04:00
parent eaeba12fbe
commit 319b60bfcd
3 changed files with 102 additions and 30 deletions

View File

@ -12,25 +12,55 @@ data ro cIntegerPointer:{Int}
data ro dMutIntegerPointer:{Int}:mut
data ro eIntegerArray16:Int:16
data ro fIntegerArrayVariable:{Int ..}
data ro gIntegerArrayInitialized:Int:16:<
3948 293 293049 948 912
340 0 2304 0 4785 92>
data ro jObject:Obj:(
data ro gIntegerArrayInitialized:Int:16:
<
3948
293
293049
948
912
340
0
2304
0
4785
92
>
data ro jObject:Obj:
(
.this:<324>
.that:<324>)
data ro kNestedObject:Obj:(
.that:<324>
)
data ro kNestedObject:Obj:
(
.ro newMember:Int:<9023>
.this:(
.this:
(
.bird0:<324>
.bird1:<"hello world">)
.that:(
.bird1:<"hello world">
)
.that:
(
.bird2:<123.8439>
.bird3:<9328.21348239>))
.bird3:<9328.21348239>
)
)
data ro lMutIntegerArray16:Int:16:mut
data ro mExternalData:Int:8
external
data ro nIntegerArrayInitialized:Int:16:mut:<
3948 293 293049 948 912
340 0 2304 0 4785 92>
data ro nIntegerArrayInitialized:Int:16:mut:
<
3948
293
293049
948
912
340
0
2304
0
4785
92
>
`, test)
}

View File

@ -66,12 +66,22 @@ func (identifier Identifier) ToString () (output string) {
return
}
func (what Type) ToString () (output string) {
func (values ObjectDefaultValues) ToString (indent int) (output string) {
return
}
func (values ArrayDefaultValues) ToString (indent int) (output string) {
return
}
func (what Type) ToString (indent int) (output string) {
if what.kind == TypeKindBasic {
output += what.name.ToString()
} else {
output += "{"
output += what.points.ToString()
output += what.points.ToString(indent)
if what.kind == TypeKindVariableArray {
output += " .."
@ -88,13 +98,38 @@ func (what Type) ToString () (output string) {
output += ":mut"
}
// TODO: print out default value
if what.members != nil {
output += ":("
for _, member := range what.members {
output += doIndent (
indent,
"\n" + member.ToString(indent + 1))
}
output += ")"
}
defaultValueKind := what.defaultValue.kind
if defaultValueKind != ArgumentKindNil {
isComplexDefaultValue :=
defaultValueKind == ArgumentKindObjectDefaultValues ||
defaultValueKind == ArgumentKindArrayDefaultValues
if isComplexDefaultValue {
output += ":\n"
output += what.defaultValue.ToString(indent, true)
}
}
if what.defaultValue.kind == ArgumentKindObjectDefaultValues {
} else if what.defaultValue.kind != ArgumentKindNil {
output += ":<" + what.defaultValue.ToString(indent, true) + ">"
}
return
}
func (declaration Declaration) ToString () (output string) {
func (declaration Declaration) ToString (indent int) (output string) {
output += declaration.name + ":"
output += declaration.what.ToString()
output += declaration.what.ToString(indent)
return
}
@ -112,8 +147,13 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) {
indent,
breakLine)
case ArgumentKindArrayDefaultValues, ArgumentKindObjectDefaultValues:
output += "DEFAULT VALUES IN WRONG PLACE"
case ArgumentKindObjectDefaultValues:
output += argument.value.(ObjectDefaultValues).
ToString(indent)
case ArgumentKindArrayDefaultValues:
output += argument.value.(ArrayDefaultValues).
ToString(indent)
case ArgumentKindIdentifier:
output += doIndent (
@ -124,7 +164,7 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) {
case ArgumentKindDeclaration:
output += doIndent (
indent,
argument.value.(Declaration).ToString())
argument.value.(Declaration).ToString(indent))
if breakLine { output += "\n" }
case ArgumentKindInt, ArgumentKindUInt, ArgumentKindFloat:
@ -222,7 +262,7 @@ func (section DataSection) ToString (indent int) (output string) {
"type ",
section.permission.ToString(), " ",
section.name, ":",
section.what.ToString(), "\n")
section.what.ToString(indent), "\n")
return
}
@ -231,7 +271,7 @@ func (member TypeMember) ToString (indent int) (output string) {
output += member.permission.ToString() + " "
output += member.name + ":"
output += member.what.ToString()
output += member.what.ToString(indent)
if member.bitWidth > 0 {
output += fmt.Sprint(" & ", member.bitWidth)
@ -248,7 +288,7 @@ func (section TypeSection) ToString (indent int) (output string) {
"type ",
section.permission.ToString(), " ",
section.name, ":",
section.what.ToString(), "\n")
section.what.ToString(indent), "\n")
return
}
@ -259,7 +299,7 @@ func (section EnumSection) ToString (indent int) (output string) {
"enum ",
section.permission.ToString(), " ",
section.name, ":",
section.what.ToString(), "\n")
section.what.ToString(indent), "\n")
for _, member := range section.members {
output += doIndent(indent + 1, member.name)
@ -300,11 +340,11 @@ func (behavior FaceBehavior) ToString (indent int) (output string) {
output += doIndent(indent, behavior.name, "\n")
for _, inputItem := range behavior.inputs {
output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n")
output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n")
}
for _, outputItem := range behavior.outputs {
output += doIndent(indent + 1, "< ", outputItem.ToString(), "\n")
output += doIndent(indent + 1, "< ", outputItem.ToString(indent), "\n")
}
return
@ -368,7 +408,7 @@ func (block Block) ToString (indent int) (output string) {
func (funcOutput FuncOutput) ToString (indent int) (output string) {
output += doIndent (
indent + 1,
"< ", funcOutput.Declaration.ToString(), "\n")
"< ", funcOutput.Declaration.ToString(indent), "\n")
return
}
@ -382,11 +422,11 @@ func (section FuncSection) ToString (indent int) (output string) {
if section.receiver != nil {
output += doIndent (
indent + 1,
"@ ", section.receiver.ToString(), "\n")
"@ ", section.receiver.ToString(indent), "\n")
}
for _, inputItem := range section.inputs {
output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n")
output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n")
}
for _, outputItem := range section.outputs {

View File

@ -285,6 +285,8 @@ func (parser *ParsingOperation) parseObjectNewMember () (
if err != nil { return }
member.what, err = parser.parseType()
if err != nil { return }
// TODO: get bit width
return
}