mirror of
https://github.com/linux-msm/qmic.git
synced 2026-02-25 13:11:34 -08:00
parser: Move struct parser to parser.c
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
35
parser.c
35
parser.c
@@ -323,6 +323,41 @@ void qmi_message_parse(enum message_type message_type)
|
||||
list_add(&qmi_messages, &qm->node);
|
||||
}
|
||||
|
||||
struct list_head qmi_structs = LIST_INIT(qmi_structs);
|
||||
|
||||
void qmi_struct_parse(void)
|
||||
{
|
||||
struct qmi_struct_member *qsm;
|
||||
struct token struct_id_tok;
|
||||
struct qmi_struct *qs;
|
||||
struct token type_tok;
|
||||
struct token id_tok;
|
||||
|
||||
token_expect(TOK_ID, &struct_id_tok);
|
||||
token_expect('{', NULL);
|
||||
|
||||
qs = malloc(sizeof(struct qmi_struct));
|
||||
qs->name = struct_id_tok.str;
|
||||
list_init(&qs->members);
|
||||
|
||||
while (token_accept(TOK_TYPE, &type_tok)) {
|
||||
token_expect(TOK_ID, &id_tok);
|
||||
token_expect(';', NULL);
|
||||
|
||||
qsm = malloc(sizeof(struct qmi_struct_member));
|
||||
qsm->name = id_tok.str;
|
||||
qsm->type = type_tok.num;
|
||||
|
||||
list_add(&qs->members, &qsm->node);
|
||||
}
|
||||
|
||||
token_expect('}', NULL);
|
||||
token_expect(';', NULL);
|
||||
|
||||
list_add(&qmi_structs, &qs->node);
|
||||
|
||||
symbol_add(qs->name, TOK_TYPE, TYPE_STRUCT, qs);
|
||||
}
|
||||
|
||||
const char *qmi_package;
|
||||
|
||||
|
||||
51
qmi_struct.c
51
qmi_struct.c
@@ -4,57 +4,6 @@
|
||||
#include "list.h"
|
||||
#include "qmic.h"
|
||||
|
||||
struct qmi_struct_member {
|
||||
const char *name;
|
||||
int type;
|
||||
|
||||
struct list_head node;
|
||||
};
|
||||
|
||||
struct qmi_struct {
|
||||
const char *name;
|
||||
|
||||
struct list_head node;
|
||||
|
||||
struct list_head members;
|
||||
};
|
||||
|
||||
static struct list_head qmi_structs = LIST_INIT(qmi_structs);
|
||||
|
||||
void qmi_struct_parse(void)
|
||||
{
|
||||
struct qmi_struct_member *qsm;
|
||||
struct token struct_id_tok;
|
||||
struct qmi_struct *qs;
|
||||
struct token type_tok;
|
||||
struct token id_tok;
|
||||
|
||||
token_expect(TOK_ID, &struct_id_tok);
|
||||
token_expect('{', NULL);
|
||||
|
||||
qs = malloc(sizeof(struct qmi_struct));
|
||||
qs->name = struct_id_tok.str;
|
||||
list_init(&qs->members);
|
||||
|
||||
while (token_accept(TOK_TYPE, &type_tok)) {
|
||||
token_expect(TOK_ID, &id_tok);
|
||||
token_expect(';', NULL);
|
||||
|
||||
qsm = malloc(sizeof(struct qmi_struct_member));
|
||||
qsm->name = id_tok.str;
|
||||
qsm->type = type_tok.num;
|
||||
|
||||
list_add(&qs->members, &qsm->node);
|
||||
}
|
||||
|
||||
token_expect('}', NULL);
|
||||
token_expect(';', NULL);
|
||||
|
||||
list_add(&qmi_structs, &qs->node);
|
||||
|
||||
symbol_add(qs->name, TOK_TYPE, TYPE_STRUCT, qs);
|
||||
}
|
||||
|
||||
void qmi_struct_header(FILE *fp, const char *package)
|
||||
{
|
||||
struct qmi_struct_member *qsm;
|
||||
|
||||
17
qmic.h
17
qmic.h
@@ -69,9 +69,24 @@ struct qmi_message {
|
||||
struct list_head members;
|
||||
};
|
||||
|
||||
struct qmi_struct_member {
|
||||
const char *name;
|
||||
int type;
|
||||
|
||||
struct list_head node;
|
||||
};
|
||||
|
||||
struct qmi_struct {
|
||||
const char *name;
|
||||
|
||||
struct list_head node;
|
||||
|
||||
struct list_head members;
|
||||
};
|
||||
|
||||
extern struct list_head qmi_consts;
|
||||
extern struct list_head qmi_messages;
|
||||
|
||||
extern struct list_head qmi_structs;
|
||||
|
||||
void yyerror(const char *fmt, ...) __attribute__((noreturn));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user