Skip to content

Commit

Permalink
add manual overrides input handling, add sub( second function.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed May 29, 2024
1 parent 0e0d6a6 commit f1b4bed
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
17 changes: 17 additions & 0 deletions TI-84_Plus_CE_catalog-tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -12235,6 +12235,23 @@
"[catalog]",
"sub("
]
},
{
"syntax": "sub(value)",
"arguments": [
[
"value",
"real|expression|real[]",
false
]
],
"description": "Divides a real number, expression, or list by 100.",
"inEditorOnly": false,
"location": [
"【2nd】",
"[catalog]",
"sub("
]
}
],
"localizations": {
Expand Down
23 changes: 23 additions & 0 deletions input/manual_overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"0xBB0C": {
"syntaxes": [
{
"syntax": "sub(value)",
"arguments": [
[
"value",
"real|expression|real[]",
false
]
],
"description": "Divides a real number, expression, or list by 100.",
"inEditorOnly": false,
"location": [
"【2nd】",
"[catalog]",
"sub("
]
}
]
}
}
22 changes: 22 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { parse as CSVParse } from 'csv-parse/sync';
const tkXML= {}; // input
const csv = {}; // input
const dict = {}; // input
const manualOverrides = {}; // input
const json = {}; // output

// temp maps used for manual matching of other tokens
Expand Down Expand Up @@ -128,6 +129,15 @@ const mergeSinceUntilFromTkXML = function(entry, match, enName) {
}
}

try {
const data = JSON.parse(fs.readFileSync('./input/manual_overrides.json', 'utf8'));
for (const [ bytes, overrides ] of Object.entries(data)) {
manualOverrides[bytes] = overrides;
}
} catch (e) {
console.error(e);
}

try {
const fileContents = fs.readFileSync('./input/ti-toolkit_tokens_8X.xml', 'utf8');

Expand Down Expand Up @@ -487,6 +497,18 @@ for(let i = 0; i < 26; i++)
specialCategory: specialCategory.length ? specialCategory : undefined,
});

if (manualOverrides[bytes]) {
for (const [ what, override ] of Object.entries(manualOverrides[bytes])) {
if (typeof(json[bytes][what]) === 'undefined') {
json[bytes][what] = override;
} else if (typeof(override) === 'object') {
json[bytes][what].push(...override)
} else {
console.error("override type not handled: " + typeof(override));
}
}
}

name2bytes[name] = bytes;
}
}
Expand Down
21 changes: 21 additions & 0 deletions tokens/0xBB0C.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ Returns a string that is a subset of another `string`, from `begin` to `length`.
<tt><kbd><b>2nd</b></kbd></tt>, <kbd>catalog</kbd>, `sub(`
<hr>

## Overview
Divides a real number, expression, or list by 100.


<b>Availability</b>: Token available everywhere.

## Syntax
`sub(value)`

## Arguments
<table>
<tr><th>Name</th><th>Type</th><th>Optional</th></tr>

<tr><td><b>value</b></td><td>real|expression|real[]</td><td></td></tr>

</table>

## Location
<tt><kbd><b>2nd</b></kbd></tt>, <kbd>catalog</kbd>, `sub(`
<hr>

## Description

The sub( command is used to get a substring, or a specific part of a string. It takes three arguments: _string_ is the source string to get the substring from, _start_ is the index of the token to start from, and _length_ is the length of the substring you want. For example:
Expand Down

0 comments on commit f1b4bed

Please sign in to comment.