Literals call themselves literals instead of arg

This commit is contained in:
Sasha Koshka 2022-10-18 23:39:07 -04:00
parent 6dfde851e5
commit 8b4fee50ab
5 changed files with 31 additions and 29 deletions

View File

@ -6,15 +6,15 @@ func TestDataSection (test *testing.T) {
checkTree ("../tests/analyzer/dataSection", false, checkTree ("../tests/analyzer/dataSection", false,
`dataSection ro ../tests/analyzer/dataSection.aBasicInt `dataSection ro ../tests/analyzer/dataSection.aBasicInt
type 1 basic Int type 1 basic Int
arg uint 5 uintLiteral 5
dataSection ro ../tests/analyzer/dataSection.bRune dataSection ro ../tests/analyzer/dataSection.bRune
type 1 basic Int type 1 basic Int
arg string 'A' stringLiteral 'A'
dataSection ro ../tests/analyzer/dataSection.cString dataSection ro ../tests/analyzer/dataSection.cString
type 1 basic String type 1 basic String
arg string 'A very large bird' stringLiteral 'A very large bird'
dataSection ro ../tests/analyzer/dataSection.dCharBuffer dataSection ro ../tests/analyzer/dataSection.dCharBuffer
type 32 basic U8 type 32 basic U8
arg string 'A very large bird` + "\000" + `' stringLiteral 'A very large bird` + "\000" + `'
`, test) `, test)
} }

View File

