Is match really semantically? #1260
-
On https://ast-grep.github.io/advanced/core-concepts.html is written
Yet, I wonder if it is really the semantic meaning, shouldn't we find two instances when
is used to search this code int i = 1;
int j = 0x1; as both assign the value 1 to the variable, yet use a different representation thereof. And similarly,
is used to search this C++ code int f();
int g(void); as both declare a function without any parameters. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I will change the wording of the doc. ast-grep is, as its name going, based on syntax tree. It is structural. If you think ast-grep does not suit your need, you can also try https://semgrep.dev/ or https://about.grit.io/ |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
And also, if you read the whole doc, you should understand ast-grep is base on tree structure. It also has a large Textual vs Structural title on the doc.
Nearly all the paragraphs on the page is discussing the tree-structure.
Implementation wise, semantics require special logic for each language. The fact that
int f()
andint f(void)
is equivalent is purely C/C++ semantics. They are NOT reflected in the AST.