{"id":19041553,"url":"https://github.com/xaxys/lxa","last_synced_at":"2025-04-23T21:45:46.913Z","repository":{"id":130001182,"uuid":"249346859","full_name":"xaxys/Lxa","owner":"xaxys","description":"A new programming language based on Lua vm.","archived":false,"fork":false,"pushed_at":"2020-05-31T16:55:03.000Z","size":685,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T06:51:22.777Z","etag":null,"topics":["compiler","interpreter","language","lua","lua-script","lxa","programming","programming-language","programming-languages","virtual-machine","vm"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xaxys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-23T05:51:12.000Z","updated_at":"2024-03-14T02:37:33.000Z","dependencies_parsed_at":"2023-04-18T08:02:12.171Z","dependency_job_id":null,"html_url":"https://github.com/xaxys/Lxa","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaxys%2FLxa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaxys%2FLxa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaxys%2FLxa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaxys%2FLxa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xaxys","download_url":"https://codeload.github.com/xaxys/Lxa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522293,"owners_count":21444509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","interpreter","language","lua","lua-script","lxa","programming","programming-language","programming-languages","virtual-machine","vm"],"created_at":"2024-11-08T22:29:47.834Z","updated_at":"2025-04-23T21:45:46.880Z","avatar_url":"https://github.com/xaxys.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lxa\r\n\r\nA new programming language based on Lua vm.\r\n\r\nI developed it for some learning purpose, but it haven't been used in any formal project.\r\n\r\nWARNING! Please expect breaking changes and unstable APIs. Most of them are currently at an early, experimental stage.\r\n\r\n## Update\r\n\r\n* 2020/03/23 Released Lxa v0.1.0.\r\n  * Use Azure/golua as vm.\r\n* 2020/03/25 Released Lxa v0.2.1.\r\n  * Use Official lua 5.3.5 vm (written in c) as default vm.\r\n  * Added inner go lua vm as a option (several stdlib unsupported yet).\r\n  * Added 'Compile Only' option to output compiled lua bytecode (since v0.2.0).\r\n  * Added linux support and x86 support (auto select static lib when compiling) (untested).\r\n* 2020/03/26 Released Lxa v0.2.4.\r\n  * Added Debug option to display details in running.\r\n  * Added 'Parse Only' option to watch bytecode instructions.\r\n  * Optimized Logical Expression generation, now multiple `and` and `or` expressions are specially handled apart from Binary Expression.\r\n  * Fixed bug of 0 length lua string in bytecode.\r\n* 2020/03/27 Updated to Lxa v0.2.5.\r\n  * Optimized Logical Expression Handling.\r\n  * Optimized Syntax Error Information.\r\n* 2020/04/03 Released Lxa v0.2.6.\r\n  * Optimized Syntax Error Information.\r\n  * Removed `Assignment` from ast.\r\n  * Added `BlockStat` for sub code block in syntax.\r\n  * Fixed bug caused by `EmptyStat` in `ForNumStat`, `WhileStat` and `IfStat`.\r\n* Draft\r\n  * Fixed bug of `LogicalExp` in `IfStat` generation.\r\n\r\n## Syntax\r\n\r\nLxa has c-formed syntax with lua-based variable and data structure. Anyone who is familiar with C/C++/Java/Go can easily use it.\r\n\r\nYou can follow these examples or look EBNF below directly.\r\n\r\n### Lexical Conventions\r\n\r\nFree-style Code, basically the same as Lua.\r\n\r\n`;` is not necessary in the end of a sentence.\r\n\r\n`\\n` will be recognized as equal as `;`.\r\n\r\n`\u0026\u0026`,`||`,`!` can be also used as `and`, `or`,`not`\r\n\r\nRemoved `::`, `goto`, `repeat` ,`until` ,`do`,`elseif`,`end`,`then`\r\n\r\nModified `function` to `func`, `//`(Integer Divide) to `~/`, `~=`(Not Equal) to `!=`, `^`(Pow) to `**`, `~`(Xor) to `^`\r\n\r\nAdded `+=`,  `-=`, `*=`, `/=`, `~/=`, `%=`, `**=`, `\u0026=`, `|=`, `^=`, `\u003c\u003c=`, `\u003e\u003e=`, `++`, `--`.\r\n\r\nAdded `?` to judge if a number = 0 or a string length = 0.\r\n\r\n(e.g.`if a := 0; a? { print(\"is 0\")}`, or `if a := \"\"; a? { print(\"a length is 0\")}`)\r\n\r\nUse `{` and `}` to recognize code block.\r\n\r\n(WARNING: Because `\\n` will be recognized as equal as `;`, `{` is not allowed appeared in the next line)\r\n\r\nUse `//` and `/* */` to comment.\r\n\r\n### Assignment\r\n\r\n```lua\r\na, b, c = 1, 2, 3\r\na, b = somefunction()\r\n```\r\n\r\nThe same as Lua, global variable can be assigned directly.\r\n\r\nMultiple value assignment is supported.\r\n\r\n#### Local Variable Declaration\r\n\r\n```lua\r\nlocal a, b, c = 1, 2, 3\r\na, b, c := 1, 2, 3 //the same\r\n```\r\n\r\nThe first statement is the same as Lua.\r\n\r\nThe second go-like statement is also supported which performs the same.\r\n\r\n### Statement\r\n\r\n#### If\r\n\r\n```lua\r\nif a := 1; b := 2; testfunc(); a \u003c b {\r\n    a++\r\n} else if c := a; c != d {\r\n    print(\"c != d\")\r\n} else {\r\n    print('else')\r\n}\r\n```\r\n\r\n'If' statement can contain multiple assignment(or function call) before the expression, separated by `;`.\r\n\r\nThe local variable declared by assignments can only be used inside 'if'.\r\n\r\n#### While\r\n\r\n```lua\r\nwhile a := 0; a \u003c 100 {\r\n    a++\r\n    if a \u003e 50 {\r\n        break\r\n    }\r\n}\r\n```\r\n\r\nThe same as 'if' statement, a 'while' statement can contain multiple assignment(or function call) before the expression, separated by `;`.\r\n\r\n#### For\r\n\r\n```lua\r\nfor i := 0; i \u003c 100; i++ {\r\n    print(i)\r\n    continue\r\n    print(\"unreachable\")\r\n}\r\n```\r\n\r\nThe same as C/C++/Java/Go, a 'for' statement can only contain one assignment(or function call) before the expression and one after the expression, separated by `;`.\r\n\r\n#### ForIn\r\n\r\n```lua\r\nfor k, v in ipairs(map0) {\r\n    print(\"Key: \"..k..\" Value: \"..v)\r\n}\r\n```\r\n\r\nThe same as Lua, a 'forin' statement invoke the function to iterate.\r\n\r\n#### Tips\r\n\r\nLxa removed `goto` and `repeat-until` from syntax. But `continue` is added to syntax.\r\n\r\n### Function declaration\r\n\r\n```lua\r\nfunc add(a, b) {\r\n    return a + b\r\n}\r\nlocal sub(a, b) {\r\n    return a - b\r\n}\r\nmul = func(a, b) {\r\n    return a * b\r\n}\r\ndiv := (a, b) =\u003e {\r\n    return a / b\r\n}\r\n```\r\n\r\nAll Above function declaration are supported(lambda included).\r\n\r\n### Other\r\n\r\nOther Lua feature are supported.\r\n\r\n### EBNF\r\n\r\n```ebnf\r\nchunk ::= block\r\n\r\nblock ::= {stat} [retstat]\r\nretstat ::= return [explist] [';']\r\nexplist ::= exp {',' exp}\r\nnamelist ::= Name {',' Name}\r\nvarlist ::= var {',' var}\r\nvar ::=  Name | prefixexp '[' exp ']' | prefixexp '.' Name\r\n\r\nassignment ::= assign | locvardecl | functioncall\r\n\r\nassign ::= varlist ('+=' | '-=' | '*=' | '/=' | '~/=' | '%='\r\n        | '\u0026=' | '^=' | '|=' | '**=' | '\u003c\u003c=' | '\u003e\u003e=' | '=') explist\r\n\r\nlocvardecl ::= namelist ':=' explist | local namelist [':=' explist]\r\n\r\nexp ::=  nil\r\n    | false\r\n    | true\r\n    | Numeral\r\n    | LiteralString\r\n    | '...'\r\n    | functiondef\r\n    | functioncall\r\n    | prefixexp\r\n    | tableconstructor\r\n    | exp binop exp\r\n    | unop exp\r\n    | varlist ['=' explist]\r\n    | namelist ':=' explist\r\n\r\nprefixexp ::= var\r\n    | functioncall\r\n    | '(' exp ')'\r\n    | prefixexp ':' Name args\r\n    | prefixexp args\r\n\r\nfunctioncall ::=  prefixexp args | prefixexp ':' Name args\r\n\r\ntableconstructor ::= '{' [fieldlist] '}'\r\nfieldlist ::= field {fieldsep field} [fieldsep]\r\nfield ::= '[' exp ']' '=' exp | Name '=' exp | exp\r\nfieldsep ::= ',' | ';'\r\n\r\nfunctiondef ::= func funcbody | lambda\r\nlambda ::= '(' [parlist] ')' '=\u003e' '{' block '}'\r\nfuncbody ::= '(' [parlist] ')' '{' block '}'\r\nparlist ::= namelist [',' '...'] | '...'\r\nnamelist ::= Name {',' Name}\r\n\r\nstat ::= ';'\r\n    | assignment ';'\r\n    | break\r\n    | continue\r\n    | while {assignment ';'} exp '{' block '}'\r\n    | if {assignment ';'} exp '{' block '}' {else if {assignment ';'} exp '{' block '}'} [else '{' block '}']\r\n    | for assignment ';' exp ';' assignment '{' block '}'\r\n    | for namelist in explist '{' block '}'\r\n    | func funcname funcbody\r\n    | local func Name funcbody\r\n```\r\n\r\n## About\r\n\r\nContact me: E-mail: gz@oasis.run, QQ: 963796543, WebSite: [http://www.oasis.run](http://www.oasis.run)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaxys%2Flxa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxaxys%2Flxa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaxys%2Flxa/lists"}