[<<][meta][>>][..]
Fri Nov 4 22:39:04 EDT 2011

Pretty-printed C AST

*Main> pc c
CTranslUnit
  [ CFDefExt (
      CFunDef
        [ CTypeSpec (
            CIntType (
              NodeInfo
                Position
                  { posOffset = 0
                  , posFile = "/tmp/foo.c"
                  , posRow = 1
                  , posColumn = 1
                  }
                ( Position
                    { posOffset = 0
                    , posFile = "/tmp/foo.c"
                    , posRow = 1
                    , posColumn = 1
                    }
                , 3
                )
                Name
                  { nameId = 1
                  ) ) )
        ] (
        CDeclr (
          Just "fun" )
          [ CFunDeclr (
              Right
                ( [ CDecl
                      [ CTypeSpec (
                          CVoidType (
                            NodeInfo
                              Position
                                { posOffset = 8
                                , posFile = "/tmp/foo.c"
                                , posRow = 1
                                , posColumn = 9
                                }
                              ( Position
                                  { posOffset = 8
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 9
                                  }
                              , 4
                              )
                              Name
                                { nameId = 3
                                } ) )
                      ]
                      [ ( Just (
                            CDeclr (
                              Just "state" )
                              [ CPtrDeclr
                                  [] (
                                  NodeInfo
                                    Position
                                      { posOffset = 13
                                      , posFile = "/tmp/foo.c"
                                      , posRow = 1
                                      , posColumn = 14
                                      }
                                    ( Position
                                        { posOffset = 14
                                        , posFile = "/tmp/foo.c"
                                        , posRow = 1
                                        , posColumn = 15
                                        }
                                    , 5
                                    )
                                    Name
                                      { nameId = 6
                                      } )
                              ]
                              Nothing
                              [] (
                              NodeInfo
                                Position
                                  { posOffset = 14
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 15
                                  }
                                ( Position
                                    { posOffset = 14
                                    , posFile = "/tmp/foo.c"
                                    , posRow = 1
                                    , posColumn = 15
                                    }
                                , 5
                                )
                                Name
                                  { nameId = 5
                                  } ) )
                        , Nothing
                        , Nothing
                        )
                      ] (
                      NodeInfo
                        Position
                          { posOffset = 8
                          , posFile = "/tmp/foo.c"
                          , posRow = 1
                          , posColumn = 9
                          }
                        ( Position
                            { posOffset = 14
                            , posFile = "/tmp/foo.c"
                            , posRow = 1
                            , posColumn = 15
                            }
                        , 5
                        )
                        Name
                          { nameId = 7
                          } )
                  , CDecl
                      [ CTypeSpec (
                          CVoidType (
                            NodeInfo
                              Position
                                { posOffset = 21
                                , posFile = "/tmp/foo.c"
                                , posRow = 1
                                , posColumn = 22
                                }
                              ( Position
                                  { posOffset = 21
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 22
                                  }
                              , 4
                              )
                              Name
                                { nameId = 8
                                } ) )
                      ]
                      [ ( Just (
                            CDeclr (
                              Just "ins" )
                              [ CPtrDeclr
                                  [] (
                                  NodeInfo
                                    Position
                                      { posOffset = 27
                                      , posFile = "/tmp/foo.c"
                                      , posRow = 1
                                      , posColumn = 28
                                      }
                                    ( Position
                                        { posOffset = 28
                                        , posFile = "/tmp/foo.c"
                                        , posRow = 1
                                        , posColumn = 29
                                        }
                                    , 3
                                    )
                                    Name
                                      { nameId = 11
                                      } )
                              , CPtrDeclr
                                  [] (
                                  NodeInfo
                                    Position
                                      { posOffset = 26
                                      , posFile = "/tmp/foo.c"
                                      , posRow = 1
                                      , posColumn = 27
                                      }
                                    ( Position
                                        { posOffset = 28
                                        , posFile = "/tmp/foo.c"
                                        , posRow = 1
                                        , posColumn = 29
                                        }
                                    , 3
                                    )
                                    Name
                                      { nameId = 12
                                      } )
                              ]
                              Nothing
                              [] (
                              NodeInfo
                                Position
                                  { posOffset = 28
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 29
                                  }
                                ( Position
                                    { posOffset = 28
                                    , posFile = "/tmp/foo.c"
                                    , posRow = 1
                                    , posColumn = 29
                                    }
                                , 3
                                )
                                Name
                                  { nameId = 10
                                  } ) )
                        , Nothing
                        , Nothing
                        )
                      ] (
                      NodeInfo
                        Position
                          { posOffset = 21
                          , posFile = "/tmp/foo.c"
                          , posRow = 1
                          , posColumn = 22
                          }
                        ( Position
                            { posOffset = 28
                            , posFile = "/tmp/foo.c"
                            , posRow = 1
                            , posColumn = 29
                            }
                        , 3
                        )
                        Name
                          { nameId = 13
                          } )
                  , CDecl
                      [ CTypeSpec (
                          CVoidType (
                            NodeInfo
                              Position
                                { posOffset = 33
                                , posFile = "/tmp/foo.c"
                                , posRow = 1
                                , posColumn = 34
                                }
                              ( Position
                                  { posOffset = 33
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 34
                                  }
                              , 4
                              )
                              Name
                                { nameId = 14
                                } ) )
                      ]
                      [ ( Just (
                            CDeclr (
                              Just "outs" )
                              [ CPtrDeclr
                                  [] (
                                  NodeInfo
                                    Position
                                      { posOffset = 39
                                      , posFile = "/tmp/foo.c"
                                      , posRow = 1
                                      , posColumn = 40
                                      }
                                    ( Position
                                        { posOffset = 40
                                        , posFile = "/tmp/foo.c"
                                        , posRow = 1
                                        , posColumn = 41
                                        }
                                    , 4
                                    )
                                    Name
                                      { nameId = 17
                                      } )
                              , CPtrDeclr
                                  [] (
                                  NodeInfo
                                    Position
                                      { posOffset = 38
                                      , posFile = "/tmp/foo.c"
                                      , posRow = 1
                                      , posColumn = 39
                                      }
                                    ( Position
                                        { posOffset = 40
                                        , posFile = "/tmp/foo.c"
                                        , posRow = 1
                                        , posColumn = 41
                                        }
                                    , 4
                                    )
                                    Name
                                      { nameId = 18
                                      } )
                              ]
                              Nothing
                              [] (
                              NodeInfo
                                Position
                                  { posOffset = 40
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 41
                                  }
                                ( Position
                                    { posOffset = 40
                                    , posFile = "/tmp/foo.c"
                                    , posRow = 1
                                    , posColumn = 41
                                    }
                                , 4
                                )
                                Name
                                  { nameId = 16
                                  } ) )
                        , Nothing
                        , Nothing
                        )
                      ] (
                      NodeInfo
                        Position
                          { posOffset = 33
                          , posFile = "/tmp/foo.c"
                          , posRow = 1
                          , posColumn = 34
                          }
                        ( Position
                            { posOffset = 40
                            , posFile = "/tmp/foo.c"
                            , posRow = 1
                            , posColumn = 41
                            }
                        , 4
                        )
                        Name
                          { nameId = 19
                          } )
                  , CDecl
                      [ CTypeSpec (
                          CIntType (
                            NodeInfo
                              Position
                                { posOffset = 46
                                , posFile = "/tmp/foo.c"
                                , posRow = 1
                                , posColumn = 47
                                }
                              ( Position
                                  { posOffset = 46
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 47
                                  }
                              , 3
                              )
                              Name
                                { nameId = 21
                                } ) )
                      ]
                      [ ( Just (
                            CDeclr (
                              Just "n" )
                              []
                              Nothing
                              [] (
                              NodeInfo
                                Position
                                  { posOffset = 50
                                  , posFile = "/tmp/foo.c"
                                  , posRow = 1
                                  , posColumn = 51
                                  }
                                ( Position
                                    { posOffset = 50
                                    , posFile = "/tmp/foo.c"
                                    , posRow = 1
                                    , posColumn = 51
                                    }
                                , 1
                                )
                                Name
                                  { nameId = 22
                                  } ) )
                        , Nothing
                        , Nothing
                        )
                      ] (
                      NodeInfo
                        Position
                          { posOffset = 46
                          , posFile = "/tmp/foo.c"
                          , posRow = 1
                          , posColumn = 47
                          }
                        ( Position
                            { posOffset = 50
                            , posFile = "/tmp/foo.c"
                            , posRow = 1
                            , posColumn = 51
                            }
                        , 1
                        )
                        Name
                          { nameId = 23
                          } )
                  ]
                , False
                ) )
              [] (
              NodeInfo
                Position
                  { posOffset = 7
                  , posFile = "/tmp/foo.c"
                  , posRow = 1
                  , posColumn = 8
                  }
                ( Position
                    { posOffset = 51
                    , posFile = "/tmp/foo.c"
                    , posRow = 1
                    , posColumn = 52
                    }
                , 1
                )
                Name
                  { nameId = 24
                  } )
          ]
          Nothing
          [] (
          NodeInfo
            Position
              { posOffset = 4
              , posFile = "/tmp/foo.c"
              , posRow = 1
              , posColumn = 5
              }
            ( Position
                { posOffset = 4
                , posFile = "/tmp/foo.c"
                , posRow = 1
                , posColumn = 5
                }
            , 3
            )
            Name
              { nameId = 2
              } ) )
        [] (
        CCompound
          []
          [] (
          NodeInfo
            Position
              { posOffset = 53
              , posFile = "/tmp/foo.c"
              , posRow = 1
              , posColumn = 54
              }
            ( Position
                { posOffset = 55
                , posFile = "/tmp/foo.c"
                , posRow = 1
                , posColumn = 56
                }
            , 1
            )
            Name
              { nameId = 25
              } ) ) (
        NodeInfo
          Position
            { posOffset = 0
            , posFile = "/tmp/foo.c"
            , posRow = 1
            , posColumn = 1
            }
          ( Position
              { posOffset = 55
              , posFile = "/tmp/foo.c"
              , posRow = 1
              , posColumn = 56
              }
          , 1
          )
          Name
            { nameId = 26
            } ) )
  ] (
  NodeInfo
    Position
      { posOffset = 0
      , posFile = "/tmp/foo.c"
      , posRow = 1
      , posColumn = 1
      }
    ( Position
        { posOffset = 55
        , posFile = "/tmp/foo.c"
        , posRow = 1
        , posColumn = 56
        }
    , 1
    )
    Name
      { nameId = 27
      } )
*Main> 


Replacing all the NodeInfo nodes by ni this gives:


[1] http://hackage.haskell.org/packages/archive/language-c/0.3.2/doc/html/Language-C-Parser.html



[Reply][About]
[<<][meta][>>][..]