Saving stuff from presentation
This commit is contained in:
parent
7aa2a36e1a
commit
c091ffacbd
|
|
@ -0,0 +1 @@
|
||||||
|
{ 2 - dup 0 <= { drop 1 } { 1 1 rot 0 swap { drop swap 1 pick + } for swap drop } if } lambda ::fib const
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
// Start with which Fibonacci number we want (Nth Fibonacci number)
|
||||||
|
2 - // We push the first two already
|
||||||
|
dup 0 <= { drop 1 } {
|
||||||
|
1 1 // Starting Fibonacci numbers
|
||||||
|
rot 0 swap // Setting up loop from zero to N
|
||||||
|
{
|
||||||
|
drop // Discard the loop counter
|
||||||
|
swap 1 pick // Swap n-1 and n-2 and copy n-1
|
||||||
|
+ // Add n-2 and the copy of n-1
|
||||||
|
// n and n-1 left on stack
|
||||||
|
} for
|
||||||
|
swap drop // Drop n-1 from the stack
|
||||||
|
} if
|
||||||
|
} lambda ::fib const
|
||||||
|
|
||||||
|
8 fib
|
||||||
|
|
@ -1803,8 +1803,8 @@ static TestResult test_Float_f32_Negative_Zero() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Simple_Letter_A() {
|
static TestResult test_Char_Simple_Letter_Uppercase_A() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Simple Letter A"), SLS_STR("'A'"));
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Uppercase A"), SLS_STR("'A'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
@ -1813,8 +1813,8 @@ static TestResult test_Char_Simple_Letter_A() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Simple_Letter_a() {
|
static TestResult test_Char_Simple_Letter_Lowercase_a() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Simple Letter a"), SLS_STR("'a'"));
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Lowercase a"), SLS_STR("'a'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
@ -1823,8 +1823,8 @@ static TestResult test_Char_Simple_Letter_a() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Simple_Letter_Z() {
|
static TestResult test_Char_Simple_Letter_Uppercase_Z() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Z"), SLS_STR("'Z'"));
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Uppercase Z"), SLS_STR("'Z'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
@ -1833,8 +1833,8 @@ static TestResult test_Char_Simple_Letter_Z() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Simple_Letter_z() {
|
static TestResult test_Char_Simple_Letter_Lowercase_z() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Simple Letter z"), SLS_STR("'z'"));
|
LexerTest test = start_up_test(SLS_STR("Char Simple Letter Lowercase z"), SLS_STR("'z'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
@ -2073,22 +2073,22 @@ static TestResult test_Char_Right_Brace() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Tab() {
|
static TestResult test_Char_Escape_Single_quote() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Tab"), SLS_STR("'\\t'"));
|
LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\\''"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){9})) return test.result;
|
if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result;
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Backslash() {
|
static TestResult test_Char_Escape_Newline() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\\\'"));
|
LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\\n'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result;
|
if (test_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
@ -2103,12 +2103,22 @@ static TestResult test_Char_Escape_Null_character() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Single_quote() {
|
static TestResult test_Char_Escape_Backslash() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\\''"));
|
LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\\\'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result;
|
if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result;
|
||||||
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
|
return pass_test(&test, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TestResult test_Char_Escape_Tab() {
|
||||||
|
LexerTest test = start_up_test(SLS_STR("Char Escape Tab"), SLS_STR("'\\t'"));
|
||||||
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
|
size_t i = 0;
|
||||||
|
if (test_character_value(&test, result, i++, &(uint8_t){9})) return test.result;
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
@ -2123,16 +2133,6 @@ static TestResult test_Char_Escape_Carriage_return() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Newline() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\\n'"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Char_With_Leading_Whitespace() {
|
static TestResult test_Char_With_Leading_Whitespace() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char With Leading Whitespace"), SLS_STR(" 'A'"));
|
LexerTest test = start_up_test(SLS_STR("Char With Leading Whitespace"), SLS_STR(" 'A'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -3845,10 +3845,10 @@ TestsReport run_lexer_tests() {
|
||||||
test_report.tests[i++] = test_Float_Default_Negative_Zero();
|
test_report.tests[i++] = test_Float_Default_Negative_Zero();
|
||||||
test_report.tests[i++] = test_Float_f32_Positive_Zero();
|
test_report.tests[i++] = test_Float_f32_Positive_Zero();
|
||||||
test_report.tests[i++] = test_Float_f32_Negative_Zero();
|
test_report.tests[i++] = test_Float_f32_Negative_Zero();
|
||||||
test_report.tests[i++] = test_Char_Simple_Letter_A();
|
test_report.tests[i++] = test_Char_Simple_Letter_Uppercase_A();
|
||||||
test_report.tests[i++] = test_Char_Simple_Letter_a();
|
test_report.tests[i++] = test_Char_Simple_Letter_Lowercase_a();
|
||||||
test_report.tests[i++] = test_Char_Simple_Letter_Z();
|
test_report.tests[i++] = test_Char_Simple_Letter_Uppercase_Z();
|
||||||
test_report.tests[i++] = test_Char_Simple_Letter_z();
|
test_report.tests[i++] = test_Char_Simple_Letter_Lowercase_z();
|
||||||
test_report.tests[i++] = test_Char_Digit_0();
|
test_report.tests[i++] = test_Char_Digit_0();
|
||||||
test_report.tests[i++] = test_Char_Digit_5();
|
test_report.tests[i++] = test_Char_Digit_5();
|
||||||
test_report.tests[i++] = test_Char_Digit_9();
|
test_report.tests[i++] = test_Char_Digit_9();
|
||||||
|
|
@ -3872,12 +3872,12 @@ TestsReport run_lexer_tests() {
|
||||||
test_report.tests[i++] = test_Char_Right_Bracket();
|
test_report.tests[i++] = test_Char_Right_Bracket();
|
||||||
test_report.tests[i++] = test_Char_Left_Brace();
|
test_report.tests[i++] = test_Char_Left_Brace();
|
||||||
test_report.tests[i++] = test_Char_Right_Brace();
|
test_report.tests[i++] = test_Char_Right_Brace();
|
||||||
test_report.tests[i++] = test_Char_Escape_Tab();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Backslash();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Null_character();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Single_quote();
|
test_report.tests[i++] = test_Char_Escape_Single_quote();
|
||||||
test_report.tests[i++] = test_Char_Escape_Carriage_return();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Newline();
|
test_report.tests[i++] = test_Char_Escape_Newline();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Null_character();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Backslash();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Tab();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Carriage_return();
|
||||||
test_report.tests[i++] = test_Char_With_Leading_Whitespace();
|
test_report.tests[i++] = test_Char_With_Leading_Whitespace();
|
||||||
test_report.tests[i++] = test_Char_With_Trailing_Whitespace();
|
test_report.tests[i++] = test_Char_With_Trailing_Whitespace();
|
||||||
test_report.tests[i++] = test_Char_With_Both_Whitespace();
|
test_report.tests[i++] = test_Char_With_Both_Whitespace();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"stack":[{"I64":10}],"functions":{"asin":{"Builtin":"asin"},"if":{"Builtin":"if"},"*":{"Builtin":"*"},"tan":{"Builtin":"tan"},"floor":{"Builtin":"floor"},"bitor":{"Builtin":"bitor"},"shl":{"Builtin":"shl"},"rot":{"TokenString":{"tokens":[{"I64":3},{"I64":1},{"Identifier":{"name":"roll","is_literal":false}}]}},"not":{"Builtin":"not"},"while":{"Builtin":"while"},"<=":{"Builtin":"<="},"pick":{"Builtin":"pick"},"ln":{"Builtin":"ln"},"shr":{"Builtin":"shr"},"round":{"Builtin":"round"},"atan":{"Builtin":"atan"},"log":{"Builtin":"log"},"swap":{"Builtin":"swap"},"dup":{"Builtin":"dup"},"or":{"Builtin":"or"},"eval":{"Builtin":"eval"},"type_of":{"Builtin":"type_of"},"rand":{"Builtin":"rand"},"/":{"Builtin":"/"},"depth":{"Builtin":"depth"},"seed":{"Builtin":"seed"},"logb":{"TokenString":{"tokens":[{"Identifier":{"name":"ln","is_literal":false}},{"Identifier":{"name":"swap","is_literal":false}},{"Identifier":{"name":"ln","is_literal":false}},{"Identifier":{"name":"swap","is_literal":false}},{"Identifier":{"name":"/","is_literal":false}}]}},"+":{"Builtin":"+"},"cos":{"Builtin":"cos"},"max":{"TokenString":{"tokens":[{"I64":1},{"Identifier":{"name":"pick","is_literal":false}},{"I64":1},{"Identifier":{"name":"pick","is_literal":false}},{"Identifier":{"name":"<","is_literal":false}},{"TokenString":{"tokens":[{"Identifier":{"name":"swap","is_literal":false}},{"Identifier":{"name":"drop","is_literal":false}}]}},{"TokenString":{"tokens":[{"Identifier":{"name":"drop","is_literal":false}}]}},{"Identifier":{"name":"if","is_literal":false}}]}},"ceil":{"Builtin":"ceil"},"-":{"Builtin":"-"},"for":{"Builtin":"for"},"and":{"Builtin":"and"},"min":{"TokenString":{"tokens":[{"I64":1},{"Identifier":{"name":"pick","is_literal":false}},{"I64":1},{"Identifier":{"name":"pick","is_literal":false}},{"Identifier":{"name":"<","is_literal":false}},{"TokenString":{"tokens":[{"Identifier":{"name":"drop","is_literal":false}}]}},{"TokenString":{"tokens":[{"Identifier":{"name":"swap","is_literal":false}},{"Identifier":{"name":"drop","is_literal":false}}]}},{"Identifier":{"name":"if","is_literal":false}}]}},"atan2":{"Builtin":"atan2"},"const":{"Builtin":"const"},"sqrt":{"Builtin":"sqrt"},">":{"Builtin":">"},"bitand":{"Builtin":"bitand"},"!=":{"Builtin":"!="},"<":{"Builtin":"<"},"acos":{"Builtin":"acos"},"%":{"Builtin":"%"},">=":{"Builtin":">="},"==":{"Builtin":"=="},"abs":{"Builtin":"abs"},"sin":{"Builtin":"sin"},"^":{"Builtin":"^"},"bitnot":{"Builtin":"bitnot"},"lambda":{"Builtin":"lambda"},"bitxor":{"Builtin":"bitxor"},"ten":{"TokenString":{"tokens":[{"I64":10}]}},"roll":{"Builtin":"roll"},"drop":{"Builtin":"drop"}}}
|
||||||
Loading…
Reference in New Issue