Skip to content

Bad AST for the following code #63

Closed

Description

@genotrance
# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a
                                        * contiguous array of 32 bit wide
                                        * big-endian values. */

typedef struct SHA256state_st {
    SHA_LONG h[8];
    SHA_LONG Nl, Nh;
    SHA_LONG data[SHA_LBLOCK];
    unsigned int num, md_len;
} SHA256_CTX;

Results in bad AST with errors. Comment style confuses tree-sitter.

(translation_unit 1 1 359
 (preproc_def 1 1 73
  (identifier 1 10 13)
  (preproc_arg 1 23 50)
 )
 (expression_statement 2 41 12
  (pointer_expression 2 41 12
   (identifier 2 43 10)
  )
 )
 (declaration 2 54 15
  (type_identifier 2 54 5)
  (ERROR 2 60 5
   (identifier 2 60 2)
   (number_literal 2 63 2)
  )
  (identifier 2 66 3)
 )
 (expression_statement 2 70 77
  (binary_expression 2 70 77
   (binary_expression 2 70 50
    (identifier 2 70 4)
    (identifier 3 43 3)
   )
   (ERROR 3 47 14
    (identifier 3 47 6)
    (identifier 3 54 6)
   )
   (binary_expression 3 62 11
    (pointer_expression 3 62 1
     (identifier 3 63 0)
    )
    (identifier 5 1 7)
   )
  )
 )
 (declaration 5 9 138
  (struct_specifier 5 9 126
   (type_identifier 5 16 14)
   (field_declaration_list 5 31 104
    (field_declaration 6 5 14
     (type_identifier 6 5 8)
     (array_declarator 6 14 4
      (field_identifier 6 14 1)
      (number_literal 6 16 1)
     )
    )
    (field_declaration 7 5 16
     (type_identifier 7 5 8)
     (field_identifier 7 14 2)
     (field_identifier 7 18 2)
    )
    (field_declaration 8 5 26
     (type_identifier 8 5 8)
     (array_declarator 8 14 16
      (field_identifier 8 14 4)
      (identifier 8 19 10)
     )
    )
    (field_declaration 9 5 25
     (sized_type_specifier 9 5 12
      (primitive_type 9 14 3)
     )
     (field_identifier 9 18 3)
     (field_identifier 9 23 6)
    )
   )
  )
  (identifier 10 3 10)
 )
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions