dsl - 使用 XmlCompiler 在运行时定义的条件变量

标签 dsl haxe hexmachina

关于 conditional parsing on hexIoC 的快速问题.

据我所知,hexIoC 支持在编译时和运行时使用多 channel DSL 解析。

是否有解决方案,可以使用带有在运行时定义的条件变量值的 XmlCompiler?

类似的东西:

var useHlsJs:Bool = true;
#if js
useHlsJs = useHlsJs && !this.isMobile();
#end
applicationAssembler = XmlCompiler.readXmlFile( "videoplayer/configuration/context.xml", null, ["useHlsJs" => useHlsJs] );

最佳答案

没有。 现在让我解释一下原因。

XmlCompiler 解析的 Xml 最后生成平台代码(JS、Php...),为此它使用条件变量在生成之前解析 DSL。

简而言之,这意味着在运行时这个条件 DSL 不再存在。您的 DSL 已被解析并转换为平台代码,所有条件变量排除的 block 已被删除。

<root name="applicationContext">
    <test if="js" id="s" value="hello JS"/>
    <test if="php" id="s" value="hello PHP"/>
</root>

这将生成 -D php=true

coreFactory.register( "s", "hello PHP" );

如果你想在运行时用条件解析你的 DSL 的一部分,你应该为这部分使用 XmlReader 而不是 XmlCompiler。

关于dsl - 使用 XmlCompiler 在运行时定义的条件变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39445999/

相关文章:

java - Spring Integration DSL JMS 入站/出站网关

generics - 如何检查该对象是 Haxe 中泛型的实例

haxe - 使用单个脚本测试多种 Haxe 目标语言

constructor - function new 或 public static main

eclipse - Xtext:JvmModelInferrer 初始化字段

ruby - 需要帮助改进 Ruby DSL 以控制 Arduino 控制的饮料分配器(bar monkey)

.net - DSL : TCL or Lisp? 有什么更好的