Added file name + line number to symbols and use it for reasonable error handling now, added a version number to the compiled grammer

This commit is contained in:
Nathan Braswell
2016-04-05 03:14:56 -04:00
parent 0e9fff705b
commit 38ec4abc01
7 changed files with 111 additions and 54 deletions

View File

@@ -85,7 +85,14 @@ obj lexer (Object) {
if (max < 0)
return symbol::invalid_symbol()
position += max_length
return symbol::symbol(regs[max].first, true, input.slice(position-max_length, position))
var line_number = fun(str: ref string::string, pos: int): int {
var line_no = 1
for (var i = 0; i < pos; i++;)
if (str[i] == '\n')
line_no++
return line_no
}
return symbol::symbol(regs[max].first, true, input.slice(position-max_length, position), line_number(input, position))
}
}