Skip to content

General discussion #4

Open
Open
@danixeee

Description

@danixeee

First of all, I would like to change configuration file name (currently .txconfig), since on Unix-like systems, any file that starts with dot is treated as hidden file. Textxfile came to my mind, obviously because of Dockerfile and Jenkinsfile. :)

Below is the example of old .txconfig file:

dsl MyDSL [mydsl] {

	general {
		publisher: "test"
		version: "0.0.1"
	}

	paths {
		grammar: "mydsl/simple.tx"
		outline: "mydsl/outline.txol"
		classes: "mydsl/lang.py:get_classes"
		builtins: "mydsl/lang.py:get_builtins"
		model_processors: "mydsl/lang.py:get_model_proc"
		object_processors: "mydsl/lang.py:get_obj_proc"
	}
}

I personally think that mydsl/lang.py:get_classes is a little bit confusing (we are pointing to a function from a python file, which is not a path like mydsl/simple.tx few rows above) and since we have already lang.py file, we can implement a python API to register those metamodel custom arguments.

So, the new configuration will contain just paths:

dsl MyDSL [mydsl] {

	general {
		publisher: "test"
		version: "0.0.1"
	}

	paths {
		grammar: "mydsl/simple.tx"
		outline: "mydsl/outline.txol"
	}
}

and the lang.py will look something like this:

from textx_ls_core import register_class, register_model_processor

@register_class()
class SimpleType(object):
    # Omitted

@register_model_processor()
def model_processor1(model, metamodel):
    # Omitted

@register_model_processor()
def model_processor2(model, metamodel):
    # Omitted

but this will require a naming convention or a path to this file, so it can be dynamically loaded.

Thoughts?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions