-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Usage of lips.Formatter
#370
Comments
You can see the usage of it in the lib/js/terminal.js file: var formatter = new lips.Formatter(code);
if (!code.match(/\n/)) {
formatter.break();
}
output = formatter.format({
offset: prompt.length
});
Note that it's not 100% working, that's why I didn't add a Scheme formatting tool that is available online. One known issue is that it doesn't add an extra newline between top level S-expressions. If you find some bugs in indentation or line breaking, you can report them. I will keep the issue open to add docs. |
No, I was asking about determining where to insert line breaks when you have a Anyway, I have to parse the code with |
If you have the meta tags are returned by the Formatter only work on strings, if you have code you can only evaluate it or stringify the code and then reformat. Can I ask why you exactly need |
maybe a screenshot of what I have so far would help. This code: (define hello (lambda (x . args) (apply format #t x args))) (begin (display (foo "hello\n")) (newline)) Each of the elements has a reference to the LIPS object that it is contained by, so when I add the ability to edit the code in-place (i.e. dragging around each of the forms) it will update the actual syntax tree without having to re-parse it every time.
Definitely do! Once that is implemented, my problem has a simple solution: format the code, then parse it, and then while walking the tree if two forms' line numbers are different, welp, insert a |
I am trying to build a block-based Scheme editor -- sort of like Edublocks but for Scheme instead of Python.
I'm able to turn each parentheses-enclosed form (i.e. the Pair objects returned by
lips.parse
) into an element, but as for deciding where to insert line breaks and make the elements flow downwards instead of to the right, it looks like the Formatter should be about to do that, but I can't figure out how to do that -- seeing that the Formatter isn't documented well (if at all).The text was updated successfully, but these errors were encountered: