delph-in / pydelphin

Python libraries for DELPH-IN
https://pydelphin.readthedocs.io/
MIT License
77 stars 27 forks source link

Parse TDL environments other than :type and :instance #391

Open goodmami opened 1 month ago

goodmami commented 1 month ago

In anticipation of parsing a unified config file (https://github.com/delph-in/docs/wiki/GrammarConfigurationRfc#proposal), PyDelphin needs to be able to parse TDL environments that are not just :type or :instance. Beyond :config, there may be a need for various places to store metadata or project information, such as things currently stored in grammar METADATA files.

arademaker commented 1 month ago

Maybe something to add in the proposal, but commenting here first to antecipate any problem. Trying to avoid the if/endif. In Lisp the annotation applies only to the next form. We can test for positive and negative presence of a feature.

:#+ACE.
quickcheck-code           := "../ace/ace-erg-qc.txt".

:#+LKB.
maximum-number-of-edges   := 4000.

:#+(or ACE LKB)
some-thing := 100.

#-ACE
ace-doesnt-know := 100.

#+(and ACE LKB)
both-ace-lkb-knows := 100.

Inspirred by Lisp *features*, see http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_1-5-2-1-1.html. But we can surely limited the available keywords and possible boolean expressions.

goodmami commented 1 month ago

I think I would like to avoid booleans altogether to keep things simple. Instead I'm leaning toward the sub-proposal #2 using :include and maybe the optional parameter of :begin :config [...].. For example:

; config.tdl
:begin :config.
...
  :begin :config ace.
  :include "ace/config".
  :end :config.
...
:end :config.

or just:

; ace-config.tdl
:begin :config.
:include "config".
:include "ace/config".
:end :config.

I agree that we should avoid any kind of :if/:endif.