Open shadmansaleh opened 3 years ago
Can you post the codes with macro you've tried ? I'm using Yuescript in termux for android with archlinux and it works fine too. More info is needed to locate the problem.
You're right . I had a syntax error . I though I was running same code on arch :P. But I shouldn't crash
macro hello = ()->
"print 'hello'"
$hello
I had !
missing after $hello
on arch it reports error correctly
4: macro expression must be followed by arguments list
$hello
^
But on termux It crashes.
Since you're using on termux can you tell me how you compiled on termux ? It's possible I did something wrong while compiling .
For me:
make
Later when I was having errors I applied tmpname
patch fot liblua on embaded lua source tree . But same result .
Also I you don't mind . A bit off topic but couldn't find anywere else to ask. How to do recursive macros ?
like this?
macro m1 = ()->
""
macro m2 = ()->
"$m1!"
$m2!
I'm using termux with AnLinux which can help installing other Linux systems without root requirement for Android and not running any compiler directly in termux environment. And then I installed ArchLinux in termux using termux environment as a common ArchLinux system to install Yuescript with luarocks.
Syntax error issue seems not to be in the Yuescript C++ codes. I might try compiling Yuescript in termux directly someday. Yes, you are right about doing recursive macros.
macro m1 = ()-> "#{1 + 1}"
macro m2 = ()-> "$m1! + 3"
print $m2!
Will compiles to:
return print((2 + 3))
And you may join the discord group to talk about any thing related to Yuescript any time.
Thanks . I don't use discord for yet . Maybe I'll join someday . if I find any solution to or the reason of segfault I'll let you know.
I was actually trying yuescript as means to scripting in neovim . And having a wierd behaviour with macros that's why I was asking about recursve macros
I had this:
macro auc = (event, patern, cmd)->
if patern::match('^[\'"](.*)[\'"]')
patern = patern::match('^[\'"](.*)[\'"]')
"vim.cmd 'autocmd #{event} #{patern} #{cmd}'"
macro au = (event, patern, cmd)->
"$auc #{event}, #{patern}, #{cmd}"
-- $au BufEnter, '*', :echo "hi" --failed to expand macro as block: syntax error
$au BufEnter, '*', ':echo "hi"'
-- $au BufEnter, '*', 'echo "hi"' --failed to expand macro as block: syntax error
$au BufEnter, '*', echo "hi"
And it compiled to:
vim.cmd({
['autocmd BufEnter * '] = echo(("hi")(''))
});
return vim.cmd('autocmd BufEnter * echo "hi"')
But what I need is
return vim.cmd('autocmd BufEnter * :echo "hi"')
I just can't seem to get the :
. Am I doing this wrong or is this an unwanted behavior ? Is there a way to get the output I'm looking for ? The one where it interpreted ':echo "hi"' as table totaly surprised me .
Is there a equavelent of moonc -X
in yue ?
Are there some docs on yue.so
?
When you import macros where does yue look for the scripts ? Does it have a separate set of directories like package.path
or package.cpath
Or use same as lua?
What's a block marco and when is it allowed ?
I'm getting lua macro can only be placed where block macro is allowed
when running lua macro example from docs . And yeah this error also segfaults in termux . Basically any error handling macro is a segfault.
What does implicit object
mean?
lots of questions :P . I'm really enjoying the language . But unlike commonly used language there's really no other place I can get help from . I'm piling them here for now . So you can answer them when you have time :) Also have joined the discord channel.
I tried yue on android with termux
It compiles and works decently except . When the script has macros it segfaults when while compiling to lua
Backtrace:
Any idea why ?
It was compiled with
clang-12
linked to bionic libc. I tried it on arch with gcc there it worked fine . Not sure if it's an issue with clang or android .Yue version: 0.7.15 (built with
make release
on main branch) lua version 5.4 (compiled by yue, Though I have lua5.1 and luajit installed on system)Also thanks for yuescript :)