Skip to content

WIP: Target #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

WIP: Target #437

wants to merge 6 commits into from

Conversation

anakrish
Copy link
Collaborator

In progress implementation of "targets".
Typechecking is in the process of being rewritten to using JSON schema.

anakrish added 5 commits July 16, 2025 10:05
Indexes allow associating extra data with nodes in the AST
using an array and then quickly looking up the array to fetch
the extra data.

- Index eidx for expressions
- Index sidx for statements
- Index qidx for queries.

AST nodes are not cloneable. Therefore once a module is created,
it is not possible to accidentally create two nodes with the same
index inadvertently via clone.

Also added IndexChecker in debug builds. When a module is parsed,
it will assert that indexes have been constructed correctly.

AST Cleanup
- Make literal expressions (null, val, number, string etc) also structs
  to match all other expressions
- Merge True and False nodes into a single Bool node.

Also update dependencies.

Signed-off-by: Anand Krishnamoorthi <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
@@ -3894,4 +3894,17 @@

Ok(Self::get_value_chained(self.data.clone(), &parts[1..]))
}

pub fn validate(&mut self) -> Result<()> {
let mut target = None;

Check warning

Code scanning / clippy

variable target is assigned to, but never used Warning

variable target is assigned to, but never used
let mut target = None;
for m in self.modules.iter() {
if m.target.is_some() {
target = m.target.clone();

Check warning

Code scanning / clippy

value assigned to target is never read Warning

value assigned to target is never read
}
}

impl Schema {

Check warning

Code scanning / clippy

method get_property is never used Warning

method get\_property is never used
}

impl Schema {
pub fn get_property(&self, name: &str) -> Result<Schema> {

Check warning

Code scanning / clippy

method get_property is never used Warning

method get\_property is never used
use crate::*;
use crate::{schema::*, target::Target};

use alloc::collections::BTreeMap;

Check warning

Code scanning / clippy

unused import: alloc::collections::BTreeMap Warning

unused import: alloc::collections::BTreeMap
Ok(())
}

fn check_query(&mut self, query: &Query) -> Result<()> {

Check warning

Code scanning / clippy

multiple associated items are never used Warning

multiple associated items are never used
Ok(())
}

fn check_rule_body(&mut self, name: &String, body: &RuleBody) -> Result<()> {

Check warning

Code scanning / clippy

multiple associated items are never used Warning

multiple associated items are never used
Ok(())
}

fn check_rule(&mut self, name: &String, rule: &Ref<Rule>) -> Result<Schema> {

Check warning

Code scanning / clippy

multiple associated items are never used Warning

multiple associated items are never used
Ok(Schema::default())
}

fn check_rules(&mut self, name: &String, rules: &[Ref<Rule>]) -> Result<()> {

Check warning

Code scanning / clippy

multiple associated items are never used Warning

multiple associated items are never used
Ok(())
}

pub fn check(&mut self) -> Result<()> {

Check warning

Code scanning / clippy

multiple associated items are never used Warning

multiple associated items are never used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant