Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c_parser: support parenthesized compounds #423

Merged
merged 3 commits into from Jul 7, 2021
Merged

c_parser: support parenthesized compounds #423

merged 3 commits into from Jul 7, 2021

Commits on Jul 7, 2021

  1. c_parser: support parenthesized compounds

    Support parenthesized compound statements as described here:
        https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    
    Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
    Jordan Yates committed Jul 7, 2021
    Copy the full SHA
    e8d47fa View commit details
    Browse the repository at this point in the history
  2. test_c_parser: support additional initializers

    Add support to `expand_init` for additional `c_ast` types. If a type
    is not explicitly handled, return the type name instead of `None`.
    
    Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
    Jordan Yates committed Jul 7, 2021
    Copy the full SHA
    744f1f1 View commit details
    Browse the repository at this point in the history
  3. test_c_parser: test parenthesized compounds

    Add parsing tests for various situations of parenthesized compound
    statements. The complete tree generated by the test string is:
    
    ```
    FileAST:
      FuncDef:
        Decl: foo, [], [], []
          FuncDecl:
            TypeDecl: foo, []
              IdentifierType: ['void']
        Compound:
          Decl: a, [], [], []
            TypeDecl: a, []
              IdentifierType: ['int']
          Compound:
          Compound:
            Constant: int, 1
          Compound:
            Constant: int, 1
            Constant: int, 2
          Decl: b, [], [], []
            TypeDecl: b, []
              IdentifierType: ['int']
            Compound:
              Constant: int, 1
          Decl: c, [], [], []
            TypeDecl: c, []
              IdentifierType: ['int']
          Decl: d, [], [], []
            TypeDecl: d, []
              IdentifierType: ['int']
            Compound:
              Decl: x, [], [], []
                TypeDecl: x, []
                  IdentifierType: ['int']
                Constant: int, 1
              BinaryOp: +
                ID: x
                Constant: int, 2
          Assignment: =
            ID: a
            Compound:
              Decl: x, [], [], []
                TypeDecl: x, []
                  IdentifierType: ['int']
                Constant: int, 1
              BinaryOp: *
                Constant: int, 2
                ID: x
    ```
    
    Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
    Jordan Yates committed Jul 7, 2021
    Copy the full SHA
    0994726 View commit details
    Browse the repository at this point in the history