Skip to content

Commit

Permalink
refactor: AST node sizes (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen committed Jun 20, 2023
1 parent a555828 commit 8d2a55d
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 78 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ members = [
# The book / docs
"web/book", #
# An example
# This is temporarily removed because it was causing a stack overflow in
# Windows; ref https://github.com/PRQL/prql/pull/2713
# "prql-compiler/examples/compile-files", #
"prql-compiler/examples/compile-files", #
]
resolver = "2"

Expand Down
8 changes: 8 additions & 0 deletions prql-compiler/prqlc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ pub enum DebugCommand {

/// Parse, resolve & combine source with comments annotating relation type
Annotate(IoArgs),

/// Print info about the AST data structure
#[cfg(debug_assertions)]
Ast,
}

#[derive(clap::Args, Default, Debug, Clone)]
Expand Down Expand Up @@ -204,6 +208,10 @@ impl Command {
shell.generate(&mut Cli::command(), &mut std::io::stdout());
Ok(())
}
Command::Debug(DebugCommand::Ast) => {

Check failure on line 211 in prql-compiler/prqlc/src/cli.rs

View workflow job for this annotation

GitHub Actions / cargo-bench

no variant or associated item named `Ast` found for enum `DebugCommand` in the current scope
prql_compiler::ast::pl::print_mem_sizes();
Ok(())
}
_ => self.run_io_command(),
}
}
Expand Down
33 changes: 20 additions & 13 deletions prql-compiler/prqlc/tests/snapshots/test__shell_completion-2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ info:
- shell-completion
- fish
env:
RUST_LOG: ""
RUST_BACKTRACE: ""
CLICOLOR_FORCE: ""
---
success: true
Expand All @@ -31,22 +33,26 @@ complete -c prqlc -n "__fish_seen_subcommand_from parse" -l color -d 'Controls w
complete -c prqlc -n "__fish_seen_subcommand_from parse" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from fmt" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from fmt" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "ast" -d 'Print info about the AST data structure'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from semantics" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from semantics" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from eval" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from eval" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from annotate" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from annotate" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from ast" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from ast" -s h -l help -d 'Print help'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "ast" -d 'Print info about the AST data structure'
complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c prqlc -n "__fish_seen_subcommand_from resolve" -l format -r -f -a "{json ,yaml }"
complete -c prqlc -n "__fish_seen_subcommand_from resolve" -l color -d 'Controls when to use color' -r -f -a "{auto ,always ,never }"
complete -c prqlc -n "__fish_seen_subcommand_from resolve" -s h -l help -d 'Print help'
Expand Down Expand Up @@ -78,9 +84,10 @@ complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subc
complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "list-targets" -d 'Show available compile target names'
complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "shell-completion" -d 'Print a shell completion for supported shells'
complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "semantics" -d 'Parse & resolve, but don\'t lower into RQ'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "eval" -d 'Parse & evaluate expression down to a value'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type'
complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from semantics; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "ast" -d 'Print info about the AST data structure'

----- stderr -----

17 changes: 17 additions & 0 deletions prql-compiler/prqlc/tests/snapshots/test__shell_completion-3.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ info:
- shell-completion
- powershell
env:
RUST_LOG: ""
RUST_BACKTRACE: ""
CLICOLOR_FORCE: ""
---
success: true
Expand Down Expand Up @@ -73,6 +75,7 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock {
[CompletionResult]::new('semantics', 'semantics', [CompletionResultType]::ParameterValue, 'Parse & resolve, but don''t lower into RQ')
[CompletionResult]::new('eval', 'eval', [CompletionResultType]::ParameterValue, 'Parse & evaluate expression down to a value')
[CompletionResult]::new('annotate', 'annotate', [CompletionResultType]::ParameterValue, 'Parse, resolve & combine source with comments annotating relation type')
[CompletionResult]::new('ast', 'ast', [CompletionResultType]::ParameterValue, 'Print info about the AST data structure')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand All @@ -94,10 +97,17 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock {
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
break
}
'prqlc;debug;ast' {
[CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Controls when to use color')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
break
}
'prqlc;debug;help' {
[CompletionResult]::new('semantics', 'semantics', [CompletionResultType]::ParameterValue, 'Parse & resolve, but don''t lower into RQ')
[CompletionResult]::new('eval', 'eval', [CompletionResultType]::ParameterValue, 'Parse & evaluate expression down to a value')
[CompletionResult]::new('annotate', 'annotate', [CompletionResultType]::ParameterValue, 'Parse, resolve & combine source with comments annotating relation type')
[CompletionResult]::new('ast', 'ast', [CompletionResultType]::ParameterValue, 'Print info about the AST data structure')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand All @@ -110,6 +120,9 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock {
'prqlc;debug;help;annotate' {
break
}
'prqlc;debug;help;ast' {
break
}
'prqlc;debug;help;help' {
break
}
Expand Down Expand Up @@ -186,6 +199,7 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock {
[CompletionResult]::new('semantics', 'semantics', [CompletionResultType]::ParameterValue, 'Parse & resolve, but don''t lower into RQ')
[CompletionResult]::new('eval', 'eval', [CompletionResultType]::ParameterValue, 'Parse & evaluate expression down to a value')
[CompletionResult]::new('annotate', 'annotate', [CompletionResultType]::ParameterValue, 'Parse, resolve & combine source with comments annotating relation type')
[CompletionResult]::new('ast', 'ast', [CompletionResultType]::ParameterValue, 'Print info about the AST data structure')
break
}
'prqlc;help;debug;semantics' {
Expand All @@ -197,6 +211,9 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock {
'prqlc;help;debug;annotate' {
break
}
'prqlc;help;debug;ast' {
break
}
'prqlc;help;resolve' {
break
}
Expand Down
Loading

0 comments on commit 8d2a55d

Please sign in to comment.