0

I have created the below mentioned grammar for the following DOT code -

digraph G {
          main [shape=box; /*this is a comment*/
          main -> parse [weight=8];
          parse -> execute;
          main -> init [style=dotted];
          main -> cleanup;
          execute -> make_string;
          init -> make_string;
          main -> printf [style=bold,label= "100 times"];
          make_string [label="make a\nstring"];
          node [shape=box,style=filled,color=".7 .3 1.0"];
          execute -> compare;
       }
Grammar:
graph    :    digraph [ ID ] '{' stmt_list '}'
stmt_list:    [ stmt [ ';' ] [ stmt_list ] ]
stmt     :    node_stmt
         |    edge_stmt
         |    attr_stmt /*defines a default attribute*/
         |    ID '=' ID
attr_stmt:    (graph | node | edge) attr_list
attr_list:    '[' attr  ']' [ attr_list ]  
attr    :     ID '=' ID [','] [attr] 
edge_stmt:    node_id -> node_id [ attr_list ]
node_stmt:    node_id [ attr_list ]
node_id  :    ID

When I execute my parser code with the above mentioned grammar its not printing the error. I wanted to know if I have defined the correct grammar

  • 2
    What do you mean by "its not printing the error"? Is it supposed to be printing an error? Is it doing something wrong without an error message? What parser did you use, and what input did you try to parse? What, exactly, is happening, and what should happen? – user2357112 Jun 03 '14 at 21:17
  • `->` in `edge_stmt` probably needs quotes. If that's the whole problem, please try to read your code more carefully next time. – user2357112 Jun 03 '14 at 21:20
  • ok, I will look into it and let u know. I wrote a code for the above grammar in Python and Its not printing the error for main [shape=box; /*this is a comment*/ --for this statement where ']' is missing. Wanted to check if my grammar is ok first and will recheck my program – user3704723 Jun 03 '14 at 21:37

0 Answers0