McCode icon indicating copy to clipboard operation
McCode copied to clipboard

Toward McCode-4 grammar

Open willend opened this issue 2 years ago • 1 comments

Ideas:

a) ASSERT ( isnotnan(par), par1>par2, par2>0) Uses code-generator to evaluate post-INITIALIZE conditions on comp/instr input parameters. McDoc could then list these requirements in a in the comp / instr docs. (Goes together with this idea: To evaluate wether an "optional" parameter is set/unset, let it default to NAN rather than 0. May need consequence-edits in mcdoc.)

b) SNIPPET Grammar to use an external tool for generating instrument-code, example:

COMPONENT Origin = Arm()
AT (0,0,0) ABSOLUTE

SNIPPET %{
#!/bin/sh
echo COMPONENT Arm2 = Arm\(\)
echo AT \(0,0,0\) RELATIVE PREVIOUS
%}

END

Dummy example listed here, one could use e.g. Python and NCrystal-tools, define for-loops etc. The content of SNIPPET %{%} is evaluated at code-generation, writes instrument-code on stdout / to temporary file and is in this way ~ %include

c) Component-driven USERVARS Components should have a way of injecting particle-scope variables, e.g. for Single_crystal / PowderN "check if this is a repetition state" optimisation in SPLITs

willend avatar Jun 16 '22 12:06 willend

@farhi a prototype for c) is now implemented on https://github.com/willend/McCode/tree/mccode-3, will merge once I have done sufficient testing.

willend avatar Sep 16 '22 20:09 willend