not everything is an expression (most notably assignments)

未关闭
#158 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
lua
领域
compilers, web-dev

调研方向

在在线编译器中重现列出的 Moon 示例,并将 parser/compiler 表达式案例与编辑器样式请求分开。检查该语言对表达式和赋值的处理,然后根据生成的 Lua 验证选定的案例;对于 UI 项,检查 prism-editor__container,并确认整个 textarea 都可以点击。在实现之前就更窄的范围达成一致。

由索引模型根据 Issue 内容生成。

描述

hi, I've been using yuescript for a little bit now so I feel pretty familiar with the language. here are some example things that I thought should have worked:

-- parens not working
if (old_val = @v) != new_val
    @v = new_val
-- working
old_val = @v
if old_val != new_val
    @v = new_val

-- assignment not working
lala = (fn) ->
    print "fn:", fn
    fn(math.rand!)
lala listener = (val) -> print val -- left hand expression is not assignable
lala (listener = (val) -> print val) -- syntax error
-- working
lala = (fn) ->
    print "fn:", fn
    fn(math.rand!)
listener = (val) -> print val
lala listener

-- iter not returned
perm = (a) ->
    co = coroutine.create ->
        permgen a, #a
        return -- necessary cause no way to specify no return
    iter = ->
        code, res = coroutine.resume co
        res
-- working
perm = (a) ->
    co = coroutine.create ->
        permgen a, #a
        return -- necessary cause no way to specify no return
    iter = ->
        code, res = coroutine.resume co
        res
    iter
-- ideally, I'd like to write:
perm = (a) ->
    co = coroutine.create !->
        permgen a, #a
    iter = ->
        code, res = coroutine.resume co
        res

-- doesn't consider last expression of do-statement as module value
export default module = do
	{foo: true}
-- also, it doesn't think that the assignment is an expression
module = do
	lala = {foo: true}
export default module
-- working
module = do
	lala = {foo: true}
	lala
export default module
-- also works
export default do
	{foo: true}


in general I really like the language. I've got a lot of ideas as well for improvements to the language:

  • if x isnt nil (is/isnt keywords)
  • type val is "function" (compiles to type(val) == "function" instead of type(val == "function"))
  • type val is \function (single backslash is single word text)
  • !(var) -> ... (no return)
  • !-> ... (no return)
  • comma on next line extends function:
    lala (v1, v1) ->
        print v1, v2
    , var1
    , var2
    

lastly, the online compiler is quite valuable for seeing what yue compiles to and I really like it.
however, the text area only allows me to click on the top.
this can easily be fixed by setting prism-editor__container to have min-height: 100%. (seen below)
edit: that should be 'min-height' (screenshot invalid)

image

cheers!

主要语言
Lua
星标
620
派生
45
平均合并
9 小时 5 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IppClub/YueScript 的其他 Issue

查看 IppClub/YueScript 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。