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

Is there a parser to generate reka AST? #21

Open
dinfer opened this issue Apr 12, 2023 · 3 comments
Open

Is there a parser to generate reka AST? #21

dinfer opened this issue Apr 12, 2023 · 3 comments

Comments

@dinfer
Copy link

dinfer commented Apr 12, 2023

Is it possible to parse tsx/jsx code to reka AST and transform the AST to code?

@prevwong
Copy link
Owner

Is it possible to parse tsx/jsx code to reka AST

Not possible currently and not planned for as I would imagine this would take significant effort with no clear benefits; and a typical JSX file has a lot more going on (ie: imports, functions, lifecycles etc) which may require us to come up with a way to support all of these in the AST. Do you have a specific use case in mind?

The current idea in my head is to only support one way transpilation of Reka AST to React/Vue/Svelte code. This can be achieved by translating Reka's AST to something like Mitosis which itself already handles transpilation to React/Vue/Svelte code.

transform the AST to code?

Reka's AST can be transformed to Reka code via the @rekajs/parser package:

import * as t from '@rekajs/types';
import { Parser } from '@rekajs/parser';

const ast = t.program({...});

const code = Parser.stringify(ast);

@dinfer
Copy link
Author

dinfer commented Apr 23, 2023

Thanks, a lot.
I just found a visual coding platform (https://www.codux.com/), and changing some components' props looks pretty convenient. I want to use it in an existing project, but there are no alternatives. After some searching, I found this fantastic project. Is there a way to avoid the syntax @if, and @each, and make us feel like just dragging valid JSX code?

@sergeylukin
Copy link

@dinfer I actually like @if and @each notation a lot. You can still drag JSX code by attaching @if and @each to a dummy container and having your JSX inside that container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants