prochitecture / pml

Translator for PML (Prochitecture Markup Language)
2 stars 0 forks source link

@include "path/to/file.pml"; #1

Closed vvoovv closed 2 years ago

vvoovv commented 4 years ago

@include inserts grammar definition from another file defined by the path:

@include "path";

Includes can be recursive.

It's desired to track down the original PML file and the line number in the original PML file for each line in the resulting PML definition.


Examples:

@include "a/b/c.pml";
@include "a.pml";
@include  "../../a/b/c.pml";

Below is the special case. The leading slash means lookup in the folder where the asset packages are stored:

@include "/default/a/b/c.pml"
polarkernel commented 4 years ago

Includes can be recursive.

What do you mean by that? Normally, recursive includes are not allowed. For instance for a file A.pml

...
@inlcude "files/B.pml";
...

and a file B.pml

...
@inlcude "files/A.pml";
...

will start an infinite include loop. I will check for that and create an error message if found.

polarkernel commented 4 years ago

... lookup in the folder where the asset packages are stored

Where will this location be defined?

vvoovv commented 4 years ago

Includes can be recursive.

What do you mean by that? Normally, recursive includes are not allowed. For instance for a file A.pml

I meant hierarchical rather than recursive. A can include B, B can include C, C can include D and so on

vvoovv commented 4 years ago

... lookup in the folder where the asset packages are stored

Where will this location be defined?

It should be an external parameter to the translator.

polarkernel commented 4 years ago

I have commited a first version of @include. The translator requires now an additional parameter:

python PML2PythonTranslator.py pmlstyle.pml pathToAssets

The path pathToAssets must not have a slash at its end. The following features are included:

Let's see if this meets your requirements.

vvoovv commented 4 years ago

You are very fast!

Trying it out right now.

vvoovv commented 4 years ago

I've made a quick fix in the path: https://github.com/prochitecture/pml/blob/master/PML_Preprocessor.py#L62

Otherwise it would not work if the path were in the absolute form.

polarkernel commented 4 years ago

Good to have an experienced programmer in the team!

vvoovv commented 1 year ago

I changed the regular expression in _PMLPreprocessor.py from

        self.cmnt_patt = re.compile('//.*?\n')

to

        self.cmnt_patt = re.compile('//.*\n?')

The previous regular expression couldn't detect a comment in the last line of a file without the next line symbol.