Skip to content

Commit

Permalink
feat(core): convert abnf to peggy grammar
Browse files Browse the repository at this point in the history
- convert each .abnf to a .pegjs file

Fixes: #13175
  • Loading branch information
srl295 committed Feb 14, 2025
1 parent 98b1fac commit a2a0e79
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions developer/src/kmc-ldml/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/util/abnf/*.pegjs
18 changes: 17 additions & 1 deletion developer/src/kmc-ldml/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
## END STANDARD BUILD SCRIPT INCLUDE

. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
# for CLDR version
. "$KEYMAN_ROOT/core/include/ldml/keyman_core_ldml.sh"

builder_describe "Keyman kmc Keyboard Compiler module" \
"@/common/web/keyman-version" \
Expand All @@ -34,17 +36,31 @@ builder_describe_outputs \
builder_parse "$@"

function do_clean() {
rm -rf ./build/ ./tsconfig.tsbuildinfo
rm -rf ./build/ ./tsconfig.tsbuildinfo ./src/util/abnf/*.pegjs
}

function do_configure() {
verify_npm_setup
do_build_abnf
}

function do_build() {
npm run build
}

function do_build_abnf() {
ABNF_SRC="$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/$LDML_CLDR_VERSION_LATEST/abnf"
for file in ${ABNF_SRC}/*.abnf; do
base=$(basename "$file" .abnf)
peg="$base.pegjs"
outfile="./src/util/abnf/$peg"
if [ ! -f "$outfile" ]; then
printf "${COLOR_GREY}abnf_gen ${COLOR_PURPLE}${base}.abnf -> ${peg}${COLOR_RESET}"
npx -p abnf abnf_gen "$file" -o "$outfile"
fi
done
}

function do_build_fixtures() {
# Build basic.kmx and emit its checksum
mkdir -p ./build/test/fixtures
Expand Down
2 changes: 2 additions & 0 deletions developer/src/kmc-ldml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@keymanapp/keyman-version": "*",
"@keymanapp/kmc-kmn": "*",
"@keymanapp/ldml-keyboard-constants": "*",
"peggy": "^4.2.0",
"semver": "^7.5.4"
},
"devDependencies": {
Expand All @@ -38,6 +39,7 @@
"@types/mocha": "^5.2.7",
"@types/node": "^20.4.1",
"@types/semver": "^7.3.12",
"abnf": "^4.3.1",
"c8": "^7.12.0",
"chalk": "^2.4.2",
"common-tags": "^1.8.2",
Expand Down
Empty file.
86 changes: 86 additions & 0 deletions package-lock.json

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

0 comments on commit a2a0e79

Please sign in to comment.