( s: string, i: number )
| 36 | } |
| 37 | |
| 38 | function identifier( |
| 39 | s: string, |
| 40 | i: number |
| 41 | ): [i: number, result: Expression | null] { |
| 42 | const m = s.slice(i).match(/^[\p{XIDS}_][\p{XIDC}]*/u); |
| 43 | if (m === null) return [i, null]; |
| 44 | return [i + m[0].length, symbol(m[0])]; |
| 45 | } |
| 46 | |
| 47 | function exponent(s: string, i: number): [i: number, result: string | null] { |
| 48 | if (s[i] !== 'e' && s[i] !== 'E') return [i, null]; |