Added parsing array initialization values
This commit is contained in:
parent
210e527b3a
commit
bb2948d397
@ -61,16 +61,51 @@ func (parser *ParsingOperation) parseInitializationValues (
|
||||
// check if line is indented one more than baseIndent
|
||||
if !parser.token.Is(lexer.TokenKindIndent) { return }
|
||||
if parser.token.Value().(int) != baseIndent + 1 { return }
|
||||
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
if parser.token.Is(lexer.TokenKindDot) {
|
||||
// TODO: parse as object initialization
|
||||
} else {
|
||||
// TODO: parse as array initialization
|
||||
values, err = parser.parseArrayInitializationValues (
|
||||
baseIndent + 1)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parseArrayInitializationValues parses a list of array initialization values
|
||||
// until the indentation lexel is not equal to indent.
|
||||
func (parser *ParsingOperation) parseArrayInitializationValues (
|
||||
indent int,
|
||||
) (
|
||||
values []Argument,
|
||||
err error,
|
||||
) {
|
||||
for {
|
||||
if parser.token.Is(lexer.TokenKindNewline) {
|
||||
println("line break")
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
if !parser.token.Is(lexer.TokenKindIndent) { break }
|
||||
if parser.token.Value().(int) != indent { break }
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
}
|
||||
if err != nil { return }
|
||||
println(parser.token.Describe())
|
||||
|
||||
var argument Argument
|
||||
argument, err = parser.parseArgument()
|
||||
if err != nil { return }
|
||||
values = append(values, argument)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parseType parses a type notation of the form Name, {Name}, etc.
|
||||
func (parser *ParsingOperation) parseType () (what Type, err error) {
|
||||
err = parser.expect(lexer.TokenKindName, lexer.TokenKindLBrace)
|
||||
|
@ -17,9 +17,9 @@ data wr integerArrayInitialized:{Int 16}
|
||||
3948 293 293049 948 912
|
||||
340 0 2304 0 4785 92
|
||||
|
||||
data wr integerPointerInit:{Int} [& integer]
|
||||
data wr integerPointerInit:{Int} #[& integer]
|
||||
|
||||
data wr mutIntegerPointerInit:{Int}:mut [& integer]
|
||||
data wr mutIntegerPointerInit:{Int}:mut #[& integer]
|
||||
|
||||
data wr object:Obj
|
||||
.this 324
|
||||
|
Reference in New Issue
Block a user