Skip to content

Commit f83adb5

Browse files
committed
Unified: regenerate AST
1 parent 5608369 commit f83adb5

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

unified/ql/lib/codeql/unified/Ast.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ module Unified {
6161
override string getAPrimaryQlClass() { result = "Token" }
6262
}
6363

64+
/** A trivia token, such as a comment, preserved from the original parse tree. */
65+
class TriviaToken extends @unified_trivia_token, AstNode {
66+
/** Gets the source text of this trivia token. */
67+
final string getValue() { unified_trivia_tokeninfo(this, _, result) }
68+
69+
/** Gets a string representation of this element. */
70+
final override string toString() { result = this.getValue() }
71+
72+
/** Gets the name of the primary QL class for this element. */
73+
override string getAPrimaryQlClass() { result = "TriviaToken" }
74+
}
75+
6476
/** Gets the file containing the given `node`. */
6577
private @file getNodeFile(@unified_ast_node node) {
6678
exists(@location_default loc | unified_ast_node_location(node, loc) |

unified/ql/lib/unified.dbscheme

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@ case @unified_token.kind of
334334
;
335335

336336

337-
@unified_ast_node = @unified_apply_pattern | @unified_binary_expr | @unified_block_stmt | @unified_call_expr | @unified_expr_condition | @unified_expr_stmt | @unified_guard_if_stmt | @unified_if_stmt | @unified_lambda_expr | @unified_let_pattern_condition | @unified_member_access_expr | @unified_name_expr | @unified_parameter | @unified_sequence_condition | @unified_token | @unified_top_level | @unified_tuple_pattern | @unified_unary_expr | @unified_var_pattern | @unified_variable_declaration_stmt | @unified_variable_declarator
337+
unified_trivia_tokeninfo(
338+
unique int id: @unified_trivia_token,
339+
int kind: int ref,
340+
string value: string ref
341+
);
342+
343+
@unified_ast_node = @unified_apply_pattern | @unified_binary_expr | @unified_block_stmt | @unified_call_expr | @unified_expr_condition | @unified_expr_stmt | @unified_guard_if_stmt | @unified_if_stmt | @unified_lambda_expr | @unified_let_pattern_condition | @unified_member_access_expr | @unified_name_expr | @unified_parameter | @unified_sequence_condition | @unified_token | @unified_top_level | @unified_trivia_token | @unified_tuple_pattern | @unified_unary_expr | @unified_var_pattern | @unified_variable_declaration_stmt | @unified_variable_declarator
338344

339345
unified_ast_node_location(
340346
unique int node: @unified_ast_node ref,

0 commit comments

Comments
 (0)