Giter Site home page Giter Site logo

elixir's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

elixir's Issues

Modules fail to be detected when returning a function with a space in it

I'm currently looking to implement ModRemote into one of my projects and I discovered that it was not being picked up by the module detection pattern.

This is our current matching pattern:

r"return\s+\S+(\s+)?$"

And this is ModRemote's return statement:

return setmetatable(remote, remoteMetatable)

The problem lies with \S in the pattern, which matches anything other than a space, tab or newline.

This works for a function without parameters, which is why it initially got committed. But if you're coding with spaces between your parameters, you're going to find that your modules aren't being picked up if you return a function with arguments.

Import existing models when compiling

When Elixir comes in contact with a .rbxmx file in the source directory it should strip away the <roblox> tag and then merge the rest of the XML with the hierarchy.

local file = assert(io.open("source/Assets/Model.rbxmx")
local content = file:read("*a")
file:close()
content = content:gsub("</?roblox.->", "")

content now holds the contents of a model without the <roblox> tags, so it can be easily imported into the model being compiled.

Derive an Instance's Parent based on the file's name

A common practice in ROBLOX is to put ModelScripts inside of other Scripts (even other ModuleScripts) to break up the source code, while still keeping everything modular. This is currently not possible in Elixir because no operating system actually lets you put files inside other files, only folders.

We can use a simple naming convention to determine the file's in-game parent:

src/
  Module.lua
  Module.Child.lua
  Module.Child.AnotherChild.lua

When implemented, the above would compile to the following:

screenshot_1

This would require an overhaul of the current compiler but I think it could be worthwhile.

Add option to beautify the compiled model

"Beautify" meaning to put each XML tag on its own line, and indenting the lines for easier readability. So instead of the model being condensed onto one line (with only Lua files adding newlines):

<Tag><AnotherTag><ThirdTag>Hello, World!</ThirdTag></AnotherTag></Tag>

Each tag would have its own line, with proper indentation:

<Tag>
  <AnotherTag>
    <ThirdTag>Hello, World!</ThirdTag>
  </AnotherTag>
</Tag>

This would be provided under options.beautify and set to false by default. This would be a nice optional feature to have for people that want to be able to read their compiled source code.

As it stands, a human would not be able to easily parse the model.

ModelCompiler is not properly setting the default model_name

This is happening when using a ModelCompiler directly. Everything works as intended from the command line. Given a directory structure of:

src/
  Modules/
    Hello.lua
  SayHello.lua

And this build script:

from elixir.compiler import ModelCompiler

compiler = ModelCompiler("src/", "model.rbxmx")
compiler.compile()

This gives us a model whose root directory is a blank string:

bad-compiling

The top-level folder is too restrictive

Right now, Elixir creates a top-level folder when compiling the model.For example, given the following directory structure:

src/
  Module.lua
  Script.lua

You will get a model with the same contents, unless you set the model_name argument to change src to something else. While this does come with the benefit of keeping all your code in a single place, it's also restrictive.

A better approach would be to remove this, and the user can add an extra folder to contain their source code if they really want everything together.


This also ties into recent changes to Nevermore. In its latest update, it was refactored to just manage ModuleScripts and RemoteEvents/RemoteFunctions. It's no longer about being a game framework. This means you shouldn't be grouping your server and client scripts with all of your modules anymore.

Nevermore requires an instance named Nevermore to exist in game.ServerScriptService. That's easy enough if we change the name of the top-level Folder (by either renaming it, or using the model_name parameter), but we are then required to group our server and client code with our modules, which is not ideal..

Modules fail to be detected when returning a function

The module detection works just fine for regular variables, but when trying to return a function the regex does not recognize it. Elixir is then compiling what should be a module to a Script.

This works fine:

local module = {}

function module.hello()
  print("Hello, World!")
end

return module

But this does not, because we're returning a function. The regex matches \w (alphanumeric characters, plus underscores), which does not pick up parenthesis.

function hello()
  print("Hello, World!")
end

return hello()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.