Added base for parsing initialization values
This commit is contained in:
parent
c172c111d8
commit
efb3bbe21b
@ -30,7 +30,11 @@ func (parser *ParsingOperation) parseDataSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
if parser.token.Is(lexer.TokenKindNewline) {
|
if parser.token.Is(lexer.TokenKindNewline) {
|
||||||
// TODO: parse arguments
|
err = parser.nextToken()
|
||||||
|
if err != nil { return }
|
||||||
|
|
||||||
|
section.value, err = parser.parseInitializationValues(0)
|
||||||
|
if err != nil { return }
|
||||||
} else {
|
} else {
|
||||||
var argument Argument
|
var argument Argument
|
||||||
argument, err = parser.parseArgument()
|
argument, err = parser.parseArgument()
|
||||||
@ -44,6 +48,29 @@ func (parser *ParsingOperation) parseDataSection () (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parseInitializationValues starts on the line after a data section, or a set
|
||||||
|
// phrase. It checks for an indent greater than the indent of the aforementioned
|
||||||
|
// data section or set phrase (passed through baseIndent), and if there is,
|
||||||
|
// it parses initialization values.
|
||||||
|
func (parser *ParsingOperation) parseInitializationValues (
|
||||||
|
baseIndent int,
|
||||||
|
) (
|
||||||
|
values []Argument,
|
||||||
|
err error,
|
||||||
|
) {
|
||||||
|
// check if line is indented one more than baseIndent
|
||||||
|
if !parser.token.Is(lexer.TokenKindIndent) { return }
|
||||||
|
if parser.token.Value().(int) != baseIndent + 1 { return }
|
||||||
|
|
||||||
|
if parser.token.Is(lexer.TokenKindDot) {
|
||||||
|
// TODO: parse as object initialization
|
||||||
|
} else {
|
||||||
|
// TODO: parse as array initialization
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// parseType parses a type notation of the form Name, {Name}, etc.
|
// parseType parses a type notation of the form Name, {Name}, etc.
|
||||||
func (parser *ParsingOperation) parseType () (what Type, err error) {
|
func (parser *ParsingOperation) parseType () (what Type, err error) {
|
||||||
err = parser.expect(lexer.TokenKindName, lexer.TokenKindLBrace)
|
err = parser.expect(lexer.TokenKindName, lexer.TokenKindLBrace)
|
||||||
@ -114,6 +141,8 @@ func (parser *ParsingOperation) parseIdentifier () (
|
|||||||
identifier.location = parser.token.Location()
|
identifier.location = parser.token.Location()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
// TODO: eat up newlines and tabs after the dot, but not before
|
||||||
|
// it.
|
||||||
if !parser.token.Is(lexer.TokenKindName) { break }
|
if !parser.token.Is(lexer.TokenKindName) { break }
|
||||||
|
|
||||||
identifier.trail = append (
|
identifier.trail = append (
|
||||||
|
@ -22,8 +22,8 @@ data wr integerPointerInit:{Int} [& integer]
|
|||||||
data wr mutIntegerPointerInit:{Int}:mut [& integer]
|
data wr mutIntegerPointerInit:{Int}:mut [& integer]
|
||||||
|
|
||||||
data wr object:Obj
|
data wr object:Obj
|
||||||
, this 324
|
.this 324
|
||||||
, that 2139
|
.that 2139
|
||||||
|
|
||||||
data wr nestedObject:Obj
|
data wr nestedObject:Obj
|
||||||
.this
|
.this
|
||||||
|
Reference in New Issue
Block a user