Skip to content

Commit dc4491f

Browse files
committed
start on parser
1 parent a22a219 commit dc4491f

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

mcparser.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// a parser for MC programs
2+
3+
// Page [num]
4+
// When [Event] Do [Action] [Loop]
5+
6+
// TODO: scripts reverse the tooltip
7+
8+
namespace microcode {
9+
// resolveTooltip to go from Tid to string (replace space by -)
10+
// reverseTooltip to go from string to tid
11+
}

pxt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"host.ts",
3535
"interpreter.ts",
3636
"sensors.ts",
37+
"mcparser.ts",
3738
"exprparser.ts",
3839
"decimal.ts",
3940
"settings.ts"

scripts/lochex.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,21 @@ for (const lang of languages.filter(l => l !== "pxt")) {
7676
{ encoding: "utf-8" }
7777
)
7878

79-
// for (const fn of ["dialogs", "legal"]) {
80-
// const dialogs = await (
81-
// await fetch(
82-
// `${cdn}content/${lang}/microcode/${fn}.html?timestamp=${timestamp}`
83-
// )
84-
// ).text()
85-
// writeFileSync(`./_includes/${fn}-${lang}.html`, dialogs, {
86-
// encoding: "utf-8",
87-
// })
88-
// }
89-
9079
// merge translations
9180
Object.keys(tooltips)
9281
.filter(k => !translations[k])
9382
.forEach(k => (translations[k] = tooltips[k]))
9483

84+
// this is for english only (for now)
85+
if (lang == "en") {
86+
const reverseMap = Object.keys(tooltips).filter(k => tooltips[k])
87+
88+
const tooltip2tid = `
89+
export function tooltip2tid(id: string): number {
90+
}
91+
`
92+
}
93+
9594
const ts = `// auto-generated, run 'node scripts/lochex.mjs' to refresh
9695
namespace microcode {
9796
export const lang = "${lang}"
@@ -109,6 +108,7 @@ ${Object.keys(translations)
109108
return res
110109
}
111110
}`
111+
112112
writeFileSync("./tooltips.ts", ts, { encoding: "utf8" })
113113

114114
// build js

0 commit comments

Comments
 (0)