Giter Site home page Giter Site logo

vurv78 / expressive Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 520 KB

Expression, but it's Typescript (with extras). Replacement for Expression2, ExpAdv, Starfall

Home Page: https://vurv78.github.io/Expressive/web/index.html

License: GNU General Public License v3.0

Lua 96.95% TypeScript 1.90% HTML 0.84% CSS 0.31%
wiremod expression2 gmod garrysmod e2 programming-language glua typescript transpiler compiler

expressive's Issues

[feature] Classes

Is your feature request related to a problem? Please describe.
There's no way to interface with external gmod types / userdata, like Vector and Angle.

Describe the solution you'd like
Classes to be made, alongside complex types / #12

class Foo {
	public bar: double;
	constructor(a: double, b: double) {
		this.bar = a + b;
	}
}

let afoo = new Foo(5.0, 10.0);
print( afoo.bar );

Additional context
This would need to be accompanied, or soon accompanied by an extern version.

declare class Vector {
	public x: double;
	public y: double;
	public z: double;

	public Div(divisor: Vector): void;
	public Angle(): Angle;
}

[feature] Editor change

Syper has been a great editor, but I've largely had to hack it in and I don't want to maintain a whole massive editor. It has support for stuff like multiple windows and image loading as well, but those aren't necessary for the language.

Possibilities

