wip
This commit is contained in:
parent
d89130b169
commit
7d23a86121
|
|
@ -201,15 +201,7 @@ export const inlineHints = [
|
|||
child = child.nextSibling
|
||||
}
|
||||
|
||||
console.log(
|
||||
`🌭`,
|
||||
availableArgs.map((a) => a.name)
|
||||
)
|
||||
|
||||
return {
|
||||
commandShape,
|
||||
availableArgs,
|
||||
}
|
||||
return { commandShape, availableArgs }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -139,6 +139,30 @@ const evaluateNode = (node: SyntaxNode, input: string, context: Context): any =>
|
|||
}
|
||||
}
|
||||
|
||||
case terms.CommandCall: {
|
||||
const commandNode = assertNode(node.firstChild, 'Command')
|
||||
const commandIdentifier = assertNode(commandNode.firstChild, 'Identifier')
|
||||
const command = input.slice(commandIdentifier.from, commandIdentifier.to)
|
||||
|
||||
const args = getChildren(node)
|
||||
.slice(1)
|
||||
.map((argNode) => {
|
||||
if (argNode.type.id === terms.Arg) {
|
||||
return evaluateNode(argNode, input, context)
|
||||
} else if (argNode.type.id === terms.NamedArg) {
|
||||
return evaluateNode(argNode, input, context)
|
||||
} else {
|
||||
throw new RuntimeError(
|
||||
`Unexpected argument type: ${argNode.type.name}`,
|
||||
input,
|
||||
argNode.from,
|
||||
argNode.to
|
||||
)
|
||||
}
|
||||
})
|
||||
const commandName = input.slice(commandIdentifier.from, commandIdentifier.to)
|
||||
}
|
||||
|
||||
default:
|
||||
const isLowerCase = node.type.name[0] == node.type.name[0]?.toLowerCase()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ExternalTokenizer, InputStream } from '@lezer/lr'
|
||||
import { ExternalTokenizer, InputStream, Stack } from '@lezer/lr'
|
||||
import { CommandPartial, Command, Identifier, UnquotedArg, insertedSemi } from './shrimp.terms'
|
||||
import { matchingCommands } from '#editor/commands'
|
||||
|
||||
|
|
@ -88,15 +88,15 @@ export const insertSemicolon = new ExternalTokenizer((input: InputStream, stack:
|
|||
}
|
||||
})
|
||||
|
||||
function isLowercaseLetter(ch: number): boolean {
|
||||
const isLowercaseLetter = (ch: number): boolean => {
|
||||
return ch >= 97 && ch <= 122 // a-z
|
||||
}
|
||||
|
||||
function isDigit(ch: number): boolean {
|
||||
const isDigit = (ch: number): boolean => {
|
||||
return ch >= 48 && ch <= 57 // 0-9
|
||||
}
|
||||
|
||||
function getFullCodePoint(input: InputStream, pos: number): number {
|
||||
const getFullCodePoint = (input: InputStream, pos: number): number => {
|
||||
const ch = input.peek(pos)
|
||||
|
||||
// Check if this is a high surrogate (0xD800-0xDBFF)
|
||||
|
|
@ -112,7 +112,7 @@ function getFullCodePoint(input: InputStream, pos: number): number {
|
|||
return ch // Single code unit
|
||||
}
|
||||
|
||||
function isEmoji(ch: number): boolean {
|
||||
const isEmoji = (ch: number): boolean => {
|
||||
return (
|
||||
// Basic Emoticons
|
||||
(ch >= 0x1f600 && ch <= 0x1f64f) ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user