Skip to content

Commit 1b7a2bb

Browse files
committed
函数框添加常数识别
1 parent 2bd0698 commit 1b7a2bb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/editor/inputs/subblocks/functionTokenize.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const fns = [
1313
"log",
1414
].sort((a, b) => b.length - a.length);
1515

16+
const nums = ["PI", "E"];
17+
1618
const ops = ["+", "-", "*", "/", "^", ","];
1719

1820
const lBracket = "(";
@@ -105,6 +107,7 @@ const hasIdentifier = (
105107
const hasNumber = (str: string): string | undefined => {
106108
const match = str.match(/^\d+(\.\d+)?([Ee][+-]\d+)?/);
107109
if (match) return match[0];
110+
for (const num of nums) if (str.startsWith(num)) return num;
108111
};
109112
const hasSpace = (str: string): string | undefined => {
110113
const match = str.match(/^\s+/);

0 commit comments

Comments
 (0)