Esempio n. 1
0
void nip::parse::Parser::term() {
	if (accept(LIT_CHAR)) {
		; // Make a character literal
	}
	else if (accept(LIT_INT)) {
		; // Make a integer literal
	}
	else if (accept(LIT_FLOAT)) {
		; // Make a floating point literal
	}
	else if (accept(LIT_STRING)) {
		; // Make a string literal
	}
	else if (is(IDENTIFIER)) {
		qualified_name();
	}
	else if (accept(LEFT_PAREN)) { // Look more into this later
		if (is(IDENTIFIER)) {
			qualified_name();
			while (!accept(RIGHT_PAREN)) {
				term();
			}
		}
		else {
			while (!accept(RIGHT_PAREN)) {
				term();
			}
		}
	}
}
Esempio n. 2
0
void nip::parse::Parser::import_name() {
	if (is(IDENTIFIER)) {
		qualified_name();
	}
	else if (accept(KEY_TYPE)) {
		qualified_name();
	}
	else if (accept(KEY_VOCAB)) {
		qualified_name();
	}
	else {
		error("expected qualified name, \"vocab\" or \"type\"");
	}
}
Esempio n. 3
0
bool Type::operator<(Type const& other) const {
    // Compares two types and returns true if this type is less than the other,
    // by doing a name comparison and a recursive comparison of the generics.
    if (qualified_name() != other.qualified_name()) {
        return qualified_name()->string() < other.qualified_name()->string();
    }
    Generic* g1 = generics();
    Generic* g2 = other.generics();
    while (true) {
        if (!g1 && g2) { return true; }
        if (g1 && !g2) { return false; }
        if (!g1 && !g2) { return false; }
        if (!g1->type()->equals(g2->type())) { return *g1->type() < *g2->type(); }
        g1 = g1->next();
        g2 = g2->next();
    }
    return false;
}
Esempio n. 4
0
void nip::parse::Parser::type_name() {
	qualified_name();
	if (accept(LEFT_CARROT)) {
		trait_arguments();
	}
	if (accept(LEFT_PAREN)) {
		do {
			expect(IDENTIFIER, "expected identifier");
		} while (accept(COMMA));
		expect(RIGHT_PAREN);
	}
}
Esempio n. 5
0
void nip::parse::Parser::vocabulary_synonym() {
	expect(IDENTIFIER, "expected identifier");
	qualified_name();
}