discover/grub2: Implement statement blocks
authorJeremy Kerr <jk@ozlabs.org>
Thu, 12 Sep 2013 07:03:05 +0000 (15:03 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 24 Sep 2013 05:14:59 +0000 (13:14 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/grub2/grub2.h
discover/grub2/parser-api.c
discover/grub2/parser.y

index 2c7951a5520c90e4c5b5040f6da81fedc634cb6e..cc817ff4b9eae7e29fb6ebbcebf5775d3376f293 100644 (file)
@@ -33,17 +33,23 @@ struct grub2_statement_if {
        struct grub2_statements *false_case;
 };
 
        struct grub2_statements *false_case;
 };
 
+struct grub2_statement_block {
+       struct grub2_statements *statements;
+};
+
 struct grub2_statement {
        struct list_item        list;
        enum {
                STMT_TYPE_SIMPLE,
                STMT_TYPE_MENUENTRY,
                STMT_TYPE_IF,
 struct grub2_statement {
        struct list_item        list;
        enum {
                STMT_TYPE_SIMPLE,
                STMT_TYPE_MENUENTRY,
                STMT_TYPE_IF,
+               STMT_TYPE_BLOCK,
        } type;
        union {
                struct grub2_statement_simple           simple;
                struct grub2_statement_menuentry        menuentry;
                struct grub2_statement_if               ifstmt;
        } type;
        union {
                struct grub2_statement_simple           simple;
                struct grub2_statement_menuentry        menuentry;
                struct grub2_statement_if               ifstmt;
+               struct grub2_statement_block            block;
        };
 };
 
        };
 };
 
@@ -69,6 +75,9 @@ struct grub2_statement *create_statement_if(struct grub2_parser *parser,
                struct grub2_statements *true_case,
                struct grub2_statements *false_case);
 
                struct grub2_statements *true_case,
                struct grub2_statements *false_case);
 
+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(struct grub2_parser *parser, const char *text,
                bool expand, bool split);
 
index 6e05ecf56faaa9261ee5c292aa35e97bbf7155e0..37c88a264d750590f282bf0bfa39262ec9b7c2f5 100644 (file)
@@ -42,6 +42,16 @@ struct grub2_statement *create_statement_if(struct grub2_parser *parser,
        stmt->ifstmt.false_case = false_case;
        return stmt;
 }
        stmt->ifstmt.false_case = false_case;
        return stmt;
 }
+
+struct grub2_statement *create_statement_block(struct grub2_parser *parser,
+               struct grub2_statements *stmts)
+{
+       struct grub2_statement *stmt = talloc(parser, struct grub2_statement);
+       stmt->type = STMT_TYPE_BLOCK;
+       stmt->block.statements = stmts;
+       return stmt;
+}
+
 void statement_append(struct grub2_statements *stmts,
                struct grub2_statement *stmt)
 {
 void statement_append(struct grub2_statements *stmts,
                struct grub2_statement *stmt)
 {
index a8c02e284b6d7b4507003839e1d5eb483814617f..d57c732a8382152c690fbabad381b5b266c0f509 100644 (file)
@@ -73,7 +73,9 @@ statement: TOKEN_EOL {
        | words TOKEN_EOL {
                   $$ = create_statement_simple(parser, $1);
        }
        | words TOKEN_EOL {
                   $$ = create_statement_simple(parser, $1);
        }
-       | '{' statements '}' { $$ = NULL; }
+       | '{' statements '}' {
+               $$ = create_statement_block(parser, $2);
+       }
        | "if" TOKEN_DELIM statement
                "then" TOKEN_EOL
                statements
        | "if" TOKEN_DELIM statement
                "then" TOKEN_EOL
                statements