summaryrefslogtreecommitdiff
path: root/test/self/lexer.mnml
blob: 8468f665bc9ad054d72a33763094a2ee34845111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const main: function = (input: string): array {
	return lex(input = input, position = 0, output = [])
}

const lex: function = (input: string, position: integer, output: array): array {
	if (position == (strlen(input))) {
		return output
	}

	const current_char: string = get_char(input, position)

	const appended_output: array
	if (current_char != " ") {
		appended_output = array_append(output, current_char)
	} else {
		appended_output = output
	}

	return lex(input = input, position = (position + 1), output = appended_output)
}

main(input = "a b c d e f g") => dump($)