@algosail/parser 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/load.js +4 -2
- package/lib/symbolTable.js +2 -1
- package/lib/tokens.js +5 -1
- package/package.json +1 -1
package/lib/load.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile, access } from 'node:fs/promises'
|
|
2
2
|
import { createRequire } from 'node:module'
|
|
3
3
|
import { dirname, extname, join, resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
4
5
|
|
|
5
6
|
function parsePackageImport(packageImport) {
|
|
6
7
|
if (packageImport.startsWith('@')) {
|
|
@@ -72,7 +73,7 @@ export async function resolveModulePath(execPath, packageImport) {
|
|
|
72
73
|
|
|
73
74
|
const sailPath = resolveExportsCondition(packageJson.exports, path)
|
|
74
75
|
if (sailPath) {
|
|
75
|
-
return { type: '
|
|
76
|
+
return { type: 'sail', path: join(packageDir, sailPath) }
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
const importId = path === '.' ? name : `${name}/${path.slice(2)}`
|
|
@@ -81,7 +82,8 @@ export async function resolveModulePath(execPath, packageImport) {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export async function resolveFilePath(execPath, filePath) {
|
|
84
|
-
const
|
|
85
|
+
const execFilePath = execPath.startsWith('file://') ? fileURLToPath(execPath) : execPath
|
|
86
|
+
const base = dirname(execFilePath)
|
|
85
87
|
const ext = extname(filePath)
|
|
86
88
|
|
|
87
89
|
if (ext === '.sail') {
|
package/lib/symbolTable.js
CHANGED
|
@@ -8,7 +8,8 @@ import { resolveModulePath, resolveFilePath } from './load.js'
|
|
|
8
8
|
|
|
9
9
|
export async function buildSymbolTable(uri, text, parser) {
|
|
10
10
|
const { tokenizer, language } = parser.sailTokenizer
|
|
11
|
-
const
|
|
11
|
+
const tree = tokenizer.parse(text)
|
|
12
|
+
const rootNode = tree.rootNode
|
|
12
13
|
const imports = getImportNodes(rootNode, language)
|
|
13
14
|
const { groups, tags } = getTagNodes(rootNode, language)
|
|
14
15
|
const { maps } = getMapNodes(rootNode, language)
|
package/lib/tokens.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { firstOfType, childrenOfField } from './utils.js'
|
|
2
|
-
export const pathDef = (node) =>
|
|
2
|
+
export const pathDef = (node) => {
|
|
3
|
+
if (!node) return null
|
|
4
|
+
const text = node.text
|
|
5
|
+
return text.startsWith('+') ? text.slice(1) : text
|
|
6
|
+
}
|
|
3
7
|
|
|
4
8
|
export const moduleDef = (node) => node?.text?.slice(1) ?? null
|
|
5
9
|
export const moduleRef = (node) => node?.text?.slice(1) ?? null
|