Exemplo n.º 1
0
static int
array(rconlexer* lexer, rconnode** nodep)
{
    rconnode* subnode = NULL;
    struct rconlist list = {NULL,0,0};
    rconnode* node = NULL;

    ENTER(_array);

    node = createrconnode(lexer,rcon_array);
    for(;;) {
        int token = nexttoken(lexer);
	if(token == EOF)
	    FAIL(lexer,"unclosed array");
	if(token == RBRACK) goto done;
	if(token == COMMA || token == SEMICOLON) continue;
	pushtoken(lexer);
        if(!value(lexer,&subnode)) goto fail;
	if(!listadd(&list,subnode)) goto fail;
    }
done:
    node->list.values = list.contents;
    node->list.nvalues = list.len;
    if(nodep) *nodep = node;
    LEAVE(_array,1);
    return 1;
fail:
    listclear(&list);
    if(subnode != NULL) rconnodefree(subnode);
    if(node != NULL) rconnodefree(node);
    LEAVE(_array,0);
    return 0;
}
Exemplo n.º 2
0
main() 
{ 
  char opc,elem; 
 
do{ 
  
  printf("\nStack  --> Opções: \n "); 
  printf("1 --> Inserir Elemento (PUSH)\n "); 
  printf("2 --> Retirar Elemento (POP)\n ");
  printf("3 --> Ler Elemento do topo (TOP)\n ");
  printf("4 --> Tamanho da stack (SIZE)\n ");
  printf("5 --> Verificar se a stack esta vazia (ISEMPTY) \n "); 
  printf("6 --> Limpar a stack (LISTCLEAR)\n ");
  printf("7 --> Listar a stack \n ");
  printf("8 --> Verificar expressao matematica\n ");
  printf("0 --> Sair\n \n"); 
  fflush(stdin);
   
  opc=getchar(); 
  system("cls");
  switch (opc) 
  { 
    case '1' : 
        printf("\n Introduza o elemento a inserir na Stack : ");
        fflush(stdin);
        elem=getchar(); 
        push(elem); 
        break; 
    case '2' :
         pop(); 
        break;
    case '3':
         printf("--> %c",top());
         break;
    case '4':
           printf("O tamanho da stack e %d\n",size());
        break;
    case '5':
         if(isempty())
            printf("A stack esta vazia\n");
         else
            printf("A stack nao esta vazia\n");
         break;
    case '6':
         listclear();
         break;
    case '7':
         listar();
         break;
    case '8':
         verificar();
         break;
    default:  printf("\n ERRO: Opção inválida! "); 
        break;        
  } 

}  
while (opc != '0'); 
} 
Exemplo n.º 3
0
static int
map(rconlexer* lexer, rconnode** nodep, int optional)
{
    rconnode* node = NULL;
    rconnode* subnode = NULL;
    struct rconlist list = {NULL,0,0};
    int token;

    ENTER(_map);
    node = createrconnode(lexer,rcon_map);
    for(;;) {
        token = nexttoken(lexer);
	if(optional && token == RBRACE)
	    FAIL(lexer,"brace mismatch");
	else if(optional && token == EOF) goto done;
	else if(!optional && token == EOF)
	    FAIL(lexer,"unclosed map");
	else if(!optional && token == RBRACE) goto done;
	if(token == COMMA || token == SEMICOLON) continue;
	pushtoken(lexer);
        if(!pair(lexer,&subnode)) goto fail;
	if(!listadd(&list,subnode)) goto fail;
    }
done:
    node->list.values = list.contents;
    node->list.nvalues = list.len;
    if(nodep) *nodep = node;
    LEAVE(_map,1);
    return 1;
fail:
    listclear(&list);
    if(subnode != NULL) rconnodefree(subnode);
    if(node != NULL) rconnodefree(node);
    LEAVE(_map,0);
    return 0;
}
Exemplo n.º 4
0
void
mn_delete(cml_node *mn)
{
    strdelete(mn->name);
    strdelete(mn->banner);
    listclear(mn->rules_using);
    if (mn->visibility_expr != 0)
    	expr_destroy(mn->visibility_expr);
    if (mn->saveability_expr != 0)
    	expr_destroy(mn->saveability_expr);
    /* only remove the list structure, all nodes are deleted seperately */
    listclear(mn->children);
    if (mn->expr != 0)
    	expr_destroy(mn->expr);
    atom_dtor(&mn->value);
    listclear(mn->transactions_guarded);
    listclear(mn->bindings);
    range_delete(mn->range);
    listdelete(mn->enumdefs, cml_enumdef, cml_enumdef_delete);
    listclear(mn->dependants);
    listclear(mn->dependees);
    strdelete(mn->help_text);
    g_free(mn);
}