Git Product home page Git Product logo

gomud's Introduction

gomud's People

Contributors

k1c14k avatar

Watchers

 avatar

gomud's Issues

Implement variable creation and assignment

Should allow two scenarios of variable creation - by declaration and assignment. Example:

x = some.method()
x, y = some.method(), 3

So basically:

<assign-expression> ::= <identifier-list> "=" <expression-list>
<identifier-list> ::= <identifier> | <identifier> "," <identifier-list>
<expression-list> ::= <expression> | <expression> "," <expression-list>
  • Add token for assign operator "="
  • If identifier is used for the first time, it should be created based on expression being assigned
  • Implement basic type checks
  • Documentation: variables, assign statement

Improve internalClass, internalObject and internalMethod

Currently internal implementations of Class, Object and Method try to imitate vm ones. This makes a mess when creating player context.

  • There should be only one definition of Class and Object types
  • There should be a vmMethod and internalMethod types: vmMethod should execute Operations and internalMethod should call internal function
  • Method should store argumentCount and returnCount

Document:

Handle multiple return values

Extend functionality #23 , so that function can return multiple values at once.

TODO:

  • Extend function declaration with return declaration list
  • Extend return statement to handle multiple values
  • Support assignment operators (=, :=) to handle multiple values on the right hand side
  • Document

Introduce if statement

Currently there are no control statements. Introduce if statement, so the following code works:

func HandleLine(line string) {
    if (line == "enter") {
        player.Move("room_b")
        player.Send(room.GetDescription())
    }
}
  • Implement if-else statement (lexer, parser, compiler)
  • Implement == operator
  • Implement conditional jumps (vm)
  • Documentation: Grammar, keywords, tokens, statements, operators

Blocked by: #16

Introduce room context

Implement a new context along player, so that following pseudocode works:

player.Move("room_b")
player.Send(room.GetDescription())

In example above, room is a context, which can be called and player.Move causes to change current room context to switch to an object of roob_b.

  • VM should keep a map of all created rooms
  • room context should change when player is moving
  • Documentation: contexts

VM class registry

Improve loading not compiled classes and registering internal objects

Handle imports

Import statement should load a class into Class.imports collection and allow programmer to create a new instance of this class.

Example code:

import (
    "dir/some_class"
    "dir/next/some_class" as "class_alias"
)

func DoSomething() {
    a := new some_class
    b := new class_alias
}

Things to consider:

  • How "new operator" should look like?

Implement arithmetic operators and data types

Language currently supports only string addition. More data types and operators should be available.

Data types:

  • int
  • float

Operators:

  • subtract
  • divide
  • modulo
  • multiply

Wiki:

  • Documentation: GMSL

Implement inheritance

It should be possible to use inheritance when creating new classes, eg. for player and room objects.

Handle function return value

Currently only void methods are supported. Handle method output. Implement both return value declaration and return statement.

Currently function declaration is implemented as follows:

<function-declaration> ::= "func" <identifier> "(" <argument-declarations> ")" "{" <statements> "}"
<identifier> ::= <any valid identifier>
<argument-declarations> ::= <argument-declaration> | <argument-declaration> "," <argument-declarations>
<argument-declaration> ::= <identifier> <type>
<type> ::= <any valid type>
<statements> ::= <statement> | <statement> <statements>
<statement> ::= <any valid statement>

To do:

  • Extend <function-declaration> to include return types as <return-types> ::= <type> | "(" <types> ")" and <types> ::= <type> | <type> "," <types>
  • Add return statement as <return-statement> ::= <expression-list> and <expression-list> ::= <expression> | <expression> "," <expression-list>
  • Documentation

Move logging to logrus

There are many places with excessive logging or using fmt.Println to debug application.

  • Remove fmt.Println calls
  • Replace default log calls with logrus with correct log levels
  • Documentation: Aplication logging

Remove package declaration

Package declaration was inspired by GoLang. VM doesn't use this abstraction and each file is considered as a separate class. It makes no sense having a package declaration in code.

Clean Assembly

Currently there is a mess with AssemblyEntries being too creative.

  • AssemblyEntry should be a single struct having: OpCode, (int, optional, if none => 0) value, token reference
  • Assembly should group entries by methods
  • Method info should contain argument types and return types

Documentation:

  • VM Operations (assembly)

Cleanup AST structures

Currently AST node structures are complex, have many pointers and are hard to understand.

Cleanup those structures:

  • Remove pointer declarations, where not necessary
  • Remove interface fields in structures
  • Add "pretty" printing

Documentation:

  • Compiler AST

Move method execution code

Currently, method is executed within Method.Execute method. It should be executed on ExecutionFrame.

  • ExecutionFrame should get string pool and operations from Method before execution
  • ExecutionFrame should have a program counter to execute step-by-step and enable jumps in future
  • Documentation: VM ExecutionFrame

Make tokens more specific

Some tokens share functionality, eg. IdentifierToken stores also context name.

  • Split context name token from IdentifierToken
  • Document tokens

Introduce fields

Object should have fields. They should be defined by assignment statements outside of function scope.

Escape character does not work in StringToken

Currently escaped characters like \r\n are not translated correctly to #10#13 characters.

  • Support \n escaped character to place #10#13 sequence
  • Ignore \r escaped character
  • Replace \t with #9
  • Replace \\ with \
  • Replace \" with "
  • Documentation: String literals

Parser mechanism

Currently parser is based on many (sometimes recursive) calls, which is hard to read and debug. Rewrite it to use stack/states.

Driver run configuration

User should be able to pass configuration to driver on startup.

Following properties should be configurable:

  • Server host
  • Server port
  • Mudlib directory

Sources of configuration:

  • CLI flags
  • mud.yaml file in CWD

Documentation:

  • CLI documentation
  • Config file documentation

Move MCCP implementation to a filter

Currently compression is handled by in connection struct.

  • Create ZlibFilter and PlainFilter, so that this logic is moved away
  • Implement MCCP1 fallback handshake option

Documentation:

  • MCCP protocol implementation notes

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.