qse/ase/lsp/token.c

78 lines
1.5 KiB
C
Raw Normal View History

2005-02-04 15:39:11 +00:00
/*
2006-10-24 04:22:40 +00:00
* $Id: token.c,v 1.15 2006-10-24 04:22:40 bacon Exp $
2005-02-04 15:39:11 +00:00
*/
2006-10-24 04:22:40 +00:00
#include <ase/lsp/lsp_i.h>
2005-02-04 15:39:11 +00:00
2006-10-24 04:22:40 +00:00
ase_lsp_token_t* ase_lsp_token_open (
ase_lsp_token_t* token, ase_word_t capacity)
2005-02-04 15:39:11 +00:00
{
2006-10-24 04:22:40 +00:00
if (token == ASE_NULL)
2006-10-23 14:57:44 +00:00
{
2006-10-24 04:22:40 +00:00
token = (ase_lsp_token_t*)
ase_malloc (ase_sizeof(ase_lsp_token_t));
if (token == ASE_NULL) return ASE_NULL;
token->__dynamic = ase_true;
2005-09-18 08:10:50 +00:00
}
2006-10-24 04:22:40 +00:00
else token->__dynamic = ase_false;
2005-09-18 08:10:50 +00:00
2006-10-24 04:22:40 +00:00
if (ase_lsp_name_open(&token->name, capacity) == ASE_NULL) {
if (token->__dynamic) ase_free (token);
return ASE_NULL;
2005-02-04 15:39:11 +00:00
}
2005-09-18 08:10:50 +00:00
/*
2005-02-04 15:39:11 +00:00
token->ivalue = 0;
token->fvalue = .0;
2005-09-18 08:10:50 +00:00
*/
2006-10-24 04:22:40 +00:00
token->type = ASE_LSP_TOKEN_END;
2005-02-04 15:39:11 +00:00
return token;
}
2006-10-24 04:22:40 +00:00
void ase_lsp_token_close (ase_lsp_token_t* token)
2005-02-04 15:39:11 +00:00
{
2006-10-24 04:22:40 +00:00
ase_lsp_name_close (&token->name);
if (token->__dynamic) ase_free (token);
2005-02-04 15:39:11 +00:00
}
2006-10-24 04:22:40 +00:00
int ase_lsp_token_addc (ase_lsp_token_t* token, ase_cint_t c)
2005-02-04 15:39:11 +00:00
{
2006-10-24 04:22:40 +00:00
return ase_lsp_name_addc (&token->name, c);
2005-09-18 08:10:50 +00:00
}
2005-02-04 15:39:11 +00:00
2006-10-24 04:22:40 +00:00
int ase_lsp_token_adds (ase_lsp_token_t* token, const ase_char_t* s)
2005-09-18 08:10:50 +00:00
{
2006-10-24 04:22:40 +00:00
return ase_lsp_name_adds (&token->name, s);
2005-02-04 15:39:11 +00:00
}
2006-10-24 04:22:40 +00:00
void ase_lsp_token_clear (ase_lsp_token_t* token)
2005-02-04 15:39:11 +00:00
{
2005-09-18 08:10:50 +00:00
/*
token->ivalue = 0;
token->fvalue = .0;
*/
2005-02-04 15:39:11 +00:00
2006-10-24 04:22:40 +00:00
token->type = ASE_LSP_TOKEN_END;
ase_lsp_name_clear (&token->name);
2005-02-04 15:39:11 +00:00
}
2006-10-24 04:22:40 +00:00
ase_char_t* ase_lsp_token_yield (ase_lsp_token_t* token, ase_word_t capacity)
2005-02-04 15:39:11 +00:00
{
2006-10-24 04:22:40 +00:00
ase_char_t* p;
2005-02-04 15:39:11 +00:00
2006-10-24 04:22:40 +00:00
p = ase_lsp_name_yield (&token->name, capacity);
if (p == ASE_NULL) return ASE_NULL;
2005-02-04 15:39:11 +00:00
2005-09-18 08:10:50 +00:00
/*
token->ivalue = 0;
token->fvalue = .0;
*/
2006-10-24 04:22:40 +00:00
token->type = ASE_LSP_TOKEN_END;
2005-09-18 08:10:50 +00:00
return p;
2005-02-04 15:39:11 +00:00
}
2006-10-24 04:22:40 +00:00
int ase_lsp_token_compare_name (ase_lsp_token_t* token, const ase_char_t* str)
2005-02-04 15:39:11 +00:00
{
2006-10-24 04:22:40 +00:00
return ase_lsp_name_compare (&token->name, str);
2005-02-04 15:39:11 +00:00
}