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

Execute function for core package #473

Merged
merged 8 commits into from Jan 2, 2020
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Jan 2, 2020

This resolves #469, resolves #471

Progress

  • evalCompiled function
  • execute function
  • compile api changes with backward compatibly, Proposal for new compile API #471
  • works for CLI
  • works for ide site
  • works for unit test
  • works for browser runtime
  • option outputHanzi for CLI
  • option Ouput Hanzi for ide
  • option outputHanzi for runtime
  • Update docs

@haoge568
Copy link

haoge568 commented Jan 2, 2020 via email

@antfu antfu marked this pull request as ready for review January 2, 2020 04:17
@antfu
Copy link
Member Author

antfu commented Jan 2, 2020

@LingDong- It's done. I did a rough test for everything. Hope I didn't break them.


For array output, I use for the separators as you did for site. But I am wondering if we should add a prefix and suffix for that in case we have nested array or more complex formats.

function hanzinize(value) {
  if (typeof value == "number") {
    return num2hanzi(value);
  } else if (typeof value == "boolean") {
    return bool2hanzi(value);
  } else if (Array.isArray(value)) {
    return value.map(i => hanzinize(i)).join("。");
  } else {
    return value;
  }
}

@LingDong- LingDong- merged commit bf28dc2 into wenyan-lang:master Jan 2, 2020
@antfu antfu mentioned this pull request Jan 2, 2020
@LingDong-
Copy link
Member

Nice, thanks a lot!

For nested structures, I had one idea is to use indentation so we don't introduce extra symbols. But then I did some experimentation on how I would use that to express various structures, and found it ambiguous & problematic. So symbols are probably the way to go. e.g.

[0,{a:[1,2,3],b:4},5,6]

《零。《「甲」、《一。二。三》。「乙」、四》。五。六。》

My plan is to add this JSON.stringify-like functionality to the standard library 格物經. Discussion welcome!

@antfu
Copy link
Member Author

antfu commented Jan 2, 2020

My plan is to add this JSON.stringify-like functionality to the standard library 格物經

Sounds very promising! If we could port num2hanzi in Wenyan natively, then maybe we could have two different 書之. One outputs raw data and one outputs hanzi. I think this would open more possibilities for usage.

LingDong- added a commit that referenced this pull request Jan 20, 2020
Execute function for core package
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

Successfully merging this pull request may close these issues.

Proposal for new compile API Exec function in core package
3 participants