Changes between Version 1 and Version 2 of SemanticQuery/Examples
- Timestamp:
- Apr 11, 2012, 1:11:32 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SemanticQuery/Examples
v1 v2 1 1 = Query Examples = 2 2 3 == Basic queries == 4 In this language we can build difficult queries from lot of very simple queries. Here are some examples for simple ones: 3 With our query language we can build either simple or more complex, compound quries. In the followings there are some useful and often used queries with different complexity. 5 4 5 Returns a list of expressions which call the pointed function: 6 6 {{{ 7 7 @fun.refs 8 8 }}} 9 Returns a list of expressions which call the pointed function.10 9 10 Returns all function calls from current module group by the module's own functions: 11 11 {{{ 12 12 @file.funs.calls 13 13 }}} 14 Returns all function calls from current module group by the module's own functions.15 14 15 Returns all functions which have 3 arguments: 16 16 {{{ 17 17 @file.funs[arity==3] 18 18 }}} 19 Returns all functions which have 3 arguments.20 19 21 == Advanced queries == 22 Let's see some useful queries: 23 20 Returns all functions which have a variable named "Expl". It useful when we want to know which functions use variables with same name: 24 21 {{{ 25 22 @file.funs.vars[name=="Expl"] 26 23 }}} 27 Returns all functions which have a variable named "Expl". It useful when we want to know which functions use variables with same name.28 24 25 26 Returns all io:format calls (this query is very useful when you have finished your software, and you want to find all debug messages): 29 27 {{{ 30 28 mods[name=="io"].funs[name==format].refs 31 29 }}} 32 Returns all io:format calls, this query is very useful when you have finished your software, and you want to find all debug messages.33 30 31 For example we stand in a variable, and run this query, we get information about the variable gets its value from where. This functionality uses [wiki:DataFlow data-flow analysis]. 34 32 {{{ 35 33 @expr.origin 36 34 }}} 37 For example we stand in a variable, and run this query, we get information about the variable gets its value from where. This functionality uses [wiki:DataFlow data-flow analysis].38 35 36 Returns information about the function gets its return value from where and how its calculated: 39 37 {{{ 40 38 @fun.refs.origin 41 39 }}} 42 Returns information about the function gets its return value from where and how its calculated.43 40 44 41 == Checking coding convensions ==