Ejemplo n.º 1
0
/*
 * Directives are of the form:
 * -module(foo)
 * -define(foo, bar)
 * -record(graph, {vtab = notable, cyclic = true}).
 * -type some_type() :: any().
 * -opaque some_opaque_type() :: any().
 */
static void parseDirective (const unsigned char *cp, vString *const module)
{
	/*
	 * A directive will be either a record definition or a directive.
	 * Record definitions are handled separately
	 */
	vString *const directive = vStringNew ();
	const char *const drtv = vStringValue (directive);
	cp = parseIdentifier (cp, directive);
	cp = skipSpace (cp);
	if (*cp == '(')
		++cp;

	if (strcmp (drtv, "record") == 0)
		parseSimpleTag (cp, K_RECORD);
	else if (strcmp (drtv, "define") == 0)
		parseSimpleTag (cp, K_MACRO);
	else if (strcmp (drtv, "type") == 0)
		parseSimpleTag (cp, K_TYPE);
	else if (strcmp (drtv, "opaque") == 0)
		parseSimpleTag (cp, K_TYPE);
	else if (strcmp (drtv, "module") == 0)
		parseModuleTag (cp, module);
	/* Otherwise, it was an import, export, etc. */
	
	vStringDelete (directive);
}
Ejemplo n.º 2
0
/*
 * Directives are of the form:
 * def defp
 * defmacro defmacrop
 * defrecord
 * defmodule
 * defprotocol
 * defimpl
 */
static void parseDirective (const unsigned char *cp, vString *const module)
{
    vString *const directive = vStringNew ();
    const char *const drtv = vStringValue (directive);
    cp = parseIdentifier (cp, directive);
    skipWhitespace (&cp);
    /* if (*cp == '(') */
    /*     ++cp; */

    if (strcmp (drtv, "def") == 0 || strcmp (drtv, "defp") == 0)
        parseSimpleTag (cp, K_FUNCTION);
    else if (strcmp (drtv, "defmacro") == 0 || strcmp (drtv, "defmacrop") == 0)
        parseSimpleTag (cp, K_MACRO);
    else if (strcmp (drtv, "defrecord") == 0)
        parseSimpleTag (cp, K_RECORD);
    else if (strcmp (drtv, "defmodule") == 0)
        parseSimpleTag (cp, K_MODULE);
    else if (strcmp (drtv, "defprotocol") == 0)
        parseSimpleTag(cp, K_PROTOCOL);
    else if (strcmp (drtv, "defimpl") == 0)
        parseSimpleTag(cp, K_IMPL);
    /* Otherwise, it was an import, require, etc. */

    vStringDelete (directive);
}