mirror of
https://github.com/justinian/lexx.git
synced 2025-12-09 16:14:32 -08:00
Initial commit
This commit is contained in:
31
lexx.ts
Normal file
31
lexx.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { parseArgs } from 'util';
|
||||
import { build_language } from './src/definition'
|
||||
|
||||
const { values, positionals } = parseArgs({
|
||||
args: Bun.argv.slice(2),
|
||||
options: {
|
||||
count: {
|
||||
type: 'string',
|
||||
short: 'c',
|
||||
default: '20',
|
||||
},
|
||||
},
|
||||
allowPositionals: true,
|
||||
});
|
||||
|
||||
let language = "test.lang";
|
||||
if (positionals.length > 0)
|
||||
language = positionals[0];
|
||||
|
||||
console.log(`Using language: ${language}`);
|
||||
const def = await Bun.file(language).text();
|
||||
|
||||
try {
|
||||
const lang = build_language(def);
|
||||
let words = lang.generate(parseInt(values.count));
|
||||
for (const w of words) {
|
||||
console.log(`${w[0]}\t\t/${w[1]}/`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
Reference in New Issue
Block a user