1. Making my own editor with derma (Cons: No support for external environments)
2. Making an ide with eclipse theia (Cons: Beta tech, not much documentation, not been tested to work with CEF)
3. Simply embedding monaco as a start (Cons: No file browser or any sort of "IDE" features, it's just an editor)

Future

In the future as seen in #5, I want to get this in other environments. nanos world has recently merged CEF, so now there's more of a benefit to 2 and 3.

1 Is the least likely possibility now that this has happened, as I don't want to maintain a new editor for an essentially dead game, while I could maintain one editor that can be run on the web alongside any games that use CEF.

[feature] Directives

Is your feature request related to a problem? Please describe.
There's no way to change the model/name/author etc of the chip

Describe the solution you'd like
I'd prefer one that doesn't break typescript in editors with a new syntax. So it could look like this:

/*
	@name Vurv
	@model xyz.mdl
	@author Vurv
*/

Describe alternatives you've considered
Using @directive syntax, just as E3 and E2 did. This would break using Expressive outside of the in-game editor, and be another thing straying further from TS, which this shouldn't do.

Also, this could lead into doc comments for any item, when the parsing for this is ready. That would be a different issue though.

[bug] Tokenizer line/char is not always accurate

Describe the bug
Sometimes the line / char is inaccurate when parsing something with the tokenizer. This is very annoying with error traces.

Note this is a shortcoming from using lua patterns as the tokenizer, which gives less control as to what happens for more performance. There is probably an elegant solution to this that maintains the pattern matching tokenizer, but it is definitely a lot more complex than if it looped over all chars.

To Reproduce
Nothing right now

Expected behaviour
Get proper line/char of the token.

[feature] Complex type system

Is your feature request related to a problem? Please describe.
Objects don't exist in the type system, and classes cannot exist without a complex type system.
Right now types are strings. Either the "typename", or "function(ptype, ptype2):ret" for function signatures.

Describe the solution you'd like
The type class to have a bunch of methods and fields to define whether it is variadic, an alias, an array (xyz[]) type, optional / nullable, an enum type (number | string) or a raw enum "foo" | "bar".

This would be an internal change, so it wouldn't add something like this:

type foo = number;
type bar = foo | string;

Additional context
This is necessary to resolve #13

[feature] Better Error Display

Is your feature request related to a problem? Please describe.
Depends on #10 being fixed.

Describe the solution you'd like
I'd like for error messages to be similar to Rust's errors, where the tokens are pointed out in a code block, and potentially there is a "fixed" code block right under.

E.g.

if (true) {

}

/*
	Warning:
		Redundant if statement:
			if (true)
			^^^^^^^^^ This will always run the if statement.
*/

Or an example from codespan
Example preview

[feature] Autocomplete

Describe the solution you'd like
Need to reimplement autocomplete, since the repo has detached from being an E3 fork. This would be through changing the existing declaration exports to use the proper exports table in the ExtensionCtx.

[feature] Compiler Warnings

Describe the solution you'd like
Warnings output from the internal compiler (tokenizer, parser, analyzer, transpiler).

Additional context
These are to work with the Syper console.

[feature] ``export`` Keyword

Is your feature request related to a problem? Please describe.
Need to be able to export created variables and functions from extensions to user chips,

Describe the solution you'd like
You could export variables in order to pass them to user chips

export const foo = 55;

Describe alternatives you've considered
Taking them from the scope, although this would be way less explicit and could lead to variable collisions

Additional context
This is needed mostly for extensions right now, since modules / imports are not a thing
This should also replace the existing auto-exporting behavior of declare, so instead of typing

declare var CLIENT: boolean;

you'd now put

export declare var CLIENT: boolean;

as you'd see in regular typescript.

[feature] DCE Pass

Describe the solution you'd like
DCE Pass for the Optimizer / Analyzer (dead code elimination)

Would also throw warnings for #1

Granted this would be kind of useless for luajit (I'd hope so), so this is more for throwing warnings.

[bug] ``return`` does not accept variables

Describe the bug
If you try and return with anything but a literal, it will fail, with the token seemingly being skipped or just not existing at all.

To Reproduce

function foo() {
	let bar = 55;
	return bar; // FAIL: "Expected ; after return", as it finds the semicolon instead of the identifier in the parser
};

Expected behaviour
Return works with identifiers.

Additional context
The tokenizer works fine. Inspecting the output tokens gives proper identifiers and semicolons. This is something incredibly cursed with the parser.

[feature] Objects

Is your feature request related to a problem? Please describe.
There's no way to interface with lua tables right now, at least non-sequential ones. This is one of the things holding this back from making a raytracer / using util.TraceLine

Describe the solution you'd like
Object types / Object values.

let foo = { bar = "foo", qux = 55 };

This would finally need a type rework to use complex structs and ids rather than strings for names etc.

Additional context
This could also be done with interfaces to define the type

interface Foo {
	bar: string,
	qux: double
};
let foo: Foo = { bar = "foo", qux = 55 };

Inactivity

This is an issue for anyone looking across this repo as I haven't committed in a quarter of a year

The repo is currently inactive as I work on LuaPro as a sister repository for the sake of rewriting the lexer and parser of Expressive since this is going to be a much more difficult task than parsing lua is. (Also was inactive because I needed to focus on school)

Additionally if I am able to complete LuaPro it could serve as a secure backend to this to verify the code generation is safe and as an optimizer.

[bug] Call exprs outside of a statement are broken

Describe the bug
Call expressions outside of a statement lead to nil / unknown transpile target

To Reproduce
Steps to reproduce the behavior:

  1. print("test")
  2. Error

Expected behaviour
Shouldn't error

Additional context
Doesn't seem to effect other expressions (last I remember)

[feature] Run outside of Garrysmod

Describe the solution you'd like
In the future, I want to see this as a solution to the lua problem. Lua is a great language for what it's meant to do. It's easy to embed and blazing fast (luajit). However, this comes with pitfalls with no typing system, oop or other features familiar to programmers. This would compile to hyper-optimized lua and be strictly typed to prevent bugs.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
It already runs perfectly fine outside of garrysmod, but only the barebones compiler (tokenizer, parser, analyzer, optimizer transpiler, etc). For this issue, I am forbidding any use of garrysmod functions in the compiler.

As a first target, it would be great to get this working with nanos world
Next, this could move on to supporting raw lua through a simple cli.

Note this is just here as a little wish for the future of this. It either won't happen, or not for a long while.

[feature] Chaining Ops

Is your feature request related to a problem? Please describe.
Can't chain most operations (besides arithmetic)

let foo = 5 >> 5 >> 5 >> 5 >> 5;

Describe the solution you'd like
To be able to chain them, like you now can with arithmetic ops.

  • Bitwise & |
  • Bitshift >> <<
  • Logical || &&

Additional context
Would like to share as much code as possible to do this, and make the implementation less jank than the current one for arithmetic

[bug] CPU Quotas don't work

Describe the bug
Quota doesn't work

To Reproduce

while (true) {}

Expected behaviour
Halts the chip before killing the server/clients..

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.