#ifndef GRUB2_H
#define GRUB2_H
-#include <regex.h>
#include <stdbool.h>
#include <list/list.h>
-struct grub2_parser;
+struct grub2_script;
struct grub2_word {
- const char *text;
- bool expand;
- bool split;
+ enum {
+ GRUB2_WORD_TEXT,
+ GRUB2_WORD_VAR,
+ } type;
+ union {
+ char *text;
+ struct {
+ const char *name;
+ bool split;
+ } var;
+ };
struct grub2_word *next;
struct list_item argv_list;
};
STMT_TYPE_IF,
STMT_TYPE_BLOCK,
} type;
+ int (*exec)(struct grub2_script *,
+ struct grub2_statement *);
};
struct grub2_statement_simple {
struct grub2_script {
struct grub2_statements *statements;
struct list environment;
- regex_t var_re;
};
struct grub2_parser {
struct grub2_statement *create_statement_block(struct grub2_parser *parser,
struct grub2_statements *stmts);
-struct grub2_word *create_word(struct grub2_parser *parser, const char *text,
- bool expand, bool split);
+struct grub2_word *create_word_text(struct grub2_parser *parser,
+ const char *text);
+
+struct grub2_word *create_word_var(struct grub2_parser *parser,
+ const char *name, bool split);
struct grub2_argv *create_argv(struct grub2_parser *parser);
void word_append(struct grub2_word *w1, struct grub2_word *w2);
/* script interface */
+void script_execute(struct grub2_script *script);
+
+int statement_simple_execute(struct grub2_script *script,
+ struct grub2_statement *statement);
+int statement_if_execute(struct grub2_script *script,
+ struct grub2_statement *statement);
struct grub2_script *create_script(void *ctx);