Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aceptar otros separadores para paths al construir el environment #287

Open
ivojawer opened this issue Sep 18, 2024 · 1 comment
Open

Aceptar otros separadores para paths al construir el environment #287

ivojawer opened this issue Sep 18, 2024 · 1 comment
Labels
component: parser enhancement New feature or request good first issue Good for newcomers

Comments

@ivojawer
Copy link
Contributor

Hoy en el parser de files esta hardcodeado que los archivos estan en formato posix (separados por /)

wollok-ts/src/parser.ts

Lines 176 to 184 in 5f9763e

export const File = (fileName: string): Parser<PackageNode> => lazy(() =>
obj({
fileName: of(fileName),
name: of(fileName.split('.')[0].replaceAll('/', '.')),
imports: Import.sepBy(_).skip(_),
members: Entity.or(alt(annotation, comment('start'))).or(entityError).sepBy(_),
}).skip(_)
.map(payload => new PackageNode(recover(payload)))
)

Me gustaría que este parametrizado, asi tambien se puede parametrizar buildEnvironment

wollok-ts/src/index.ts

Lines 17 to 27 in 5f9763e

function buildEnvironment(files: List<FileContent>, baseEnvironment: Environment = fromJSON<Environment>(WRE)): Environment {
return link(files.map(({ name, content }) => {
try {
return parse.File(name).tryParse(content)
} catch (error) {
throw new Error(`Failed to parse ${name}: ${(error as Error).message}`)
}
}), baseEnvironment)
}

y facilitar el manejo de paths en Windows.

@ivojawer ivojawer added enhancement New feature or request good first issue Good for newcomers component: parser labels Sep 18, 2024
@ivojawer ivojawer changed the title Haceptar otros separadores para paths al construir el environment Aceptar otros separadores para paths al construir el environment Sep 18, 2024
@ivojawer
Copy link
Contributor Author

ivojawer commented Nov 26, 2024

Para simplificar se podria agregar a

of(fileName.split('.')[0].replaceAll('/', '.'))

otro replace con la contra barra replaceAll('\\', '.') en vez de tener que parametrizar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: parser enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant