Code

grammar.y: Added some (very) short documentation for each statement.
[sysdb.git] / src / frontend / grammar.y
index 551d1714d7a12cf86b64aea6834b4e4dd782dd89..3802c9c97de1aa70c8d387acd99df728c70ed0bb 100644 (file)
@@ -37,6 +37,7 @@
 #include "utils/llist.h"
 
 #include <stdio.h>
+#include <string.h>
 
 int
 sdb_fe_yylex(YYSTYPE *yylval, YYLTYPE *yylloc, sdb_fe_yyscan_t yyscanner);
@@ -74,11 +75,12 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
 
 %token SCANNER_ERROR
 
-%token <str> IDENTIFIER
-%token <node> LIST
+%token <str> IDENTIFIER STRING
+%token <node> FETCH LIST
 
 %type <list> statements
 %type <node> statement
+       fetch_statement
        list_statement
        expression
 
@@ -135,6 +137,8 @@ statements:
        ;
 
 statement:
+       fetch_statement
+       |
        list_statement
        |
        /* empty */
@@ -143,6 +147,28 @@ statement:
                }
        ;
 
+/*
+ * FETCH <hostname>;
+ *
+ * Retrieve detailed information about a single host.
+ */
+fetch_statement:
+       FETCH STRING
+               {
+                       $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
+                                               conn_fetch_t, conn_fetch_destroy));
+                       CONN_FETCH($$)->name = strdup($2);
+                       $$->cmd = CONNECTION_FETCH;
+                       free($2);
+                       $2 = NULL;
+               }
+       ;
+
+/*
+ * LIST;
+ *
+ * Returns a list of all hosts in the store.
+ */
 list_statement:
        LIST
                {
@@ -153,7 +179,7 @@ list_statement:
        ;
 
 expression:
-       IDENTIFIER
+       STRING
                {
                        $$ = SDB_CONN_NODE(sdb_object_create_T(/* name = */ NULL,
                                                conn_node_matcher_t));