-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Replace generate_grammar.py with generate-grammar.vsh (#204)
Co-authored-by: ge <gechandev@gmail.com>
- Loading branch information
1 parent
eaa590c
commit 7043a23
Showing
5 changed files
with
42 additions
and
38 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
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,40 @@ | ||
#!/usr/bin/env -S v | ||
|
||
path := abs_path('vsql') | ||
output_filename := join_path_single(path, 'y.y') | ||
files := glob(join_path_single(path, '*.y')) or { [] } | ||
|
||
mut top := '' | ||
mut middle := '' | ||
mut bottom := '' | ||
|
||
for file_path in files { | ||
if is_dir(file_path) { | ||
continue | ||
} | ||
content := read_file(file_path) or { | ||
eprintln('error: unable to open file ${file_path}: ${err}') | ||
exit(1) | ||
} | ||
parts := content.split('%%') | ||
if parts.len != 3 { | ||
eprintln('${file_path}: wrong number of parts (${parts.len})') | ||
exit(1) | ||
} | ||
top += parts[0] | ||
middle += parts[1] | ||
bottom += parts[2] | ||
} | ||
|
||
mut output := open_file(output_filename, 'w') or { | ||
eprintln('error: unable to open file to write') | ||
exit(1) | ||
} | ||
|
||
output.writeln(top.trim_space())! | ||
output.writeln('%%')! | ||
output.writeln(middle.trim_space())! | ||
output.writeln('%%')! | ||
output.write_string(bottom.trim_space())! | ||
output.flush() | ||
output.close() |
This file was deleted.
Oops, something went wrong.