~yerinalexey/csq

0019ab92b9bb26125b4d446c1b9e30677f156cce — Alexey Yerin a month ago b85274f
Give a name to the special reference value for '$$'
2 files changed, 4 insertions(+), 2 deletions(-)

M eval.ha
M lex.ha
M eval.ha => eval.ha +1 -1
@@ 49,7 49,7 @@ fn eval(st: *state, e: *expr) (rational::number | noresult | invalid) = {
	case let i: rational::number =>
		return i;
	case let r: reference =>
		if (r == -1) {
		if (r == REFERENCE_LAST) {
			if (len(st.results) == 0) {
				return invalid;
			};

M lex.ha => lex.ha +3 -1
@@ 23,6 23,8 @@ type name = str;
type token = ((i64, uint) | dot | reference | sqrt_keyword | option_keyword
	| name | groupstart | groupend | bang | operation | io::EOF);

def REFERENCE_LAST: reference = -1;

// Invalid token
type invalid = !void;



@@ 130,7 132,7 @@ fn next_token(lex: *lexer) (token | invalid) = {
			match (strings::next(&lex.iter)) {
			case let r: rune =>
				if (r == '$') {
					return -1: reference;
					return REFERENCE_LAST;
				};
				strings::prev(&lex.iter);
			case done =>