Beispiel #1
0
int			ft_inner(va_list ap, char *str)
{
	int out;
	int i;

	i = 0;
	out = 0;
	while (str[i] != '\0')
	{
		if (str[i] == '%' && str[i + 1] != '%')
		{
			while (ft_isspec(str[i + 1]) != 1)
				i++;
			out += specifier(ap, str[i + 1]);
			i++;
		}
		else if (str[i] == '%' && str[i + 1] == '%')
		{
			out += ft_putchar(str[i]);
			i++;
		}
		else
			out += ft_putchar(str[i]);
		i++;
	}
	return (out);
}
Beispiel #2
0
Code read_stat(Pnode p)
{
    Code result, specifiercode;
    int op;

    // Vincoli semantici
    Psymbol symbol = lookup(valname(p->child->brother));
    if (symbol == NULL)
        semerror(p->child, "Unknown identifier");

    if (p->child->child != NULL)
    {
        // Con specifier
        op = T_FGET;
        specifiercode = specifier(p->child);
    }
    else
    {
        op = T_GET;
    }

    Value v1; v1.ival = symbol->oid;
    Value v2; v2.sval = get_format(symbol->schema);
    result = makecode2(op, v1, v2);

    if (op == T_GET)
        return result;
    else
        return appcode(specifiercode, result);
}
Beispiel #3
0
/*Controlla la semantica della write e ne ritorna il codice*/
Code write_stat(Pnode write_stat_node){
	//Imposto le due parti del nodo
	Pnode specifier_node = write_stat_node->child;
	Pnode expr_node = write_stat_node->child->brother;

	//Definisco la variabile che contiene il codice da ritornare
	Code write_stat_code;
	
	//Calcolo il codice di specifier
	Pschema schema_specifier = (Pschema) newmem(sizeof(Schema));
	Code specifier_code = specifier(specifier_node,schema_specifier);

	//Controllo che non ci siano errori semantici
	//Controllo che il tipo di specifier sia corretto
	if (schema_specifier->type != STRING && schema_specifier->type != NIHIL)
		semerror(write_stat_node,"Expected string type");

	//Genero il codice di write_stat
	//Genero il codice di expr
	Pschema schema_expr = (Pschema) newmem(sizeof(Schema));
	Code expr_code = expr(expr_node,schema_expr);

	//La sintassi della write dipende dalla presenza dello specifier
	if (specifier_node->child == NULL)
		write_stat_code = appcode(expr_code,make_print_fprint(T_PRINT,get_format(*schema_expr)));
	else
		write_stat_code = concode(expr_code,specifier_code,make_print_fprint(T_FPRINT,get_format(*schema_expr)),endcode());

	return write_stat_code;
}
Beispiel #4
0
Code write_stat(Pnode p)
{
    /*
         WRITE_STAT
            /
           /
        N_SPECIFIER --> expr
             /
            /
        [expr-filename]
     */
    Value format;
    int op;
    Schema exprschema;
    Code code = expr(p->child->brother, &exprschema);

    if (p->child->child != NULL)
    {
        // Con specifier
        code = appcode(code, specifier(p->child));
        op = T_FPRINT;
    }
    else
    {
        // Senza specifier
        op = T_PRINT;
    }
    format.sval = get_format(&exprschema);
    free_schema(exprschema.next);
    return concode(
        code,
        makecode1(op, format),
        endcode()
        );
}
Beispiel #5
0
status_t
FolderShaper::MoveRefToTrash	(const entry_ref * a_ref)
{
	BMessenger trak_messgr(FS_TRACKER_SIGNATURE);

	if (trak_messgr.IsValid())
	{
		BMessage msg(B_DELETE_PROPERTY);

		BMessage specifier('sref');
		specifier.AddRef("refs", a_ref);
		specifier.AddString("property", "Entry");
		msg.AddSpecifier(& specifier);

		msg.AddSpecifier("Poses");
		msg.AddSpecifier("Window", 1);

		BMessage reply;
		status_t status;
		status = trak_messgr.SendMessage(&msg, &reply);
		
		return status;
	}
	else
		PRINT(("Tracker BMessenger not valid.\n"));
		
	return B_ERROR;
}
Beispiel #6
0
void CommandInset::write(WriteStream & os) const
{
	ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
	MathEnsurer ensurer(os, needs_math_mode_);
	os << '\\' << name_;
	if (cell(1).size())
		os << '[' << cell(1) << ']';
	os << '{' << cell(0) << '}';
}
Beispiel #7
0
/*Controlla la semantica della read e ritorna il codice della read*/
Code read_stat(Pnode read_stat_node){
#ifdef DEBUG_READ_STAT
	printf("READ_STAT - enter\n");
#endif
	//Imposto le due parti del nodo
	Pnode specifier_node = read_stat_node->child;
	Pnode id_node = read_stat_node->child->brother;
	
	//Definisco il codice del nodo
	Code read_stat_code;
	read_stat_code.head = NULL;

	//Calcolo il codice di specifier
	Pschema schema_specifier = (Pschema) newmem(sizeof(Schema));
	Code specifier_code = specifier(specifier_node,schema_specifier);

	//Controllo che non ci siano errori semantici
	//Controllo che il tipo di specifier sia corretto
	if ((schema_specifier->type != STRING) && (schema_specifier->type != NIHIL))
		semerror(read_stat_node,"Expected string type");
	//Controllo che il nome dell'id sia visibile
	if (lookup(valname(id_node))==NULL)
		semerror(id_node,"Variable not defined");

	//Genero il codice di readstat
	//La sintassi della read dipende dalla presenza dello specifier
	Psymbol symbol = lookup(valname(id_node));
	if (specifier_node->child == NULL)		
		read_stat_code = make_get_fget(T_GET,symbol->oid,get_format((symbol->schema)));
	else
		read_stat_code = appcode(specifier_code,make_get_fget(T_FGET,symbol->oid,get_format((symbol->schema))));
#ifdef DEBUG_READ_STAT
	printf("READ_STAT - exit\n");
#endif
	return read_stat_code;
}
Beispiel #8
0
void InsetMathTabular::write(WriteStream & os) const
{
	ModeSpecifier specifier(os, TEXT_MODE);

	if (os.fragile())
		os << "\\protect";
	os << "\\begin{" << name_ << '}';
	bool open = os.startOuterRow();

	char const v = verticalAlignment();
	if (v == 't' || v == 'b')
		os << '[' << v << ']';
	os << '{' << horizontalAlignments() << "}\n";

	InsetMathGrid::write(os);

	if (os.fragile())
		os << "\\protect";
	os << "\\end{" << name_ << '}';
	if (open)
		os.startOuterRow();
	// adding a \n here is bad if the tabular is the last item
	// in an \eqnarray...
}
Beispiel #9
0
void write_stat(){
	match(WRITE);
	specifier();
	expr();
}
Beispiel #10
0
void read_stat(){
	match(READ);
	specifier();
	match(ID);
}
Beispiel #11
0
void InsetMathEnsureMath::write(WriteStream & os) const
{
	ModeSpecifier specifier(os, MATH_MODE);
	os << "\\ensuremath{" << cell(0) << "}";
}