@ -5,40 +5,40 @@ import "testing"
func TestEnumSection (test *testing.T) { func TestEnumSection (test *testing.T) {
checkTree ("../tests/analyzer/enumSection", false, checkTree ("../tests/analyzer/enumSection", false,
`enumSection ro ../tests/analyzer/enumSection.aWeekday `enumSection ro ../tests/analyzer/enumSection.aWeekday
arg uint 1 uintLiteral 1
type 1 basic Int type 1 basic Int
member sunday member sunday
arg uint 1 uintLiteral 1
member monday member monday
arg uint 2 uintLiteral 2
member tuesday member tuesday
arg uint 3 uintLiteral 3
member wednesday member wednesday
arg uint 4 uintLiteral 4
member thursday member thursday
arg uint 5 uintLiteral 5
member friday member friday
arg uint 6 uintLiteral 6
member saturday member saturday
arg uint 7 uintLiteral 7
typeSection ro ../tests/analyzer/enumSection.bColor typeSection ro ../tests/analyzer/enumSection.bColor
type 1 basic U32 type 1 basic U32
enumSection ro ../tests/analyzer/enumSection.cNamedColor enumSection ro ../tests/analyzer/enumSection.cNamedColor
arg uint 16711680 uintLiteral 16711680
type 1 basic bColor type 1 basic bColor
member red member red
arg uint 16711680 uintLiteral 16711680
member green member green
arg uint 65280 uintLiteral 65280
member blue member blue
arg uint 255 uintLiteral 255
enumSection ro ../tests/analyzer/enumSection.dFromFarAway enumSection ro ../tests/analyzer/enumSection.dFromFarAway
arg uint 5 uintLiteral 5
type 1 basic dInheritFromOther type 1 basic dInheritFromOther
member bird member bird
arg uint 5 uintLiteral 5
member bread member bread
arg uint 4 uintLiteral 4
typeSection ro ../tests/analyzer/typeSection/required.aBasic typeSection ro ../tests/analyzer/typeSection/required.aBasic
type 1 basic Int type 1 basic Int
typeSection ro ../tests/analyzer/typeSection.dInheritFromOther typeSection ro ../tests/analyzer/typeSection.dInheritFromOther

View File

@ -6,7 +6,9 @@ func TestFuncSection (test *testing.T) {
checkTree ("../tests/analyzer/funcSection", false, checkTree ("../tests/analyzer/funcSection", false,
` `
typeSection ro ../tests/analyzer/funcSection.aCString typeSection ro ../tests/analyzer/funcSection.aCString
type 1 pointer {Int} type 1 pointer {
type 1 basic U8
}
funcSection ro ../tests/analyzer/funcSection.bArbitrary funcSection ro ../tests/analyzer/funcSection.bArbitrary
block block
arbitraryPhrase arbitraryPhrase

View File

@ -28,7 +28,7 @@ type StringLiteral struct {
// ToString outputs the data in the argument as a string. // ToString outputs the data in the argument as a string.
func (literal IntLiteral) ToString (indent int) (output string) { func (literal IntLiteral) ToString (indent int) (output string) {
output += doIndent(indent, fmt.Sprint("arg int ", literal.value, "\n")) output += doIndent(indent, fmt.Sprint("intLiteral ", literal.value, "\n"))
return return
} }
@ -71,7 +71,7 @@ func (literal IntLiteral) canBePassedAs (what Type) (allowed bool) {
// ToString outputs the data in the argument as a string. // ToString outputs the data in the argument as a string.
func (literal UIntLiteral) ToString (indent int) (output string) { func (literal UIntLiteral) ToString (indent int) (output string) {
output += doIndent(indent, fmt.Sprint("arg uint ", literal.value, "\n")) output += doIndent(indent, fmt.Sprint("uintLiteral ", literal.value, "\n"))
return return
} }
@ -120,7 +120,7 @@ func (literal FloatLiteral) What () (what Type) {
// ToString outputs the data in the argument as a string. // ToString outputs the data in the argument as a string.
func (literal FloatLiteral) ToString (indent int) (output string) { func (literal FloatLiteral) ToString (indent int) (output string) {
output += doIndent(indent, fmt.Sprint("arg float ", literal.value, "\n")) output += doIndent(indent, fmt.Sprint("floatLiteral ", literal.value, "\n"))
return return
} }
@ -170,7 +170,7 @@ func (literal StringLiteral) What () (what Type) {
// ToString outputs the data in the argument as a string. // ToString outputs the data in the argument as a string.
func (literal StringLiteral) ToString (indent int) (output string) { func (literal StringLiteral) ToString (indent int) (output string) {
output += doIndent(indent, fmt.Sprint("arg string '", literal.value, "'\n")) output += doIndent(indent, fmt.Sprint("stringLiteral '", literal.value, "'\n"))
return return
} }

View File

@ -10,10 +10,10 @@ typeSection ro ../tests/analyzer/typeSection/required.bBird
type 1 basic Obj type 1 basic Obj
member rw wing member rw wing
type 1 basic Int type 1 basic Int
arg uint 2 uintLiteral 2
typeSection ro ../tests/analyzer/typeSection.aBasicInt typeSection ro ../tests/analyzer/typeSection.aBasicInt
type 1 basic Int type 1 basic Int
arg uint 5 uintLiteral 5
typeSection ro ../tests/analyzer/typeSection.bOnBasicInt typeSection ro ../tests/analyzer/typeSection.bOnBasicInt
type 1 basic aBasicInt type 1 basic aBasicInt
typeSection ro ../tests/analyzer/typeSection.cBasicObject typeSection ro ../tests/analyzer/typeSection.cBasicObject
@ -28,15 +28,15 @@ typeSection ro ../tests/analyzer/typeSection.eInheritObject
type 1 basic cBasicObject type 1 basic cBasicObject
member ro that member ro that
type 1 basic UInt type 1 basic UInt
arg uint 5 uintLiteral 5
typeSection ro ../tests/analyzer/typeSection.fInheritObjectFromOther typeSection ro ../tests/analyzer/typeSection.fInheritObjectFromOther
type 1 basic bBird type 1 basic bBird
member ro wing member ro wing
type 1 basic Int type 1 basic Int
arg uint 2 uintLiteral 2
member ro beak member ro beak
type 1 basic Int type 1 basic Int
arg uint 238 uintLiteral 238
typeSection ro ../tests/analyzer/typeSection.gPointer typeSection ro ../tests/analyzer/typeSection.gPointer
type 1 pointer { type 1 pointer {
type 1 basic Int type 1 basic Int