-
-
Save BitPuffin/c9e6514bbaa9f9952ebe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ yig } » ssh BitPuffin@hub.darcs.net ~/src/yig 130 | |
Enter passphrase for key '/home/usefulProgrammer/.ssh/id_rsa': | |
PTY allocation request failed on channel 0 | |
shell request failed on channel 0 | |
{ yig } » darcs push --debug-verbose ~/src/yig 255 | |
Beginning identifying repository . | |
Done identifying repository . | |
Identified darcs-2 repo: C:/Users/usefulProgrammer/.babun/cygwin/home/usefulProgrammer/src/yig | |
Beginning identifying repository bitpuffin@hub.darcs.net:yig | |
copySSH file: BitPuffin@hub.darcs.net:yig//_darcs/format | |
Disabling progress reports... | |
ssh BitPuffin@hub.darcs.net darcs transfer-mode --repodir yig/ | |
Failed to start ssh connection: | |
fd:4: hGetLine: end of file | |
Severing ssh failed connection to BitPuffin@hub.darcs.net | |
NOTE: the server may be running a version of darcs prior to 2.0.0. | |
Installing darcs 2 on the server will speed up ssh-based commands. | |
Disabling progress reports... | |
Enter passphrase for key '/home/usefulProgrammer/.ssh/id_rsa': | |
Leaving progress reports off. | |
Reenabling progress reports. | |
Done identifying repository bitpuffin@hub.darcs.net:yig | |
copySSH file: BitPuffin@hub.darcs.net:yig//_darcs/prefs/sources | |
Disabling progress reports... | |
ssh BitPuffin@hub.darcs.net darcs transfer-mode --repodir yig/ | |
Failed to start ssh connection: | |
fd:4: hGetLine: end of file | |
Severing ssh failed connection to BitPuffin@hub.darcs.net | |
NOTE: the server may be running a version of darcs prior to 2.0.0. | |
Installing darcs 2 on the server will speed up ssh-based commands. | |
Disabling progress reports... | |
Enter passphrase for key '/home/usefulProgrammer/.ssh/id_rsa': | |
/home/darcsden/users/BitPuffin/yig//_darcs/prefs/sources: canonicalizePath: does not exist (No such file or directory) | |
Leaving progress reports off. | |
(scp) failed to fetch: BitPuffin@hub.darcs.net:yig//_darcs/prefs/sources | |
copySSH file: BitPuffin@hub.darcs.net:yig//_darcs/hashed_inventory | |
Disabling progress reports... | |
ssh BitPuffin@hub.darcs.net darcs transfer-mode --repodir yig/ | |
Failed to start ssh connection: | |
fd:4: hGetLine: end of file | |
Severing ssh failed connection to BitPuffin@hub.darcs.net | |
NOTE: the server may be running a version of darcs prior to 2.0.0. | |
Installing darcs 2 on the server will speed up ssh-based commands. | |
Disabling progress reports... | |
Enter passphrase for key '/home/usefulProgrammer/.ssh/id_rsa': | |
Leaving progress reports off. | |
Reenabling progress reports. | |
Reading patch file: Fri Jan 23 00:35:48 Eur 2015 contact@bitpuffin.com | |
* Add lybi to repository. It can currently lex numbers, strings and characters. It ignores comments too | |
I'm doing copyFileUsingCache on patches/0000024823-81e36386ba9b8e52e56ca6e2136a15ea6e0bc9e19dc9e6fa7bfc337249cd3dc8 | |
Pushing to "BitPuffin@hub.darcs.net:yig"... | |
Detecting SSH settings | |
SSH settings (plink): plink: readProcessWithExitCode: does not exist (No such file or directory) | |
SSH settings: SshSettings {ssh = "ssh", scp = "scp -q", sftp = "sftp"} | |
scp -q BitPuffin@hub.darcs.net:yig//_darcs/format .\darcs12568 ; # AsIs AsIs AsIs | |
scp -q BitPuffin@hub.darcs.net:yig//_darcs/prefs/sources .\darcs12568 ; # AsIs AsIs AsIs | |
scp -q BitPuffin@hub.darcs.net:yig//_darcs/hashed_inventory .\darcs12568 ; # AsIs AsIs AsIs | |
We have the following patches to push: | |
Wed Jan 28 14:16:02 Eur 2015 contact@bitpuffin.com | |
* Make test code much much much shorter, and fix a bug that was discovered in the process causing column number to be wrong when using block comments | |
Tue Jan 27 13:34:44 Eur 2015 contact@bitpuffin.com | |
* yep, more tests | |
Tue Jan 27 12:57:20 Eur 2015 contact@bitpuffin.com | |
* Write failed tests to stderr for stream redirection | |
Tue Jan 27 12:52:30 Eur 2015 contact@bitpuffin.com | |
* Some source code annotation | |
Tue Jan 27 12:48:38 Eur 2015 contact@bitpuffin.com | |
* fix bug which recognized 123iu as a valid number | |
Tue Jan 27 12:38:12 Eur 2015 contact@bitpuffin.com | |
* More tests, some bugfixing too thanks to tests, such as negative unsigned numbers that have specified bit count | |
Fri Jan 23 13:25:28 Eur 2015 contact@bitpuffin.com | |
* Add a bunch of tests for hex, octal and binary numbers and fix a bug that was discovered doing so | |
Fri Jan 23 00:35:48 Eur 2015 contact@bitpuffin.com | |
* Add lybi to repository. It can currently lex numbers, strings and characters. It ignores comments too | |
Fri Jan 23 00:35:48 Eur 2015 contact@bitpuffin.com | |
* Add lybi to repository. It can currently lex numbers, strings and characters. It ignores comments too | |
adddir ./lybi | |
addfile ./lybi/lybi.lua | |
hunk ./lybi/lybi.lua 1 | |
+-------------------------------------------------------------------------------- | |
+-- Lua Yig Bootstrapping Interpreter | |
+-- | |
+-- Author: Isak Andersson 2015 | |
+-- | |
+-- This file is in the public domain. | |
+-- If you reside in a jurisdiction where | |
+-- copyrights cannot be waived you may | |
+-- use CC0. See COPYING.txt in project | |
+-- root or: | |
+-- | |
+-- + http://creativecommons.org/publicdomain/zero/1.0/legalcode.txt | |
+-- | |
+-- Enjoy! | |
+ | |
+function string.startswith(s, w, idx) | |
+ if idx == nil then idx = 1 end | |
+ return string.sub(s, idx, string.len(w) + idx - 1) == w | |
+end | |
+ | |
+function string.at(s, i) | |
+ return string.sub(s, i, i) | |
+end | |
+ | |
+local function iswithinrangeofchars(c, a, b) | |
+ local beginning = string.byte(a) | |
+ local ending = string.byte(b) | |
+ local byte = string.byte(c) | |
+ return byte >= beginning and byte <= ending | |
+end | |
+ | |
+function string.isdigit(s) | |
+ if s == "" then return false end | |
+ return iswithinrangeofchars(s, "0", "9") | |
+end | |
+ | |
+function string.isalnum(s) | |
+ return iswithinrangeofchars(s, "0", "z") | |
+end | |
+ | |
+function string.isalpha(s) | |
+ return iswithinrangeofchars(s, "A", "z") | |
+end | |
+ | |
+function string.isspace(s) | |
+ return s == " " or s == "\n" or s == "\t" | |
+end | |
+ | |
+local token_kinds = { | |
+ reserved = "reserved", | |
+ symbol = "symbol", | |
+ character = "character", | |
+ string = "string", | |
+ integer = "integer", | |
+ uinteger = "uinteger", | |
+ float = "float", | |
+ integer8 = "integer8", | |
+ integer16 = "integer16", | |
+ integer32 = "integer32", | |
+ integer64 = "integer64", | |
+ uinteger8 = "uinteger8", | |
+ uinteger16 = "uinteger16", | |
+ uinteger32 = "uinteger32", | |
+ uinteger64 = "uinteger64", | |
+ float32 = "float32", | |
+ float64 = "float64" | |
+} | |
+ | |
+local token_operators = { | |
+ begin_container = "[", | |
+ end_container = "]", | |
+ separator_comma = ",", | |
+ separator_double_pipe = "||", | |
+ separator_pipe = "|", | |
+ symbol_in_container = "::", | |
+ access_by_key = ":", | |
+ symbol_in_parent_container = "..::", | |
+ access_by_key_in_parent_container = "..:", | |
+ access_in_parent_container = "..", | |
+ access = ".", | |
+ quote = "`", | |
+ unquote = "[_<U+00C2>_][_<U+00B4>_]", | |
+} | |
+ | |
+-- Lua doesn't allow me to do { in = "in" } -_- | |
+local reserved_keywords = {} | |
+reserved_keywords["in"] = "in" | |
+reserved_keywords["as"] = "as" | |
+ | |
+local function create_token(k, v, l, c) | |
+ return { kind = k, value = v, line = l, column = c } | |
+end | |
+ | |
+local function lex(str) | |
+ local row = 1 | |
+ local col = 1 | |
+ local strlen = #str | |
+ local tokens = {} | |
+ | |
+ local function lex_error(msg, l, c) | |
+ error(msg .. ". Line: " .. l .. " Column: " .. c) | |
+ end | |
+ | |
+ local function lex_at(idx) | |
+ if idx > strlen then return end | |
+ | |
+ local c = string.at(str, idx) | |
+ | |
+ -- Whitespace | |
+ if string.isspace(c) then | |
+ if c == "\n" then | |
+ row = row + 1 | |
+ col = 1 | |
+ return lex_at(idx + 1) | |
+ end | |
+ col = col + 1 | |
+ return lex_at(idx + 1) | |
+ end | |
+ | |
+ local next_char = string.at(str, idx + 1) | |
+ | |
+ -- Comments | |
+ if c == "#" then | |
+ local end_of_comment = string.find(str, "\n", idx + 1, true) | |
+ if end_of_comment == nil then | |
+ return -- We never reached a newline so it must be the end of the file | |
+ end | |
+ col = 1 | |
+ row = row +1 | |
+ return lex_at(end_of_comment) | |
+ end | |
+ | |
+ if c == "(" and next_char == "#" then | |
+ local nest_level = 1 | |
+ local function iterate(i) | |
+ local c = string.at(str, i) | |
+ local next_char = string.at(str, i + 1) | |
+ if c == "(" and next_char == "#" then | |
+ nest_level = nest_level + 1 | |
+ col = col + 2 | |
+ return iterate(i + 2) | |
+ elseif c == "#" and next_char == ")" then | |
+ nest_level = nest_level - 1 | |
+ col = col + 2 | |
+ if nest_level < 1 then | |
+ return lex_at(i + 2) | |
+ end | |
+ return iterate(i + 2) | |
+ elseif c == "\n" then | |
+ col = 1 | |
+ row = row + 1 | |
+ elseif c == "" then | |
+ return -- eof? | |
+ else | |
+ col = col + 1 | |
+ end | |
+ return iterate(i + 1) | |
+ end | |
+ iterate(idx + 2) | |
+ end | |
+ | |
+ -- Numbers | |
+ local is_digit = string.isdigit(c) | |
+ local num_is_negative = c == "-" | |
+ if is_digit or (num_is_negative and string.isdigit(next_char)) then | |
+ local lit_len = 0 | |
+ local lit_types = { decimal = 0, hex = 1, octal = 2, binary = 3 } | |
+ local lit_type = lit_types.decimal | |
+ local token_kind = token_kinds.integer | |
+ local end_junk = 0 | |
+ | |
+ local function figure_out_num_and_length(s) | |
+ local length = 0 | |
+ local dot_found = false | |
+ local first_digit = string.at(s, 1) | |
+ | |
+ local function is_end_of_num(i) | |
+ if string.at(s, i) == "" then return true end | |
+ return not string.isalnum(string.at(s, i)) | |
+ end | |
+ | |
+ local function assert_end_of_num(i) | |
+ if not is_end_of_num(i) then | |
+ lex_error("Invalid number literal", row, col) | |
+ end | |
+ end | |
+ | |
+ local function iterate(i) | |
+ length = length + 1 | |
+ local c = string.at(s, i) | |
+ if string.isdigit(c) or c == "_" then | |
+ return iterate(i + 1) | |
+ elseif i == 2 and (c == "o" or c == "x" or c == "b") then | |
+ if not (first_digit == "0") then | |
+ lex_error("First digit of octal, hex, or binary numbers needs to be 0", row, col) | |
+ end | |
+ if c == "x" then | |
+ lit_type = lit_types.hex | |
+ elseif c == "o" then | |
+ lit_type = lit_types.octal | |
+ elseif c == "b" then | |
+ lit_type = lit_types.binary | |
+ end | |
+ | |
+ return iterate(i + 1) | |
+ elseif c == "." then | |
+ if dot_found then | |
+ lex_error("You can't have two decimal points in your number", row, col) | |
+ end | |
+ | |
+ dot_found = true | |
+ token_kind = token_kinds.float | |
+ return iterate(i + 1) | |
+ elseif (c == "i" or c == "u") then | |
+ if dot_found then | |
+ lex_error("Integer can not have a fractional part", row, col) | |
+ end | |
+ local n = string.at(s, i + 1) | |
+ if not (string.isdigit(n) or n == "_") then | |
+ if c == "i" then | |
+ token_kind = token_kinds.integer | |
+ else | |
+ token_kind = token_kinds.uinteger | |
+ if num_is_negative then | |
+ lex_error("Unsigned integer can not be negative", row, col) | |
+ end | |
+ end | |
+ length = length + 1 | |
+ end_junk = 1 | |
+ return | |
+ end | |
+ local nn = string.at(s, i + 2) | |
+ if n == "8" then | |
+ if string.isdigit(nn) then | |
+ lex_error(n .. nn .. " is not a valid integer size", row, col) | |
+ end | |
+ assert_end_of_num(i + 2) | |
+ length = length + 2 | |
+ end_junk = 2 | |
+ if c == "i" then | |
+ token_kind = token_kinds.integer8 | |
+ else | |
+ token_kind = token_kinds.uinteger8 | |
+ end | |
+ return | |
+ elseif n == "1" and nn == "6" then | |
+ assert_end_of_num(i + 3) | |
+ length = length + 3 | |
+ end_junk = 3 | |
+ if c == "i" then | |
+ token_kind = token_kinds.integer16 | |
+ else | |
+ token_kind = token_kinds.uinteger16 | |
+ end | |
+ return | |
+ elseif n == "3" and nn == "2" then | |
+ assert_end_of_num(i + 3) | |
+ length = length + 3 | |
+ end_junk = 3 | |
+ if c == "i" then | |
+ token_kind = token_kinds.integer32 | |
+ else | |
+ token_kind = token_kinds.uinteger32 | |
+ end | |
+ return | |
+ elseif n == "6" and nn == "4" then | |
+ assert_end_of_num(i + 3) | |
+ length = length + 3 | |
+ end_junk = 3 | |
+ if c == "i" then | |
+ token_kind = token_kinds.integer64 | |
+ else | |
+ token_kind = token_kinds.uinteger64 | |
+ end | |
+ return | |
+ else | |
+ lex_error(n .. nn .. " is not a valid integer size", row, col) | |
+ end | |
+ elseif c == "f" then | |
+ local n = string.at(s, i + 1) | |
+ if not (string.isdigit(n) or n == "_") then | |
+ token_kind = token_kinds.float | |
+ return | |
+ end | |
+ local nn = string.at(s, i + 2) | |
+ assert_end_of_num(i + 3) | |
+ length = length + 2 | |
+ end_junk = 2 | |
+ if n == "3" and nn == "2" then | |
+ token_kind = token_kinds.float32 | |
+ elseif n == "6" and nn == "4" then | |
+ token_kind = token_kinds.float64 | |
+ else | |
+ lex_error(n .. nn .. " is not a valid float size", row, col) | |
+ end | |
+ return | |
+ elseif lit_type == lit_types.hex and (iswithinrangeofchars(c, "a", "f") or | |
+ iswithinrangeofchars(c, "A", "F")) then | |
+ return iterate(i + 1) | |
+ elseif not is_end_of_num(i) then | |
+ lex_error(c .. " is not allowed in a number literal (at that position)", row, col) | |
+ end | |
+ end | |
+ length = length - 1 | |
+ iterate(1) | |
+ return length | |
+ end | |
+ | |
+ if not (lit_type == lit_types.decimal or lit_type == lit_types.hex) | |
+ and (token_kind == token_kinds.float or | |
+ token_kind == token_kinds.float32 or | |
+ token_kind == token_kinds.float64) then | |
+ lex_error("Floating point numbers must be base 10 or 16 at the moment", row, col) | |
+ end | |
+ | |
+ if num_is_negative then idx = idx + 1 end | |
+ substr = string.sub(str, idx) | |
+ local lit_len = figure_out_num_and_length(substr) | |
+ local numlit = string.sub(substr, 1, lit_len) | |
+ numlit = string.gsub(numlit, "_", "") | |
+ numlit = string.sub(numlit, 1, #numlit - end_junk) | |
+ local number_value = 0 | |
+ | |
+ if lit_type == lit_types.octal then | |
+ numlit = string.sub(numlit, 3) | |
+ local lit_len = #numlit | |
+ for i = 0, lit_len - 1 do | |
+ local n = string.at(numlit, lit_len - i) | |
+ local nint = tonumber(n) | |
+ if nint > 7 then | |
+ lex_error("Octal numbers cannot have a number greater than 7", row, col) | |
+ end | |
+ number_value = number_value + nint * 8 ^ i | |
+ end | |
+ number_value = math.tointeger(number_value) | |
+ elseif lit_type == lit_types.binary then | |
+ numlit = string.sub(numlit, 3) | |
+ local lit_len = #numlit | |
+ for i = 0, lit_len - 1 do | |
+ local n = string.at(numlit, lit_len - i) | |
+ local nint = tonumber(n) | |
+ if nint > 1 then | |
+ lex_error("Binary numbers cannot have a number greater than 1 in them", row, col) | |
+ end | |
+ number_value = number_value + nint * 2 ^ i | |
+ end | |
+ number_value = math.tointeger(number_value) | |
+ else | |
+ number_value = tonumber(numlit) | |
+ end | |
+ if num_is_negative then number_value = -number_value end | |
+ | |
+ table.insert(tokens, create_token(token_kind, number_value, row, col)) | |
+ col = col + lit_len | |
+ return lex_at(idx + lit_len) | |
+ end | |
+ | |
+ local function deal_with_escape_sequences(s, cha) | |
+ if cha then | |
+ s = string.gsub(s, "\\'", "'") | |
+ else | |
+ s = string.gsub(s, "\\\"", "\"") | |
+ end | |
+ s = string.gsub(s, "\\\\", "\\") | |
+ s = string.gsub(s, "\\a", "\a") | |
+ s = string.gsub(s, "\\b", "\b") | |
+ s = string.gsub(s, "\\f", "\f") | |
+ s = string.gsub(s, "\\n", "\n") | |
+ s = string.gsub(s, "\\r", "\r") | |
+ s = string.gsub(s, "\\t", "\t") | |
+ s = string.gsub(s, "\\v", "\v") | |
+ return s | |
+ end | |
+ | |
+ -- Characters | |
+ if c == "'" then | |
+ local lit_len = 1 | |
+ local function iterate(i) | |
+ local c = string.at(str, i) | |
+ if c == "\n" then | |
+ lex_error("Newlines not allowed in character literals, use \\n instead", row, col) | |
+ elseif c == "\\" then | |
+ lit_len = lit_len + 2 | |
+ return iterate(i + 2) | |
+ elseif c == "" then | |
+ lex_error("Character literal was never terminated", row, col) | |
+ elseif c == "'" then return end | |
+ lit_len = lit_len + 1 | |
+ return iterate(i + 1) | |
+ end | |
+ iterate(idx + 1) | |
+ if lit_len > 3 or (lit_len == 3 and not next_char == "\\") then | |
+ lex_error("Character literal too long", row, col) | |
+ end | |
+ | |
+ local char_value = string.sub(str, idx + 1, idx + lit_len - 1) | |
+ char_value = deal_with_escape_sequences(char_value, true) | |
+ if lit_len == 1 then char_value = "" end | |
+ | |
+ table.insert(tokens, create_token(token_kinds.character, char_value, row, col)) | |
+ col = col + lit_len + 1 | |
+ return lex_at(idx + 1 + lit_len) | |
+ end | |
+ | |
+ -- Strings | |
+ if c == "\"" then | |
+ local next_col = col | |
+ local next_row = row | |
+ local lit_offset = 1 | |
+ local function iterate(i) | |
+ local c = string.at(str, i) | |
+ if c == "\\" then | |
+ lit_offset = lit_offset + 2 | |
+ if string.at(str, i + 1) == "\n" then | |
+ next_row = new_row + 1 | |
+ next_col = 1 | |
+ end | |
+ return iterate(i + 2) | |
+ elseif c == "\n" then | |
+ next_row = next_row + 1 | |
+ next_col = 1 | |
+ lit_offset = lit_offset + 1 | |
+ return iterate(i + 1) | |
+ elseif c == "" then | |
+ lex_error("String literal was never terminated", row, col) | |
+ elseif c == "\"" then [_$_] | |
+ next_col = next_col + 1 | |
+ return | |
+ end | |
+ lit_offset = lit_offset + 1 | |
+ next_col = next_col + 1 | |
+ return iterate(i + 1) | |
+ end | |
+ iterate(idx + 1) | |
+ | |
+ local string_value = string.sub(str, idx + 1, idx + lit_offset - 1) | |
+ string_value = deal_with_escape_sequences(string_value) | |
+ if lit_offset == 1 then string_value = "" end | |
+ | |
+ table.insert(tokens, create_token(token_kinds.string, string_value, row, col)) | |
+ row = next_row | |
+ col = next_col | |
+ return lex_at(idx + 1 + lit_offset) | |
+ end | |
+ end | |
+ | |
+ lex_at(1) | |
+ | |
+ return tokens | |
+end | |
+ | |
+------------- | |
+-- TESTS!!! | | |
+------------- | |
+ | |
+function test_interpreter() | |
+ print("|---------|") | |
+ print("| testing |") | |
+ print("|---------|") | |
+ print() | |
+ | |
+ local test_count = 0 | |
+ local pass_count = 0 | |
+ | |
+ local function test(b, msg) | |
+ test_count = test_count + 1 | |
+ if b then | |
+ print(msg .. "\t\t- passed!") | |
+ pass_count = pass_count + 1 | |
+ else | |
+ print(msg .. "\t\t- failed!") | |
+ end | |
+ end | |
+ | |
+ local lexstr = "#\n1" | |
+ local tokens = lex(lexstr) | |
+ local token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == 1, "lex: " .. lexstr) | |
+ | |
+ local lexstr = "# hello there 283938\n 138 3888f " | |
+ local tokens = lex(lexstr) | |
+ local token = tokens[1] | |
+ local token2 = tokens[2] | |
+ test(token.kind == token_kinds.integer and | |
+ token.value == 138 and | |
+ token2.kind == token_kinds.float and | |
+ token2.value == 3888.0, | |
+ "lex: " .. lexstr) | |
+ | |
+ lexstr = "(# hahaoeucrhaou (# hehe nateuh#)#)1234i " | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == 1234, "lex: " .. lexstr) | |
+ | |
+ local lexstr = "1" | |
+ local tokens = lex(lexstr) | |
+ local token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == 1, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1" | |
+ local tokens = lex(lexstr) | |
+ local token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == -1, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1234i" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == 1234, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1234i" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer and token.value == -1234, "lex: " .. lexstr) | |
+ | |
+ lexstr = "17i8" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer8 and token.value == 17, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-17i8" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer8 and token.value == -17, "lex: " .. lexstr) | |
+ | |
+ lexstr = "666i16" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer16 and token.value == 666, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-666i16" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer16 and token.value == -666, "lex: " .. lexstr) | |
+ | |
+ lexstr = "77777i32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer32 and token.value == 77777, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-77777i32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer32 and token.value == -77777, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1337i64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer64 and token.value == 1337, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1337i64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.integer64 and token.value == -1337, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1234u" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.uinteger and token.value == 1234, "lex: " .. lexstr) | |
+ | |
+ lexstr = "666u16" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.uinteger16 and token.value == 666, "lex: " .. lexstr) | |
+ | |
+ lexstr = "77777u32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.uinteger32 and token.value == 77777, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1337u64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.uinteger64 and token.value == 1337, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1." | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1.0" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1." | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1.0" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1.f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1.f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1.0f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1.0f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -1.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392." | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392.0" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392." | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392.0" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392.f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392.f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392.0f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392.0f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392.8392" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.8392, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392.8392" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+Disabling progress reports... | |
test(token.kind == token_kinds.float and token.value == -6392.8392, "lex: " .. lexstr) | |
+ | |
+ lexstr = "6392.8392f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == 6392.8392, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-6392.8392f" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float and token.value == -6392.8392, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1994f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == 1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1994f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == -1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1994.f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == 1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1994.f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == -1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1994.0f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == 1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1994.0f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == -1994.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1994.1021f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == 1994.1021, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1994.1021f32" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float32 and token.value == -1994.1021, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1939f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == 1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1939f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == -1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1939.f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == 1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1939.f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == -1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1939.0f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == 1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1939.0f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == -1939.0, "lex: " .. lexstr) | |
+ | |
+ lexstr = "1939.1945f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == 1939.1945, "lex: " .. lexstr) | |
+ | |
+ lexstr = "-1939.1945f64" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.float64 and token.value == -1939.1945, "lex: " .. lexstr) | |
+ | |
+ lexstr = "''" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.character and token.value == "", "lex: " .. lexstr) | |
+ | |
+ lexstr = "'a'" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.character and token.value == "a", "lex: " .. lexstr) | |
+ | |
+ lexstr = "'\\t'" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ test(token.kind == token_kinds.character and token.value == "\t", "lex: " .. lexstr) | |
+ | |
+ lexstr = "1123 '\\t'\n 'n' 8790u ''" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ token2 = tokens[2] | |
+ local token3 = tokens[3] | |
+ local token4 = tokens[4] | |
+ local token5 = tokens[5] | |
+ test(token.kind == token_kinds.integer and token.value == 1123 and token.line == 1 and token.column == 1 and | |
+ token2.kind == token_kinds.character and token2.value == "\t" and token2.line == 1 and token2.column == 6 and | |
+ token3.kind == token_kinds.character and token3.value == "n" and token3.line == 2 and token3.column == 2 and | |
+ token4.kind == token_kinds.uinteger and token4.value == 8790 and token4.line == 2 and token4.column == 7 and | |
+ token5.kind == token_kinds.character and token5.value == "" and token5.line == 2 and token5.column == 13, "lex: " .. lexstr) | |
+ | |
+ lexstr = "\"Hello\nWorld\"\n\"I\n\nam\" \"Isak\"" | |
+ tokens = lex(lexstr) | |
+ token = tokens[1] | |
+ token2 = tokens[2] | |
+ token3 = tokens[3] | |
+ test(token.kind == token_kinds.string and token2.kind == token_kinds.string and token3.kind == token_kinds.string and | |
+ token.value == "Hello\nWorld" and token2.value == "I\n\nam" and token3.value == "Isak" and | |
+ token.line == 1 and token2.line == 3 and token3.line == 5 and | |
+ token.column == 1 and token2.column == 1 and token3.column == 7, "lex: " .. lexstr) | |
+ | |
+ print(pass_count .. "/" .. test_count .. " passed (" .. pass_count*100.0/test_count .. "%)") | |
+ | |
+ print() | |
+ print("|-------------|") | |
+ print("| end testing |") | |
+ print("|-------------|") | |
+end | |
+ | |
+local runtests = true | |
+if runtests then | |
+ test_interpreter() | |
+end | |
Shall I push this patch? (1/8) [ynW...], or ? for more options: a | |
Reenabling progress reports. | |
Disabling progress reports... | |
ssh BitPuffin@hub.darcs.net darcs apply --all --debug --repodir 'yig' | |
Reading patch file: Fri Jan 23 13:25:28 Eur 2015 contact@bitpuffin.com | |
* Add a bunch of tests for hex, octal and binary numbers and fix a bug that was discovered doing so | |
I'm doing copyFileUsingCache on patches/0000014635-7912687e594daabbe7a72e45a4a6478d174e8448a5a8cb697a0e76d19a1861de | |
Reading patch file: Tue Jan 27 12:38:12 Eur 2015 contact@bitpuffin.com | |
* More tests, some bugfixing too thanks to tests, such as negative unsigned numbers that have specified bit count | |
I'm doing copyFileUsingCache on patches/0000008834-3135b4da9f2e5b1d67be75f5ed357ef953f6d61d875903c13440716b3992f71b | |
Reading patch file: Tue Jan 27 12:48:38 Eur 2015 contact@bitpuffin.com | |
* fix bug which recognized 123iu as a valid number | |
I'm doing copyFileUsingCache on patches/0000000580-cfe2e0efe0464e1001f310b5daa8fbd7bf764de7eb68eb5fd102af1ea89e77a3 | |
Reading patch file: Tue Jan 27 12:52:30 Eur 2015 contact@bitpuffin.com | |
* Some source code annotation | |
I'm doing copyFileUsingCache on patches/0000000552-5706d53bfc1b580b93acffb46756d6fc2bf4d18ad5fefcca544e1b4f570877aa | |
Reading patch file: Tue Jan 27 12:57:20 Eur 2015 contact@bitpuffin.com | |
* Write failed tests to stderr for stream redirection | |
I'm doing copyFileUsingCache on patches/0000000242-8c118253d43f400292a160d764da97b03a03e8b0804d8424bee2c2551e5b8390 | |
Reading patch file: Tue Jan 27 13:34:44 Eur 2015 contact@bitpuffin.com | |
* yep, more tests | |
I'm doing copyFileUsingCache on patches/0000004478-36453b09701fbe15baf2ee50d5382e5ed425aae58d19d12a7fe6bfc9d0baf467 | |
Reading patch file: Wed Jan 28 14:16:02 Eur 2015 contact@bitpuffin.com | |
* Make test code much much much shorter, and fix a bug that was discovered in the process causing column number to be wrong when using block comments | |
I'm doing copyFileUsingCache on patches/0000053440-07ef80d8e7eaf15dba13e47f34562778db2fb6ea4534c6b2aa75b1201512bcca | |
Permission denied (publickey). | |
darcs.exe: fd:3: hPutBuf: resource vanished (Broken pipe) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment