-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to the parser and CLI (#142)
- Fixed array destruction syntax (and added support to checker) - Update CLI things - Added retaining blank lines for formatting - Use BufferedStandardStream - Updated release compiler options - Added missing `run` checker example - Optional class properties - Removed Eq from parser items - More additional syntax for destructuring with type annotations - Change variable declaration overflow line splitting - Add conditional ternary overflow line splitting - Fixed precedence of condition types (fixes issue raised in type checking) - Try add trailing new lines as empty - Ignore whitespace during fuzzing trip
- Loading branch information
1 parent
c1ecf40
commit bfd2133
Showing
64 changed files
with
1,291 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,31 +53,26 @@ jobs: | |
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md ./demo.ts | ||
echo "::info::Finished file generation" | ||
LINES_OF_CODE=$(scc -c --no-cocomo -f json demo.ts | jq ".[0].Code") | ||
echo "<details> | ||
<summary>Input</summary> | ||
\`\`\`ts | ||
" >> $GITHUB_STEP_SUMMARY | ||
echo "// $(scc -c --no-cocomo -f json demo.ts | jq ".[0].Code") lines of TypeScript" >> $GITHUB_STEP_SUMMARY | ||
cat ./demo.ts >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\` | ||
// $LINES_OF_CODE lines of TypeScript generated from specification.md | ||
$(cat ./demo.ts) | ||
\`\`\` | ||
</details> | ||
" >> $GITHUB_STEP_SUMMARY | ||
echo "::info::Wrote code to summary" | ||
echo "<details> | ||
<summary>Diagnostics</summary> | ||
\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
# Printing diagnostics, so turn colors off for GH Summary (also affects printing perf I think) | ||
NO_COLOR=1 | ||
(./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY) || true | ||
echo "\`\`\` | ||
\`\`\` | ||
$(./target/release/ezno check demo.ts --timings || true) | ||
\`\`\` | ||
</details> | ||
" >> $GITHUB_STEP_SUMMARY | ||
|
@@ -102,6 +97,8 @@ jobs: | |
"https://esm.sh/v135/[email protected]/es2022/typescript.mjs" | ||
) | ||
// TODO hyperfine | ||
for url in "${strings[@]}"; do | ||
curl -sS $url > input.js | ||
echo "--- debug: $url ---" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ target | |
/private | ||
.vscode | ||
.env | ||
/checker/examples | ||
**/examples/private-*.rs | ||
build | ||
node_modules | ||
/TODO.txt | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#[cfg(feature = "ezno-parser")] | ||
fn main() { | ||
use ezno_checker::{check_project, synthesis, Diagnostic, TypeCheckOptions}; | ||
use std::{collections::HashSet, fs, path::Path, time::Instant}; | ||
|
||
let default_path = Path::new("private").join("tocheck").join("aaa.tsx"); | ||
let simple_dts_path = Path::new("checker").join("definitions").join("simple.d.ts"); | ||
let overrides_dts_path = Path::new("checker").join("definitions").join("overrides.d.ts"); | ||
|
||
let args: Vec<_> = std::env::args().skip(1).collect(); | ||
|
||
let path = args | ||
.first() | ||
.and_then(|arg| (!arg.starts_with("--")).then_some(arg)) | ||
.map(Path::new) | ||
.unwrap_or(default_path.as_path()); | ||
|
||
let use_simple = args.iter().any(|item| item == "--simple-dts"); | ||
let no_cache = args.iter().any(|item| item == "--no-cache"); | ||
|
||
let now = Instant::now(); | ||
|
||
let resolver = |path: &std::path::Path| fs::read(path).ok(); | ||
|
||
let definition_file = if use_simple { | ||
simple_dts_path.to_path_buf() | ||
} else if no_cache { | ||
overrides_dts_path.to_path_buf() | ||
} else { | ||
ezno_checker::INTERNAL_DEFINITION_FILE_PATH.into() | ||
}; | ||
let type_definition_files = HashSet::from_iter([definition_file]); | ||
|
||
let debug_types = false; | ||
let options = TypeCheckOptions { debug_types, ..Default::default() }; | ||
|
||
let result = check_project::<_, synthesis::EznoParser>( | ||
vec![path.to_path_buf()], | ||
type_definition_files, | ||
resolver, | ||
options, | ||
(), | ||
None, | ||
); | ||
|
||
if args.iter().any(|arg| arg == "--types") { | ||
eprintln!("Types:"); | ||
for (type_id, item) in result.types.into_vec_temp() { | ||
eprintln!("\t{type_id:?}: {item:?}"); | ||
} | ||
} | ||
|
||
if args.iter().any(|arg| arg == "--events") { | ||
eprintln!("Events on entry:"); | ||
let (_, entry_module) = result.modules.into_iter().next().unwrap(); | ||
for item in entry_module.info.get_events() { | ||
eprintln!("\t{item:?}"); | ||
} | ||
} | ||
|
||
if args.iter().any(|arg| arg == "--time") { | ||
let end = now.elapsed(); | ||
let count = result.diagnostics.into_iter().len(); | ||
eprintln!("Found {count} diagnostics in {end:?}"); | ||
} else if args.iter().any(|arg| arg == "--debug-diagnostics") { | ||
eprintln!("Diagnostics:"); | ||
for diagnostic in result.diagnostics { | ||
eprintln!("{diagnostic:?}"); | ||
} | ||
} else { | ||
eprintln!("Diagnostics:"); | ||
for diagnostic in result.diagnostics { | ||
let prefix: &str = match diagnostic.kind() { | ||
ezno_checker::DiagnosticKind::Error => "ERROR", | ||
ezno_checker::DiagnosticKind::Warning => "WARNING", | ||
ezno_checker::DiagnosticKind::Info => "INFO", | ||
}; | ||
match diagnostic { | ||
Diagnostic::Global { reason, kind: _ } => { | ||
eprintln!("\t{prefix}: {reason}"); | ||
} | ||
Diagnostic::Position { reason, position, kind: _ } => { | ||
eprintln!("\t{prefix} (@{position:?}): {reason} "); | ||
} | ||
Diagnostic::PositionWithAdditionalLabels { reason, position, labels, kind: _ } => { | ||
eprintln!("\t{prefix} (@{position:?}): {reason}"); | ||
for (reason, position) in labels { | ||
eprintln!("\t\t{reason} {position:?}"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "ezno-parser"))] | ||
fn main() { | ||
println!("Requires 'ezno-parser'") | ||
} |
Oops, something went wrong.