Phobos


Phobos's goal is to be an optimizing bytecode compiler for Lua with some language extensions and a type system. For more info see the readme (on the homepage or in the mod files), especially 'Factorio Support -> Factorio Mod'. (In short: This mod is 99% a library.)

Internal
1 year, 2 months ago
1.1
119

Changelog

Version: 0.1.5
Date: 2023-10-03
  Bugfixes:
    - Fix error when the optional '--ignore' argument was not specified
Version: 0.1.4
Date: 2023-02-10
  Minor Features:
    - Add `--version` argument
    - Add a human readable header stating the Phobos version in output files with `--use-load`
    - Add `--custom-header` to include a little extra description in the header mentioned above
    - Support files with a shebang
    - Handle invalid nodes in the formatter
    - Implement parsing and compiling as 32 bit signed integer numbers instead of doubles
  Changes:
    - Change output of `--use-load` making it 40-50% smaller, a little bit bigger than raw bytecode
    - Cleanup, improve and update the README and add a docs folder
    - Emit null strings in bytecode wherever null is valid instead of falling back to ""
    - Replace `stat_elem` internally everywhere by using intrusive linked lists
    - Parse malformed numbers just like Lua parses them resulting in more useful syntax errors
  Bugfixes:
    - Fix 'lua.exe' not finding 'lua52.dll' because it was called 'lua.dll'
    - Fix `(foo())` being a valid statement
    - Fix strings in invalid contexts generating invalid AstTokenNodes or failing assertions
    - Fix the local variable for 'fornum' being in the parent scope in the AST
    - Fix unterminated block strings with leading newlines missing said newline in the invalid node
    - Fix unterminated block comments not emitting invalid nodes, so no syntax errors
    - Fix potentially invalid or broken bytecode in functions with more than 256 constants
    - Fix hexadecimal numbers with hex letters in their exponent (malformed) failing assertions
Version: 0.1.3
Date: 2022-02-17
  Minor Features:
    - Add error codes. Makes errors much easier to distinguish when using Phobos as a library
    - Keep all data about the source in the AST regardless of how many syntax errors there might be
  Bugfixes:
    - Fix every package missing the 'lib' and 'optimize' sub directories. 0.1.2 was/is unusable
    - Fix '\r' and '\r\n' resulting in '\r' instead of '\n' in blank tokens
    - Fix unescaped '\r' in strings not causing syntax errors and breaking line numbers
    - Fix too large decimal escape sequences crashing in the tokenizer. For example '\256'
    - Fix string and comment tokens sometimes having incorrect line:column positions
    - Fix ']' inside block strings disappearing
    - Fix `(foo..bar)..baz` performing `bar..baz` first. Only matters when using __concat
    - Fix parenthesis inside of concat chains not being representable inside the AST (data loss)
    - Fix the condition for repeatstat resolving references starting at the parent scope
      For example the condition in `repeat local foo; until foo` would index into `_ENV`
    - Fix scope bodies referring to the parent scope instead of the current scope
    - Fix 'goto's to the end of a repeatstat block being allowed no matter what
    - Fix jump_linker attempting to concatenate nil when the given AST does not have debug
      information and contains an invalid jump
    - Fix backwards 'goto' jumping to the outer most label with the same name instead of inner
Version: 0.1.2
Date: 2022-01-29
  Features:
    - Add continuing parsing after encountering syntax errors
  Changes:
    - Set linux lua executable flag [PR#1](https://github.com/JanSharp/phobos/pull/1)
  Bugfixes:
    - Fix error when requiring files using non normalized module names in Factorio
    - Fix vararg expressions sometimes not assigning values properly
      (for example `local foo, bar; foo, bar = ...`, while `local foo, bar = ...` worked)
    - Fix call or vararg expressions wrapped in `()` not forcing single results and potentially
      not even assigning to the right registers (for example `local foo, bar; foo, bar = (...)`)
    - Fix '\r\n' (or '\n\r' which shouldn't - but can - exist) breaking escaped newlines in strings
      In fact '\r' was mostly unhandled. Now all newlines get properly normalized to '\n' just like
      they do in regular Lua
Version: 0.1.1
Date: 2021-10-25
  Changes:
    - Add missing thumbnail on mod portal
Version: 0.1.0
Date: 2021-10-25
  Major Features:
    - Add command line tool for compiling
    - Implement parsing of Lua 5.2 source code to AST
    - Implement formatting AST to Lua 5.2 source code without making any format changes
      (except concats with parenthesis in the middle of them)
    - Implement compiling AST to Lua 5.2 bytecode
    - Implement disassembling Lua 5.2 bytecode to AST
  Features:
    - Add Factorio in game commands to execute phobos code similar to regular Lua commands
    - Add cmd option to compile to bytecode files or text files that `load` a bytecode string
    - Add cmd option to change the `source` name used for compiled bytecode functions for debugging
    - Add cmd option to monitor memory during compilation
    - Add cmd option to ignore and continue past files with syntax errors
    - Add WIP cmd option for build profiles (debug or release)
  Minor Features:
    - Add Phobos Debug Symbols v0 for use by third party tools (not Lua itself)
  Optimizations:
    - Implement folding pure const expressions
    - Implement folding control statements with pure const conditions
  Scripting:
    - Add WIP cmd AST injection scripts during compilation