Data sections can now be marked as external

This commit is contained in:
Sasha Koshka 2022-09-05 14:09:47 -04:00
parent 345cf3fa29
commit 2295e3bd32
6 changed files with 38 additions and 3 deletions

View File

@ -197,6 +197,12 @@ func (section FaceSection) Behaviors () (iterator types.Iterator[FaceBehavior])
return
}
// External returns whether or not the data section is external.
func (section DataSection) External () (external bool) {
external = section.external
return
}
// Kind returns what kind of phrase it is.
func (phrase Phrase) Kind () (kind PhraseKind) {
kind = phrase.kind

View File

@ -32,6 +32,25 @@ func (parser *ParsingOperation) parseDataSection () (
err = parser.nextToken()
if err != nil { return }
// check if external
if !parser.token.Is(lexer.TokenKindIndent) { return }
if parser.token.Value().(int) != 1 { return }
err = parser.nextToken()
if err != nil { return }
if parser.token.Is(lexer.TokenKindName) &&
parser.token.Value().(string) == "external" {
section.external = true
err = parser.nextToken(lexer.TokenKindNewline)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
return
}
// otherwise, parse initialization values
parser.previousToken()
section.value, err = parser.parseInitializationValues(0)
if err != nil { return }
} else {

View File

@ -35,7 +35,9 @@ data ro kNestedObject:Obj
.bird0 324
.bird1 "hello world"
data ro lMutIntegerArray16:Int:16:mut
data ro mIntegerArrayInitialized:Int:16:mut
data ro mExternalData:Int:8
external
data ro nIntegerArrayInitialized:Int:16:mut
3948
293
293049

View File

@ -266,7 +266,10 @@ func (section DataSection) ToString (indent int) (output string) {
section.value.kind == ArgumentKindObjectInitializationValues ||
section.value.kind == ArgumentKindArrayInitializationValues
if section.value.value == nil {
if section.external {
output += "\n"
output += doIndent(indent + 1, "external\n")
} else if section.value.value == nil {
output += "\n"
} else if isComplexInitialization {
output += "\n"

View File

@ -169,6 +169,8 @@ type DataSection struct {
typeable
permissionable
valuable
external bool
}
// TypeSection represents a blind type definition.

View File

@ -38,6 +38,9 @@ data ro kNestedObject:Obj
data ro lMutIntegerArray16:Int:16:mut
data ro mIntegerArrayInitialized: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