зеркало из https://github.com/github/codeql.git
QL for QL: sync changes from Ruby
In particular, update the dbscheme to put location columns in a single table.
This commit is contained in:
Родитель
9217d0e1b9
Коммит
3ee109731a
|
@ -402,11 +402,12 @@ impl Visitor<'_> {
|
|||
match &table.kind {
|
||||
EntryKind::Token { kind_id, .. } => {
|
||||
self.trap_writer.add_tuple(
|
||||
&format!("{}_ast_node_parent", self.language_prefix),
|
||||
&format!("{}_ast_node_info", self.language_prefix),
|
||||
vec![
|
||||
Arg::Label(id),
|
||||
Arg::Label(parent_id),
|
||||
Arg::Int(parent_index),
|
||||
Arg::Label(loc),
|
||||
],
|
||||
);
|
||||
self.trap_writer.add_tuple(
|
||||
|
@ -415,7 +416,6 @@ impl Visitor<'_> {
|
|||
Arg::Label(id),
|
||||
Arg::Int(*kind_id),
|
||||
sliced_source_arg(self.source, node),
|
||||
Arg::Label(loc),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -425,16 +425,16 @@ impl Visitor<'_> {
|
|||
} => {
|
||||
if let Some(args) = self.complex_node(&node, fields, &child_nodes, id) {
|
||||
self.trap_writer.add_tuple(
|
||||
&format!("{}_ast_node_parent", self.language_prefix),
|
||||
&format!("{}_ast_node_info", self.language_prefix),
|
||||
vec![
|
||||
Arg::Label(id),
|
||||
Arg::Label(parent_id),
|
||||
Arg::Int(parent_index),
|
||||
Arg::Label(loc),
|
||||
],
|
||||
);
|
||||
let mut all_args = vec![Arg::Label(id)];
|
||||
all_args.extend(args);
|
||||
all_args.push(Arg::Label(loc));
|
||||
self.trap_writer.add_tuple(table_name, all_args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,15 +232,6 @@ fn convert_nodes(
|
|||
});
|
||||
}
|
||||
|
||||
// Finally, the type's defining table also includes the location.
|
||||
main_table.columns.push(dbscheme::Column {
|
||||
unique: false,
|
||||
db_type: dbscheme::DbColumnType::Int,
|
||||
name: "loc",
|
||||
ql_type: ql::Type::At("location"),
|
||||
ql_type_is_ref: true,
|
||||
});
|
||||
|
||||
entries.push(dbscheme::Entry::Table(main_table));
|
||||
}
|
||||
node_types::EntryKind::Token { .. } => {}
|
||||
|
@ -250,18 +241,24 @@ fn convert_nodes(
|
|||
(entries, ast_node_members, token_kinds)
|
||||
}
|
||||
|
||||
/// Creates a dbscheme table entry representing the parent relation for AST nodes.
|
||||
/// Creates a dbscheme table specifying the parent node and location for each
|
||||
/// AST node.
|
||||
///
|
||||
/// # Arguments
|
||||
/// - `name` - the name of both the table to create and the node parent type.
|
||||
/// - `name` - the name of the table to create.
|
||||
/// - `parent_name` - the name of the parent type.
|
||||
/// - `ast_node_name` - the name of the node child type.
|
||||
fn create_ast_node_parent_table<'a>(name: &'a str, ast_node_name: &'a str) -> dbscheme::Table<'a> {
|
||||
fn create_ast_node_info_table<'a>(
|
||||
name: &'a str,
|
||||
parent_name: &'a str,
|
||||
ast_node_name: &'a str,
|
||||
) -> dbscheme::Table<'a> {
|
||||
dbscheme::Table {
|
||||
name,
|
||||
columns: vec![
|
||||
dbscheme::Column {
|
||||
db_type: dbscheme::DbColumnType::Int,
|
||||
name: "child",
|
||||
name: "node",
|
||||
unique: false,
|
||||
ql_type: ql::Type::At(ast_node_name),
|
||||
ql_type_is_ref: true,
|
||||
|
@ -270,7 +267,7 @@ fn create_ast_node_parent_table<'a>(name: &'a str, ast_node_name: &'a str) -> db
|
|||
db_type: dbscheme::DbColumnType::Int,
|
||||
name: "parent",
|
||||
unique: false,
|
||||
ql_type: ql::Type::At(name),
|
||||
ql_type: ql::Type::At(parent_name),
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
dbscheme::Column {
|
||||
|
@ -280,6 +277,13 @@ fn create_ast_node_parent_table<'a>(name: &'a str, ast_node_name: &'a str) -> db
|
|||
ql_type: ql::Type::Int,
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
dbscheme::Column {
|
||||
unique: false,
|
||||
db_type: dbscheme::DbColumnType::Int,
|
||||
name: "loc",
|
||||
ql_type: ql::Type::At("location"),
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
],
|
||||
keysets: Some(vec!["parent", "parent_index"]),
|
||||
}
|
||||
|
@ -311,13 +315,6 @@ fn create_tokeninfo<'a>(name: &'a str, type_name: &'a str) -> dbscheme::Table<'a
|
|||
ql_type: ql::Type::String,
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
dbscheme::Column {
|
||||
unique: false,
|
||||
db_type: dbscheme::DbColumnType::Int,
|
||||
name: "loc",
|
||||
ql_type: ql::Type::At("location"),
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -605,15 +602,16 @@ fn main() -> std::io::Result<()> {
|
|||
)?;
|
||||
ql::write(
|
||||
&mut ql_writer,
|
||||
&[
|
||||
ql::TopLevel::Import("codeql.files.FileSystem"),
|
||||
ql::TopLevel::Import("codeql.Locations"),
|
||||
],
|
||||
&[ql::TopLevel::Import(ql::Import {
|
||||
module: "codeql.Locations",
|
||||
alias: Some("L"),
|
||||
})],
|
||||
)?;
|
||||
|
||||
for language in languages {
|
||||
let prefix = node_types::to_snake_case(&language.name);
|
||||
let ast_node_name = format!("{}_ast_node", &prefix);
|
||||
let node_info_table_name = format!("{}_ast_node_info", &prefix);
|
||||
let ast_node_parent_name = format!("{}_ast_node_parent", &prefix);
|
||||
let token_name = format!("{}_token", &prefix);
|
||||
let tokeninfo_name = format!("{}_tokeninfo", &prefix);
|
||||
|
@ -636,7 +634,8 @@ fn main() -> std::io::Result<()> {
|
|||
name: &ast_node_parent_name,
|
||||
members: [&ast_node_name, "file"].iter().cloned().collect(),
|
||||
}),
|
||||
dbscheme::Entry::Table(create_ast_node_parent_table(
|
||||
dbscheme::Entry::Table(create_ast_node_info_table(
|
||||
&node_info_table_name,
|
||||
&ast_node_parent_name,
|
||||
&ast_node_name,
|
||||
)),
|
||||
|
@ -646,7 +645,7 @@ fn main() -> std::io::Result<()> {
|
|||
let mut body = vec![
|
||||
ql::TopLevel::Class(ql_gen::create_ast_node_class(
|
||||
&ast_node_name,
|
||||
&ast_node_parent_name,
|
||||
&node_info_table_name,
|
||||
)),
|
||||
ql::TopLevel::Class(ql_gen::create_token_class(&token_name, &tokeninfo_name)),
|
||||
ql::TopLevel::Class(ql_gen::create_reserved_word_class(&reserved_word_name)),
|
||||
|
|
|
@ -4,20 +4,35 @@ use std::fmt;
|
|||
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||
pub enum TopLevel<'a> {
|
||||
Class(Class<'a>),
|
||||
Import(&'a str),
|
||||
Import(Import<'a>),
|
||||
Module(Module<'a>),
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for TopLevel<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
TopLevel::Import(x) => write!(f, "private import {}", x),
|
||||
TopLevel::Import(imp) => write!(f, "{}", imp),
|
||||
TopLevel::Class(cls) => write!(f, "{}", cls),
|
||||
TopLevel::Module(m) => write!(f, "{}", m),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Import<'a> {
|
||||
pub module: &'a str,
|
||||
pub alias: Option<&'a str>,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Import<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "import {}", &self.module)?;
|
||||
if let Some(name) = &self.alias {
|
||||
write!(f, " as {}", name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Class<'a> {
|
||||
pub qldoc: Option<String>,
|
||||
|
@ -53,6 +68,7 @@ impl<'a> fmt::Display for Class<'a> {
|
|||
qldoc: None,
|
||||
name: self.name,
|
||||
overridden: false,
|
||||
is_final: false,
|
||||
return_type: None,
|
||||
formal_parameters: vec![],
|
||||
body: charpred.clone(),
|
||||
|
@ -224,6 +240,7 @@ pub struct Predicate<'a> {
|
|||
pub qldoc: Option<String>,
|
||||
pub name: &'a str,
|
||||
pub overridden: bool,
|
||||
pub is_final: bool,
|
||||
pub return_type: Option<Type<'a>>,
|
||||
pub formal_parameters: Vec<FormalParameter<'a>>,
|
||||
pub body: Expression<'a>,
|
||||
|
@ -234,6 +251,9 @@ impl<'a> fmt::Display for Predicate<'a> {
|
|||
if let Some(qldoc) = &self.qldoc {
|
||||
write!(f, "/** {} */", qldoc)?;
|
||||
}
|
||||
if self.is_final {
|
||||
write!(f, "final ")?;
|
||||
}
|
||||
if self.overridden {
|
||||
write!(f, "override ")?;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::BTreeSet;
|
|||
|
||||
/// Creates the hard-coded `AstNode` class that acts as a supertype of all
|
||||
/// classes we generate.
|
||||
pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) -> ql::Class<'a> {
|
||||
pub fn create_ast_node_class<'a>(ast_node: &'a str, node_info_table: &'a str) -> ql::Class<'a> {
|
||||
// Default implementation of `toString` calls `this.getAPrimaryQlClass()`
|
||||
let to_string = ql::Predicate {
|
||||
qldoc: Some(String::from(
|
||||
|
@ -11,6 +11,7 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
)),
|
||||
name: "toString",
|
||||
overridden: false,
|
||||
is_final: false,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Equals(
|
||||
|
@ -22,12 +23,23 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
)),
|
||||
),
|
||||
};
|
||||
let get_location = create_none_predicate(
|
||||
Some(String::from("Gets the location of this element.")),
|
||||
"getLocation",
|
||||
false,
|
||||
Some(ql::Type::Normal("Location")),
|
||||
);
|
||||
let get_location = ql::Predicate {
|
||||
name: "getLocation",
|
||||
qldoc: Some(String::from("Gets the location of this element.")),
|
||||
overridden: false,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::Normal("L::Location")),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Pred(
|
||||
node_info_table,
|
||||
vec![
|
||||
ql::Expression::Var("this"),
|
||||
ql::Expression::Var("_"), // parent
|
||||
ql::Expression::Var("_"), // parent index
|
||||
ql::Expression::Var("result"), // location
|
||||
],
|
||||
),
|
||||
};
|
||||
let get_a_field_or_child = create_none_predicate(
|
||||
Some(String::from("Gets a field or child node of this node.")),
|
||||
"getAFieldOrChild",
|
||||
|
@ -38,14 +50,16 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
qldoc: Some(String::from("Gets the parent of this element.")),
|
||||
name: "getParent",
|
||||
overridden: false,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::Normal("AstNode")),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Pred(
|
||||
ast_node_parent,
|
||||
node_info_table,
|
||||
vec![
|
||||
ql::Expression::Var("this"),
|
||||
ql::Expression::Var("result"),
|
||||
ql::Expression::Var("_"),
|
||||
ql::Expression::Var("_"), // parent index
|
||||
ql::Expression::Var("_"), // location
|
||||
],
|
||||
),
|
||||
};
|
||||
|
@ -55,14 +69,16 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
)),
|
||||
name: "getParentIndex",
|
||||
overridden: false,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::Int),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Pred(
|
||||
ast_node_parent,
|
||||
node_info_table,
|
||||
vec![
|
||||
ql::Expression::Var("this"),
|
||||
ql::Expression::Var("_"),
|
||||
ql::Expression::Var("result"),
|
||||
ql::Expression::Var("_"), // parent
|
||||
ql::Expression::Var("result"), // parent index
|
||||
ql::Expression::Var("_"), // location
|
||||
],
|
||||
),
|
||||
};
|
||||
|
@ -72,6 +88,7 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
)),
|
||||
name: "getAPrimaryQlClass",
|
||||
overridden: false,
|
||||
is_final: false,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Equals(
|
||||
|
@ -87,6 +104,7 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
),
|
||||
name: "getPrimaryQlClasses",
|
||||
overridden: false,
|
||||
is_final: false,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Equals(
|
||||
|
@ -123,29 +141,23 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
|
|||
}
|
||||
|
||||
pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Class<'a> {
|
||||
let tokeninfo_arity = 4;
|
||||
let tokeninfo_arity = 3; // id, kind, value
|
||||
let get_value = ql::Predicate {
|
||||
qldoc: Some(String::from("Gets the value of this token.")),
|
||||
name: "getValue",
|
||||
overridden: false,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: create_get_field_expr_for_column_storage("result", tokeninfo, 1, tokeninfo_arity),
|
||||
};
|
||||
let get_location = ql::Predicate {
|
||||
qldoc: Some(String::from("Gets the location of this token.")),
|
||||
name: "getLocation",
|
||||
overridden: true,
|
||||
return_type: Some(ql::Type::Normal("Location")),
|
||||
formal_parameters: vec![],
|
||||
body: create_get_field_expr_for_column_storage("result", tokeninfo, 2, tokeninfo_arity),
|
||||
};
|
||||
let to_string = ql::Predicate {
|
||||
qldoc: Some(String::from(
|
||||
"Gets a string representation of this element.",
|
||||
)),
|
||||
name: "toString",
|
||||
overridden: true,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Equals(
|
||||
|
@ -167,9 +179,8 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
|
|||
characteristic_predicate: None,
|
||||
predicates: vec![
|
||||
get_value,
|
||||
get_location,
|
||||
to_string,
|
||||
create_get_a_primary_ql_class("Token"),
|
||||
create_get_a_primary_ql_class("Token", false),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +188,7 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
|
|||
// Creates the `ReservedWord` class.
|
||||
pub fn create_reserved_word_class(db_name: &str) -> ql::Class {
|
||||
let class_name = "ReservedWord";
|
||||
let get_a_primary_ql_class = create_get_a_primary_ql_class(class_name);
|
||||
let get_a_primary_ql_class = create_get_a_primary_ql_class(class_name, true);
|
||||
ql::Class {
|
||||
qldoc: Some(String::from("A reserved word.")),
|
||||
name: class_name,
|
||||
|
@ -201,6 +212,7 @@ fn create_none_predicate<'a>(
|
|||
qldoc,
|
||||
name,
|
||||
overridden,
|
||||
is_final: false,
|
||||
return_type,
|
||||
formal_parameters: Vec::new(),
|
||||
body: ql::Expression::Pred("none", vec![]),
|
||||
|
@ -209,13 +221,14 @@ fn create_none_predicate<'a>(
|
|||
|
||||
/// Creates an overridden `getAPrimaryQlClass` predicate that returns the given
|
||||
/// name.
|
||||
fn create_get_a_primary_ql_class(class_name: &str) -> ql::Predicate {
|
||||
fn create_get_a_primary_ql_class(class_name: &str, is_final: bool) -> ql::Predicate {
|
||||
ql::Predicate {
|
||||
qldoc: Some(String::from(
|
||||
"Gets the name of the primary QL class for this element.",
|
||||
)),
|
||||
name: "getAPrimaryQlClass",
|
||||
overridden: true,
|
||||
is_final,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Equals(
|
||||
|
@ -225,55 +238,6 @@ fn create_get_a_primary_ql_class(class_name: &str) -> ql::Predicate {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates the `getLocation` predicate.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `def_table` - the name of the table that defines the entity and its location.
|
||||
/// `arity` - the total number of columns in the table
|
||||
fn create_get_location_predicate(def_table: &str, arity: usize) -> ql::Predicate {
|
||||
ql::Predicate {
|
||||
qldoc: Some(String::from("Gets the location of this element.")),
|
||||
name: "getLocation",
|
||||
overridden: true,
|
||||
return_type: Some(ql::Type::Normal("Location")),
|
||||
formal_parameters: vec![],
|
||||
// body of the form: foo_bar_def(_, _, ..., result)
|
||||
body: ql::Expression::Pred(
|
||||
def_table,
|
||||
[
|
||||
vec![ql::Expression::Var("this")],
|
||||
vec![ql::Expression::Var("_"); arity - 2],
|
||||
vec![ql::Expression::Var("result")],
|
||||
]
|
||||
.concat(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates the `getText` predicate for a leaf node.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `def_table` - the name of the table that defines the entity and its text.
|
||||
fn create_get_text_predicate(def_table: &str) -> ql::Predicate {
|
||||
ql::Predicate {
|
||||
qldoc: Some(String::from("Gets the text content of this element.")),
|
||||
name: "getText",
|
||||
overridden: false,
|
||||
return_type: Some(ql::Type::String),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Pred(
|
||||
def_table,
|
||||
vec![
|
||||
ql::Expression::Var("this"),
|
||||
ql::Expression::Var("result"),
|
||||
ql::Expression::Var("_"),
|
||||
],
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an expression to get a field that's defined as a column in the parent's table.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -473,6 +437,7 @@ fn create_field_getters<'a>(
|
|||
qldoc: Some(qldoc),
|
||||
name: &field.getter_name,
|
||||
overridden: false,
|
||||
is_final: true,
|
||||
return_type,
|
||||
formal_parameters,
|
||||
body,
|
||||
|
@ -497,7 +462,8 @@ pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel> {
|
|||
match &node.kind {
|
||||
node_types::EntryKind::Token { kind_id: _ } => {
|
||||
if type_name.named {
|
||||
let get_a_primary_ql_class = create_get_a_primary_ql_class(&node.ql_class_name);
|
||||
let get_a_primary_ql_class =
|
||||
create_get_a_primary_ql_class(&node.ql_class_name, true);
|
||||
let mut supertypes: BTreeSet<ql::Type> = BTreeSet::new();
|
||||
supertypes.insert(ql::Type::At(&node.dbscheme_name));
|
||||
supertypes.insert(ql::Type::Normal("Token"));
|
||||
|
@ -532,20 +498,17 @@ pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel> {
|
|||
name: main_table_name,
|
||||
fields,
|
||||
} => {
|
||||
// Count how many columns there will be in the main table.
|
||||
// There will be:
|
||||
// - one for the id
|
||||
// - one for the location
|
||||
// - one for each field that's stored as a column
|
||||
// - if there are no fields, one for the text column.
|
||||
let main_table_arity = 2 + if fields.is_empty() {
|
||||
1
|
||||
} else {
|
||||
fields
|
||||
.iter()
|
||||
.filter(|&f| matches!(f.storage, node_types::Storage::Column { .. }))
|
||||
.count()
|
||||
};
|
||||
if fields.is_empty() {
|
||||
panic!("Encountered node '{}' with no fields", type_name.kind);
|
||||
}
|
||||
|
||||
// Count how many columns there will be in the main table. There
|
||||
// will be one for the id, plus one for each field that's stored
|
||||
// as a column.
|
||||
let main_table_arity = 1 + fields
|
||||
.iter()
|
||||
.filter(|&f| matches!(f.storage, node_types::Storage::Column { .. }))
|
||||
.count();
|
||||
|
||||
let main_class_name = &node.ql_class_name;
|
||||
let mut main_class = ql::Class {
|
||||
|
@ -559,48 +522,40 @@ pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel> {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
characteristic_predicate: None,
|
||||
predicates: vec![
|
||||
create_get_a_primary_ql_class(main_class_name),
|
||||
create_get_location_predicate(main_table_name, main_table_arity),
|
||||
],
|
||||
predicates: vec![create_get_a_primary_ql_class(main_class_name, true)],
|
||||
};
|
||||
|
||||
if fields.is_empty() {
|
||||
main_class
|
||||
.predicates
|
||||
.push(create_get_text_predicate(main_table_name));
|
||||
} else {
|
||||
let mut main_table_column_index: usize = 0;
|
||||
let mut get_child_exprs: Vec<ql::Expression> = Vec::new();
|
||||
let mut main_table_column_index: usize = 0;
|
||||
let mut get_child_exprs: Vec<ql::Expression> = Vec::new();
|
||||
|
||||
// Iterate through the fields, creating:
|
||||
// - classes to wrap union types if fields need them,
|
||||
// - predicates to access the fields,
|
||||
// - the QL expressions to access the fields that will be part of getAFieldOrChild.
|
||||
for field in fields {
|
||||
let (get_pred, get_child_expr) = create_field_getters(
|
||||
main_table_name,
|
||||
main_table_arity,
|
||||
&mut main_table_column_index,
|
||||
field,
|
||||
nodes,
|
||||
);
|
||||
main_class.predicates.push(get_pred);
|
||||
if let Some(get_child_expr) = get_child_expr {
|
||||
get_child_exprs.push(get_child_expr)
|
||||
}
|
||||
// Iterate through the fields, creating:
|
||||
// - classes to wrap union types if fields need them,
|
||||
// - predicates to access the fields,
|
||||
// - the QL expressions to access the fields that will be part of getAFieldOrChild.
|
||||
for field in fields {
|
||||
let (get_pred, get_child_expr) = create_field_getters(
|
||||
main_table_name,
|
||||
main_table_arity,
|
||||
&mut main_table_column_index,
|
||||
field,
|
||||
nodes,
|
||||
);
|
||||
main_class.predicates.push(get_pred);
|
||||
if let Some(get_child_expr) = get_child_expr {
|
||||
get_child_exprs.push(get_child_expr)
|
||||
}
|
||||
|
||||
main_class.predicates.push(ql::Predicate {
|
||||
qldoc: Some(String::from("Gets a field or child node of this node.")),
|
||||
name: "getAFieldOrChild",
|
||||
overridden: true,
|
||||
return_type: Some(ql::Type::Normal("AstNode")),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Or(get_child_exprs),
|
||||
});
|
||||
}
|
||||
|
||||
main_class.predicates.push(ql::Predicate {
|
||||
qldoc: Some(String::from("Gets a field or child node of this node.")),
|
||||
name: "getAFieldOrChild",
|
||||
overridden: true,
|
||||
is_final: true,
|
||||
return_type: Some(ql::Type::Normal("AstNode")),
|
||||
formal_parameters: vec![],
|
||||
body: ql::Expression::Or(get_child_exprs),
|
||||
});
|
||||
|
||||
classes.push(ql::TopLevel::Class(main_class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ fn dbscheme_name_to_class_name(dbscheme_name: &str) -> String {
|
|||
}
|
||||
dbscheme_name
|
||||
.split('_')
|
||||
.map(|word| to_title_case(word))
|
||||
.map(to_title_case)
|
||||
.collect::<Vec<String>>()
|
||||
.join("")
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -58,8 +58,7 @@ ql_add_expr_def(
|
|||
unique int id: @ql_add_expr,
|
||||
int left: @ql_add_expr_left_type ref,
|
||||
int right: @ql_add_expr_right_type ref,
|
||||
int child: @ql_token_addop ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_addop ref
|
||||
);
|
||||
|
||||
@ql_aggregate_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_full_aggregate_body | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token_agg_id | @ql_unary_expr | @ql_variable
|
||||
|
@ -72,16 +71,14 @@ ql_aggregate_child(
|
|||
);
|
||||
|
||||
ql_aggregate_def(
|
||||
unique int id: @ql_aggregate,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_aggregate
|
||||
);
|
||||
|
||||
@ql_annotArg_child_type = @ql_token_result | @ql_token_simple_id | @ql_token_this
|
||||
|
||||
ql_annot_arg_def(
|
||||
unique int id: @ql_annot_arg,
|
||||
int child: @ql_annotArg_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_annotArg_child_type ref
|
||||
);
|
||||
|
||||
@ql_annotation_args_type = @ql_annot_arg | @ql_reserved_word
|
||||
|
@ -95,8 +92,7 @@ ql_annotation_args(
|
|||
|
||||
ql_annotation_def(
|
||||
unique int id: @ql_annotation,
|
||||
int name: @ql_token_annot_name ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_annot_name ref
|
||||
);
|
||||
|
||||
ql_arityless_predicate_expr_child(
|
||||
|
@ -106,8 +102,7 @@ ql_arityless_predicate_expr_child(
|
|||
|
||||
ql_arityless_predicate_expr_def(
|
||||
unique int id: @ql_arityless_predicate_expr,
|
||||
int name: @ql_token_literal_id ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_literal_id ref
|
||||
);
|
||||
|
||||
@ql_asExpr_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_var_name | @ql_variable
|
||||
|
@ -120,8 +115,7 @@ ql_as_expr_child(
|
|||
);
|
||||
|
||||
ql_as_expr_def(
|
||||
unique int id: @ql_as_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_as_expr
|
||||
);
|
||||
|
||||
#keyset[ql_as_exprs, index]
|
||||
|
@ -132,24 +126,21 @@ ql_as_exprs_child(
|
|||
);
|
||||
|
||||
ql_as_exprs_def(
|
||||
unique int id: @ql_as_exprs,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_as_exprs
|
||||
);
|
||||
|
||||
@ql_body_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
||||
ql_body_def(
|
||||
unique int id: @ql_body,
|
||||
int child: @ql_body_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_body_child_type ref
|
||||
);
|
||||
|
||||
@ql_bool_child_type = @ql_token_false | @ql_token_true
|
||||
|
||||
ql_bool_def(
|
||||
unique int id: @ql_bool,
|
||||
int child: @ql_bool_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_bool_child_type ref
|
||||
);
|
||||
|
||||
@ql_call_body_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token_underscore | @ql_unary_expr | @ql_variable
|
||||
|
@ -162,8 +153,7 @@ ql_call_body_child(
|
|||
);
|
||||
|
||||
ql_call_body_def(
|
||||
unique int id: @ql_call_body,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_call_body
|
||||
);
|
||||
|
||||
@ql_call_or_unqual_agg_expr_child_type = @ql_arityless_predicate_expr | @ql_call_body | @ql_token_closure | @ql_unqual_agg_body
|
||||
|
@ -176,8 +166,7 @@ ql_call_or_unqual_agg_expr_child(
|
|||
);
|
||||
|
||||
ql_call_or_unqual_agg_expr_def(
|
||||
unique int id: @ql_call_or_unqual_agg_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_call_or_unqual_agg_expr
|
||||
);
|
||||
|
||||
@ql_charpred_body_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -185,8 +174,7 @@ ql_call_or_unqual_agg_expr_def(
|
|||
ql_charpred_def(
|
||||
unique int id: @ql_charpred,
|
||||
int body: @ql_charpred_body_type ref,
|
||||
int child: @ql_token_class_name ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_class_name ref
|
||||
);
|
||||
|
||||
@ql_classMember_child_type = @ql_annotation | @ql_charpred | @ql_field | @ql_member_predicate | @ql_token_qldoc
|
||||
|
@ -199,8 +187,7 @@ ql_class_member_child(
|
|||
);
|
||||
|
||||
ql_class_member_def(
|
||||
unique int id: @ql_class_member,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_class_member
|
||||
);
|
||||
|
||||
@ql_classlessPredicate_returnType_type = @ql_token_predicate | @ql_type_expr
|
||||
|
@ -217,8 +204,7 @@ ql_classless_predicate_child(
|
|||
ql_classless_predicate_def(
|
||||
unique int id: @ql_classless_predicate,
|
||||
int name: @ql_token_predicate_name ref,
|
||||
int return_type: @ql_classlessPredicate_returnType_type ref,
|
||||
int loc: @location ref
|
||||
int return_type: @ql_classlessPredicate_returnType_type ref
|
||||
);
|
||||
|
||||
@ql_comp_term_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -229,8 +215,7 @@ ql_comp_term_def(
|
|||
unique int id: @ql_comp_term,
|
||||
int left: @ql_comp_term_left_type ref,
|
||||
int right: @ql_comp_term_right_type ref,
|
||||
int child: @ql_token_compop ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_compop ref
|
||||
);
|
||||
|
||||
@ql_conjunction_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -240,8 +225,7 @@ ql_comp_term_def(
|
|||
ql_conjunction_def(
|
||||
unique int id: @ql_conjunction,
|
||||
int left: @ql_conjunction_left_type ref,
|
||||
int right: @ql_conjunction_right_type ref,
|
||||
int loc: @location ref
|
||||
int right: @ql_conjunction_right_type ref
|
||||
);
|
||||
|
||||
@ql_dataclass_extends_type = @ql_reserved_word | @ql_type_expr
|
||||
|
@ -273,15 +257,13 @@ ql_dataclass_child(
|
|||
|
||||
ql_dataclass_def(
|
||||
unique int id: @ql_dataclass,
|
||||
int name: @ql_token_class_name ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_class_name ref
|
||||
);
|
||||
|
||||
ql_datatype_def(
|
||||
unique int id: @ql_datatype,
|
||||
int name: @ql_token_class_name ref,
|
||||
int child: @ql_datatype_branches ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_datatype_branches ref
|
||||
);
|
||||
|
||||
@ql_datatypeBranch_child_type = @ql_annotation | @ql_body | @ql_token_qldoc | @ql_var_decl
|
||||
|
@ -295,8 +277,7 @@ ql_datatype_branch_child(
|
|||
|
||||
ql_datatype_branch_def(
|
||||
unique int id: @ql_datatype_branch,
|
||||
int name: @ql_token_class_name ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_class_name ref
|
||||
);
|
||||
|
||||
#keyset[ql_datatype_branches, index]
|
||||
|
@ -307,8 +288,7 @@ ql_datatype_branches_child(
|
|||
);
|
||||
|
||||
ql_datatype_branches_def(
|
||||
unique int id: @ql_datatype_branches,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_datatype_branches
|
||||
);
|
||||
|
||||
ql_db_annotation_args_annotation(
|
||||
|
@ -322,8 +302,7 @@ ql_db_annotation_simple_annotation(
|
|||
);
|
||||
|
||||
ql_db_annotation_def(
|
||||
unique int id: @ql_db_annotation,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_db_annotation
|
||||
);
|
||||
|
||||
#keyset[ql_db_args_annotation, index]
|
||||
|
@ -335,8 +314,7 @@ ql_db_args_annotation_child(
|
|||
|
||||
ql_db_args_annotation_def(
|
||||
unique int id: @ql_db_args_annotation,
|
||||
int name: @ql_token_annot_name ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_annot_name ref
|
||||
);
|
||||
|
||||
ql_db_branch_qldoc(
|
||||
|
@ -354,8 +332,7 @@ ql_db_branch_child(
|
|||
);
|
||||
|
||||
ql_db_branch_def(
|
||||
unique int id: @ql_db_branch,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_db_branch
|
||||
);
|
||||
|
||||
@ql_db_caseDecl_child_type = @ql_db_branch | @ql_token_db_case
|
||||
|
@ -370,16 +347,14 @@ ql_db_case_decl_child(
|
|||
ql_db_case_decl_def(
|
||||
unique int id: @ql_db_case_decl,
|
||||
int base: @ql_token_dbtype ref,
|
||||
int discriminator: @ql_token_simple_id ref,
|
||||
int loc: @location ref
|
||||
int discriminator: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
@ql_db_colType_child_type = @ql_token_db_boolean | @ql_token_db_date | @ql_token_db_float | @ql_token_db_int | @ql_token_db_string | @ql_token_dbtype
|
||||
|
||||
ql_db_col_type_def(
|
||||
unique int id: @ql_db_col_type,
|
||||
int child: @ql_db_colType_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_db_colType_child_type ref
|
||||
);
|
||||
|
||||
ql_db_column_is_ref(
|
||||
|
@ -401,16 +376,14 @@ ql_db_column_def(
|
|||
unique int id: @ql_db_column,
|
||||
int col_name: @ql_token_simple_id ref,
|
||||
int col_type: @ql_db_col_type ref,
|
||||
int repr_type: @ql_db_repr_type ref,
|
||||
int loc: @location ref
|
||||
int repr_type: @ql_db_repr_type ref
|
||||
);
|
||||
|
||||
@ql_db_entry_child_type = @ql_db_case_decl | @ql_db_table | @ql_db_union_decl | @ql_token_qldoc
|
||||
|
||||
ql_db_entry_def(
|
||||
unique int id: @ql_db_entry,
|
||||
int child: @ql_db_entry_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_db_entry_child_type ref
|
||||
);
|
||||
|
||||
@ql_db_reprType_child_type = @ql_token_db_boolean | @ql_token_db_date | @ql_token_db_float | @ql_token_db_int | @ql_token_db_string | @ql_token_db_varchar | @ql_token_integer
|
||||
|
@ -423,8 +396,7 @@ ql_db_repr_type_child(
|
|||
);
|
||||
|
||||
ql_db_repr_type_def(
|
||||
unique int id: @ql_db_repr_type,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_db_repr_type
|
||||
);
|
||||
|
||||
@ql_db_table_child_type = @ql_db_annotation | @ql_db_column
|
||||
|
@ -438,14 +410,12 @@ ql_db_table_child(
|
|||
|
||||
ql_db_table_def(
|
||||
unique int id: @ql_db_table,
|
||||
int table_name: @ql_db_table_name ref,
|
||||
int loc: @location ref
|
||||
int table_name: @ql_db_table_name ref
|
||||
);
|
||||
|
||||
ql_db_table_name_def(
|
||||
unique int id: @ql_db_table_name,
|
||||
int child: @ql_token_simple_id ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
#keyset[ql_db_union_decl, index]
|
||||
|
@ -457,8 +427,7 @@ ql_db_union_decl_child(
|
|||
|
||||
ql_db_union_decl_def(
|
||||
unique int id: @ql_db_union_decl,
|
||||
int base: @ql_token_dbtype ref,
|
||||
int loc: @location ref
|
||||
int base: @ql_token_dbtype ref
|
||||
);
|
||||
|
||||
@ql_disjunction_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -468,8 +437,7 @@ ql_db_union_decl_def(
|
|||
ql_disjunction_def(
|
||||
unique int id: @ql_disjunction,
|
||||
int left: @ql_disjunction_left_type ref,
|
||||
int right: @ql_disjunction_right_type ref,
|
||||
int loc: @location ref
|
||||
int right: @ql_disjunction_right_type ref
|
||||
);
|
||||
|
||||
ql_expr_aggregate_body_order_bys(
|
||||
|
@ -479,8 +447,7 @@ ql_expr_aggregate_body_order_bys(
|
|||
|
||||
ql_expr_aggregate_body_def(
|
||||
unique int id: @ql_expr_aggregate_body,
|
||||
int as_exprs: @ql_as_exprs ref,
|
||||
int loc: @location ref
|
||||
int as_exprs: @ql_as_exprs ref
|
||||
);
|
||||
|
||||
@ql_expr_annotation_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -489,14 +456,12 @@ ql_expr_annotation_def(
|
|||
unique int id: @ql_expr_annotation,
|
||||
int annot_arg: @ql_token_annot_name ref,
|
||||
int name: @ql_token_annot_name ref,
|
||||
int child: @ql_expr_annotation_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_expr_annotation_child_type ref
|
||||
);
|
||||
|
||||
ql_field_def(
|
||||
unique int id: @ql_field,
|
||||
int child: @ql_var_decl ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_var_decl ref
|
||||
);
|
||||
|
||||
ql_full_aggregate_body_as_exprs(
|
||||
|
@ -524,8 +489,7 @@ ql_full_aggregate_body_child(
|
|||
);
|
||||
|
||||
ql_full_aggregate_body_def(
|
||||
unique int id: @ql_full_aggregate_body,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_full_aggregate_body
|
||||
);
|
||||
|
||||
@ql_higherOrderTerm_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_predicate_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token_underscore | @ql_unary_expr | @ql_variable
|
||||
|
@ -539,8 +503,7 @@ ql_higher_order_term_child(
|
|||
|
||||
ql_higher_order_term_def(
|
||||
unique int id: @ql_higher_order_term,
|
||||
int name: @ql_token_literal_id ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_token_literal_id ref
|
||||
);
|
||||
|
||||
@ql_if_term_cond_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -553,8 +516,7 @@ ql_if_term_def(
|
|||
unique int id: @ql_if_term,
|
||||
int cond: @ql_if_term_cond_type ref,
|
||||
int first: @ql_if_term_first_type ref,
|
||||
int second: @ql_if_term_second_type ref,
|
||||
int loc: @location ref
|
||||
int second: @ql_if_term_second_type ref
|
||||
);
|
||||
|
||||
@ql_implication_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -564,8 +526,7 @@ ql_if_term_def(
|
|||
ql_implication_def(
|
||||
unique int id: @ql_implication,
|
||||
int left: @ql_implication_left_type ref,
|
||||
int right: @ql_implication_right_type ref,
|
||||
int loc: @location ref
|
||||
int right: @ql_implication_right_type ref
|
||||
);
|
||||
|
||||
@ql_importDirective_child_type = @ql_import_module_expr | @ql_module_name
|
||||
|
@ -578,8 +539,7 @@ ql_import_directive_child(
|
|||
);
|
||||
|
||||
ql_import_directive_def(
|
||||
unique int id: @ql_import_directive,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_import_directive
|
||||
);
|
||||
|
||||
#keyset[ql_import_module_expr, index]
|
||||
|
@ -591,8 +551,7 @@ ql_import_module_expr_name(
|
|||
|
||||
ql_import_module_expr_def(
|
||||
unique int id: @ql_import_module_expr,
|
||||
int child: @ql_qual_module_expr ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_qual_module_expr ref
|
||||
);
|
||||
|
||||
@ql_in_expr_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -602,8 +561,7 @@ ql_import_module_expr_def(
|
|||
ql_in_expr_def(
|
||||
unique int id: @ql_in_expr,
|
||||
int left: @ql_in_expr_left_type ref,
|
||||
int right: @ql_in_expr_right_type ref,
|
||||
int loc: @location ref
|
||||
int right: @ql_in_expr_right_type ref
|
||||
);
|
||||
|
||||
@ql_instance_of_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_type_expr | @ql_unary_expr | @ql_variable
|
||||
|
@ -616,16 +574,14 @@ ql_instance_of_child(
|
|||
);
|
||||
|
||||
ql_instance_of_def(
|
||||
unique int id: @ql_instance_of,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_instance_of
|
||||
);
|
||||
|
||||
@ql_literal_child_type = @ql_bool | @ql_token_float | @ql_token_integer | @ql_token_string
|
||||
|
||||
ql_literal_def(
|
||||
unique int id: @ql_literal,
|
||||
int child: @ql_literal_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_literal_child_type ref
|
||||
);
|
||||
|
||||
@ql_memberPredicate_returnType_type = @ql_token_predicate | @ql_type_expr
|
||||
|
@ -642,8 +598,7 @@ ql_member_predicate_child(
|
|||
ql_member_predicate_def(
|
||||
unique int id: @ql_member_predicate,
|
||||
int name: @ql_token_predicate_name ref,
|
||||
int return_type: @ql_memberPredicate_returnType_type ref,
|
||||
int loc: @location ref
|
||||
int return_type: @ql_memberPredicate_returnType_type ref
|
||||
);
|
||||
|
||||
@ql_module_child_type = @ql_module_alias_body | @ql_module_member
|
||||
|
@ -657,14 +612,12 @@ ql_module_child(
|
|||
|
||||
ql_module_def(
|
||||
unique int id: @ql_module,
|
||||
int name: @ql_module_name ref,
|
||||
int loc: @location ref
|
||||
int name: @ql_module_name ref
|
||||
);
|
||||
|
||||
ql_module_alias_body_def(
|
||||
unique int id: @ql_module_alias_body,
|
||||
int child: @ql_module_expr ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_module_expr ref
|
||||
);
|
||||
|
||||
ql_module_expr_name(
|
||||
|
@ -676,8 +629,7 @@ ql_module_expr_name(
|
|||
|
||||
ql_module_expr_def(
|
||||
unique int id: @ql_module_expr,
|
||||
int child: @ql_moduleExpr_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_moduleExpr_child_type ref
|
||||
);
|
||||
|
||||
@ql_moduleMember_child_type = @ql_annotation | @ql_classless_predicate | @ql_dataclass | @ql_datatype | @ql_import_directive | @ql_module | @ql_select | @ql_token_qldoc
|
||||
|
@ -690,14 +642,12 @@ ql_module_member_child(
|
|||
);
|
||||
|
||||
ql_module_member_def(
|
||||
unique int id: @ql_module_member,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_module_member
|
||||
);
|
||||
|
||||
ql_module_name_def(
|
||||
unique int id: @ql_module_name,
|
||||
int child: @ql_token_simple_id ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
@ql_mul_expr_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -708,16 +658,14 @@ ql_mul_expr_def(
|
|||
unique int id: @ql_mul_expr,
|
||||
int left: @ql_mul_expr_left_type ref,
|
||||
int right: @ql_mul_expr_right_type ref,
|
||||
int child: @ql_token_mulop ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_mulop ref
|
||||
);
|
||||
|
||||
@ql_negation_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
||||
ql_negation_def(
|
||||
unique int id: @ql_negation,
|
||||
int child: @ql_negation_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_negation_child_type ref
|
||||
);
|
||||
|
||||
@ql_orderBy_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token_direction | @ql_unary_expr | @ql_variable
|
||||
|
@ -730,8 +678,7 @@ ql_order_by_child(
|
|||
);
|
||||
|
||||
ql_order_by_def(
|
||||
unique int id: @ql_order_by,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_order_by
|
||||
);
|
||||
|
||||
#keyset[ql_order_bys, index]
|
||||
|
@ -742,22 +689,19 @@ ql_order_bys_child(
|
|||
);
|
||||
|
||||
ql_order_bys_def(
|
||||
unique int id: @ql_order_bys,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_order_bys
|
||||
);
|
||||
|
||||
@ql_par_expr_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
||||
ql_par_expr_def(
|
||||
unique int id: @ql_par_expr,
|
||||
int child: @ql_par_expr_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_par_expr_child_type ref
|
||||
);
|
||||
|
||||
ql_predicate_alias_body_def(
|
||||
unique int id: @ql_predicate_alias_body,
|
||||
int child: @ql_predicate_expr ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_predicate_expr ref
|
||||
);
|
||||
|
||||
@ql_predicateExpr_child_type = @ql_arityless_predicate_expr | @ql_token_integer
|
||||
|
@ -770,8 +714,7 @@ ql_predicate_expr_child(
|
|||
);
|
||||
|
||||
ql_predicate_expr_def(
|
||||
unique int id: @ql_predicate_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_predicate_expr
|
||||
);
|
||||
|
||||
@ql_prefix_cast_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_type_expr | @ql_unary_expr | @ql_variable
|
||||
|
@ -784,8 +727,7 @@ ql_prefix_cast_child(
|
|||
);
|
||||
|
||||
ql_prefix_cast_def(
|
||||
unique int id: @ql_prefix_cast,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_prefix_cast
|
||||
);
|
||||
|
||||
@ql_ql_child_type = @ql_db_entry | @ql_module_member | @ql_yaml_entry
|
||||
|
@ -798,8 +740,7 @@ ql_ql_child(
|
|||
);
|
||||
|
||||
ql_ql_def(
|
||||
unique int id: @ql_ql,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_ql
|
||||
);
|
||||
|
||||
#keyset[ql_qual_module_expr, index]
|
||||
|
@ -810,8 +751,7 @@ ql_qual_module_expr_name(
|
|||
);
|
||||
|
||||
ql_qual_module_expr_def(
|
||||
unique int id: @ql_qual_module_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_qual_module_expr
|
||||
);
|
||||
|
||||
ql_qualified_rhs_name(
|
||||
|
@ -829,8 +769,7 @@ ql_qualified_rhs_child(
|
|||
);
|
||||
|
||||
ql_qualified_rhs_def(
|
||||
unique int id: @ql_qualified_rhs,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_qualified_rhs
|
||||
);
|
||||
|
||||
@ql_qualified_expr_child_type = @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_expr_annotation | @ql_literal | @ql_par_expr | @ql_qualified_expr | @ql_qualified_rhs | @ql_range | @ql_set_literal | @ql_super_ref | @ql_variable
|
||||
|
@ -843,8 +782,7 @@ ql_qualified_expr_child(
|
|||
);
|
||||
|
||||
ql_qualified_expr_def(
|
||||
unique int id: @ql_qualified_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_qualified_expr
|
||||
);
|
||||
|
||||
@ql_quantified_expr_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -878,8 +816,7 @@ ql_quantified_child(
|
|||
);
|
||||
|
||||
ql_quantified_def(
|
||||
unique int id: @ql_quantified,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_quantified
|
||||
);
|
||||
|
||||
@ql_range_lower_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -889,8 +826,7 @@ ql_quantified_def(
|
|||
ql_range_def(
|
||||
unique int id: @ql_range,
|
||||
int lower: @ql_range_lower_type ref,
|
||||
int upper: @ql_range_upper_type ref,
|
||||
int loc: @location ref
|
||||
int upper: @ql_range_upper_type ref
|
||||
);
|
||||
|
||||
@ql_select_child_type = @ql_add_expr | @ql_aggregate | @ql_as_exprs | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_order_bys | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_var_decl | @ql_variable
|
||||
|
@ -903,8 +839,7 @@ ql_select_child(
|
|||
);
|
||||
|
||||
ql_select_def(
|
||||
unique int id: @ql_select,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_select
|
||||
);
|
||||
|
||||
@ql_set_literal_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -917,14 +852,12 @@ ql_set_literal_child(
|
|||
);
|
||||
|
||||
ql_set_literal_def(
|
||||
unique int id: @ql_set_literal,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_set_literal
|
||||
);
|
||||
|
||||
ql_special_call_def(
|
||||
unique int id: @ql_special_call,
|
||||
int child: @ql_token_special_id ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_special_id ref
|
||||
);
|
||||
|
||||
@ql_super_ref_child_type = @ql_token_super | @ql_type_expr
|
||||
|
@ -937,14 +870,12 @@ ql_super_ref_child(
|
|||
);
|
||||
|
||||
ql_super_ref_def(
|
||||
unique int id: @ql_super_ref,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_super_ref
|
||||
);
|
||||
|
||||
ql_type_alias_body_def(
|
||||
unique int id: @ql_type_alias_body,
|
||||
int child: @ql_type_expr ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_type_expr ref
|
||||
);
|
||||
|
||||
ql_type_expr_name(
|
||||
|
@ -960,8 +891,7 @@ ql_type_expr_child(
|
|||
);
|
||||
|
||||
ql_type_expr_def(
|
||||
unique int id: @ql_type_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_type_expr
|
||||
);
|
||||
|
||||
#keyset[ql_type_union_body, index]
|
||||
|
@ -972,8 +902,7 @@ ql_type_union_body_child(
|
|||
);
|
||||
|
||||
ql_type_union_body_def(
|
||||
unique int id: @ql_type_union_body,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_type_union_body
|
||||
);
|
||||
|
||||
@ql_unary_expr_child_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token_unop | @ql_unary_expr | @ql_variable
|
||||
|
@ -986,8 +915,7 @@ ql_unary_expr_child(
|
|||
);
|
||||
|
||||
ql_unary_expr_def(
|
||||
unique int id: @ql_unary_expr,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_unary_expr
|
||||
);
|
||||
|
||||
@ql_unqual_agg_body_asExprs_type = @ql_as_exprs | @ql_reserved_word
|
||||
|
@ -1014,8 +942,7 @@ ql_unqual_agg_body_child(
|
|||
);
|
||||
|
||||
ql_unqual_agg_body_def(
|
||||
unique int id: @ql_unqual_agg_body,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_unqual_agg_body
|
||||
);
|
||||
|
||||
@ql_varDecl_child_type = @ql_type_expr | @ql_var_name
|
||||
|
@ -1028,36 +955,31 @@ ql_var_decl_child(
|
|||
);
|
||||
|
||||
ql_var_decl_def(
|
||||
unique int id: @ql_var_decl,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_var_decl
|
||||
);
|
||||
|
||||
ql_var_name_def(
|
||||
unique int id: @ql_var_name,
|
||||
int child: @ql_token_simple_id ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
@ql_variable_child_type = @ql_token_result | @ql_token_this | @ql_var_name
|
||||
|
||||
ql_variable_def(
|
||||
unique int id: @ql_variable,
|
||||
int child: @ql_variable_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_variable_child_type ref
|
||||
);
|
||||
|
||||
ql_yaml_comment_def(
|
||||
unique int id: @ql_yaml_comment,
|
||||
int child: @ql_token_yaml_value ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_yaml_value ref
|
||||
);
|
||||
|
||||
@ql_yaml_entry_child_type = @ql_yaml_comment | @ql_yaml_keyvaluepair | @ql_yaml_listitem
|
||||
|
||||
ql_yaml_entry_def(
|
||||
unique int id: @ql_yaml_entry,
|
||||
int child: @ql_yaml_entry_child_type ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_yaml_entry_child_type ref
|
||||
);
|
||||
|
||||
@ql_yaml_key_child_type = @ql_token_simple_id | @ql_yaml_key
|
||||
|
@ -1070,28 +992,24 @@ ql_yaml_key_child(
|
|||
);
|
||||
|
||||
ql_yaml_key_def(
|
||||
unique int id: @ql_yaml_key,
|
||||
int loc: @location ref
|
||||
unique int id: @ql_yaml_key
|
||||
);
|
||||
|
||||
ql_yaml_keyvaluepair_def(
|
||||
unique int id: @ql_yaml_keyvaluepair,
|
||||
int key__: @ql_yaml_key ref,
|
||||
int value: @ql_token_yaml_value ref,
|
||||
int loc: @location ref
|
||||
int value: @ql_token_yaml_value ref
|
||||
);
|
||||
|
||||
ql_yaml_listitem_def(
|
||||
unique int id: @ql_yaml_listitem,
|
||||
int child: @ql_token_yaml_value ref,
|
||||
int loc: @location ref
|
||||
int child: @ql_token_yaml_value ref
|
||||
);
|
||||
|
||||
ql_tokeninfo(
|
||||
unique int id: @ql_token,
|
||||
int kind: int ref,
|
||||
string value: string ref,
|
||||
int loc: @location ref
|
||||
string value: string ref
|
||||
);
|
||||
|
||||
case @ql_token.kind of
|
||||
|
@ -1144,9 +1062,10 @@ case @ql_token.kind of
|
|||
@ql_ast_node_parent = @file | @ql_ast_node
|
||||
|
||||
#keyset[parent, parent_index]
|
||||
ql_ast_node_parent(
|
||||
int child: @ql_ast_node ref,
|
||||
ql_ast_node_info(
|
||||
int node: @ql_ast_node ref,
|
||||
int parent: @ql_ast_node_parent ref,
|
||||
int parent_index: int ref
|
||||
int parent_index: int ref,
|
||||
int loc: @location ref
|
||||
);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче