在Python中为DOT代码定义语法

时间:2014-06-03 21:08:26

标签: python parsing lexer dot

我为以下DOT代码创建了下面提到的语法 -

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

当我使用上面提到的语法执行我的解析器代码时,它不会打印错误。我想知道我是否定义了正确的语法

0 个答案:

没有答案