Changes between Initial Version and Version 1 of SemanticQuery/ExpressionEntity


Ignore:
Timestamp:
Feb 20, 2012, 8:07:24 AM (13 years ago)
Author:
manualwiki
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SemanticQuery/ExpressionEntity

    v1 v1  
     1= Expression entity = 
     2 
     3Expressions are the basic syntactic elements of Erlang, and they are represented by expression entities. This is the only syntactic entity in the query language, it is mainly useful to express relations that cannot be calculated by selectors of other entities. Patterns and guards are also represented as expressions, however, there are syntactic units which are not expressions and cannot be handled in this query language, like clauses and module attributes. 
     4 
     5== Initial selector ==   
     6* {{{@expr}}} a query can be started from the currently selected expression using this selector. 
     7 
     8== Selectors == 
     9 
     10The following selectors work on expression entities. 
     11 
     12Note that an expression is always treated as a single unit with its subexpressions, even in case expressions with more clauses like {{{if}}} or {{{case}}}. 
     13 
     14''After the name of the selector between parentheses you can find the type of the elements in the resulted set.'' 
     15 
     16* {{{fundef}}} (''function''): returns the function entity which contains the expression. 
     17* {{{funs}}} (''function''): returns every function entity referred directly in the expression. 
     18* {{{vars}}} (''variable''): returns every variable entity referred in the expression. 
     19* {{{records}}} (''record''): returns every record entity referred in the expression. 
     20* {{{macros}}} (''macro''): returns every macro entity referred in the expression. 
     21* {{{sub}}} (''expression''): returns the set of expressions that are nested in the expression in any depth. This is mainly useful together with the {{{type}}} property. 
     22* {{{top}}} (''expression''): returns the expression's top-level expression. 
     23* {{{file}}} (''file''): returns the file entity where the expression is located. 
     24* {{{origin}}} (''expression''): this is an experimental selector, which returns the origin of the expression's value determined by [wiki:DataFlow data flow analysis]. 
     25* {{{reach}}} (''expression''): this is an experimental selector, which returns the places where the expression's value is copied, determined by [wiki:DataFLow data flow analysis]. 
     26 
     27== Properties == 
     28 
     29These properties are defined for expression entities. 
     30 
     31Note that some of them depends of the context of the expression, which makes possible selecting tail calls or indexing function arguments. 
     32 
     33* {{{type}}} (''atom''): returns the type of the expression. The type can 
     34  be one of the following: 
     35  * {{{application}}}: {{{func(Arg1, ...)}}} 
     36  * {{{implicit_fun}}}: {{{fun func/1}}} 
     37  * {{{parenthesis}}}: {{{(Expr)}}} 
     38  * {{{tuple}}}: {{{\{A, B, C\}}} 
     39  * {{{binary}}}: {{{<<3.14/float>>}}} 
     40  * {{{binary_field}}}: {{{3.14/float}}} in the previous binary 
     41  * {{{record_access}}}: {{{Rec#name.fld}}} 
     42  * {{{record_expr}}}: {{{#name{fld=Val} }}} 
     43  * {{{record_update}}}: {{{Rec#name{fld=Val} }}} 
     44  * {{{record_index}}}: {{{#name.fld}}} 
     45  * {{{match_expr}}}: {{{Pattern = Expr}}} 
     46  * {{{send_expr}}}: {{{Pid ! Expr}}} 
     47  * {{{'bnot'}}}: {{{bnot Expr}}} (there are other prefix operators like this) 
     48  * {{{'+'}}}: {{{A + B}}}  (there are other infix operators like this) 
     49  * {{{cons}}}: {{{[1, 2, 3 | Tail]}}}  
     50  * {{{list}}}: {{{1, 2, 3}}} in the previous list 
     51  * {{{nil}}}: {{{[]}}} 
     52  * {{{atom}}}, {{{char}}}, {{{float}}}, {{{integer}}}, {{{string}}}: constants 
     53  * {{{variable}}}: {{{Var}}} 
     54  * {{{catch_expr}}}: {{{catch Expr}}} 
     55  * {{{list_comp}}}: {{{[A || A <- L, A > 0]}}} 
     56  * {{{list_gen}}}: {{{A <- L}}} in the previous list comprehension 
     57  * {{{filter}}}: {{{A > 0}}} in the previous list comprehension 
     58  * {{{bin_comp}}}: {{{ {<< <<C/utf8>> || <<C:16>> <= Str >>} }}} 
     59  * {{{binary_gen}}}: {{{<<C:16>> <= Str}}} in the previous binary comprehension 
     60  * {{{block_expr}}}: {{{begin ... end}}} 
     61  * {{{if_expr}}}: {{{if ... end}}} 
     62  * {{{fun_expr}}}: {{{fun () -> ... end}}} 
     63  * {{{receive_expr}}}: {{{receive ... end}}} 
     64  * {{{case_expr}}}: {{{case Expr of ... end}}} 
     65  * {{{try_expr}}}: {{{try ... end}}} 
     66 
     67* {{{value}}}: returns the value of the expression. It is either the value of a constant expression or an operator of an operator-based expression. 
     68* {{{class}}} (''atom''): returns the class of the expression: it either can be {{{expr}}} (stands for single expressions), {{{pattern}}}, or {{{guard}}}. 
     69* {{{last}}} (''bool''): returns true if the expression is the last expression of the clause. 
     70* {{{index}}} (''int''): returns the index of the expression in the containing expression list. 
     71* {{{tailcall}}} (''bool''): returns true if the expression is a tail call. Tail call expressions are function applications, which are the last expressions of their containing clause.