Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051package scanner
import ( "git.urbach.dev/cli/q/src/core" "git.urbach.dev/cli/q/src/errors" "git.urbach.dev/cli/q/src/fs" "git.urbach.dev/cli/q/src/token")
// scanGlobal scans a global.func (s *scanner) scanGlobal(file *fs.File, tokens token.List, i int) (int, error) { threadLocal := tokens[i].Kind == token.Local i++
if tokens[i].Kind != token.BlockStart { return i, errors.NewAt(MissingBlockStart, file, tokens[i].Position) }
i++ start := -1
for i < len(tokens) { switch tokens[i].Kind { case token.Identifier: if start == -1 { start = i } case token.NewLine, token.BlockEnd: if start != -1 { global := &core.Global{ Name: tokens[start].StringFrom(file.Bytes), Tokens: tokens[start:i], File: file, ThreadLocal: threadLocal, }
s.items <- global }
if tokens[i].Kind == token.BlockEnd { return i, nil }
start = -1 }
i++ }
return i, errors.NewAt(MissingBlockEnd, file, tokens[i-1].End())}