dsl

Scala External DSL — Multi line string literal

流过昼夜 提交于 2020-01-04 02:44:57
问题 I am trying to define an external DSL using the scala parser combinators. I see that the 'stringLit' token parser does not accomodate multi line strings using the triple quotes. Is there something similar to a multiLineStringLit in the scala parser combinator world? Thanks in advance, Kishore 回答1: Not that I'm aware of, but it's not too hard to write your own: import scala.util.parsing.combinator._ object myParser extends JavaTokenParsers { def mlStringLiteral: Parser[String] = ( "\"\"\"" + "

How to unit test Spring IntegrationFlow?

微笑、不失礼 提交于 2020-01-03 19:07:10
问题 I have been using Spring Integration DSL to implement some messaging processing flow. How can I actually unit test a single IntegrationFlow, can anyone provide me with an example on how to unit test i.e. transform part of this bean: @Bean public IntegrationFlow transformMessage(){ return message -> message .transform(new GenericTransformer<Message<String>, Message<String>>() { @Override public Message<String> transform(Message<String> message) { MutableMessageHeaders headers = new

Is it possible to define a new operator in Groovy?

走远了吗. 提交于 2020-01-03 12:30:08
问题 Is it possible to define a brand new operator in Groovy? I would like to express a trade where someone buys 200 items for the price of 10 like this: def trade = 200 @ 10 Is this achievable? Thanks EDIT: I want to make it clearer that I am interested in defining an operator not adding a method. Cheers. 回答1: I am not quite sure how you can make this work for the @ sign but you could certainly add the operation like this which I actually find more expressive: Number.metaClass.buyFor { Integer

Domain Specific Language (DSL) vs. Frameworks

妖精的绣舞 提交于 2020-01-03 08:57:50
问题 What is the main difference between the main idea of DSL and Frameworks? These two issues are very confusing to me and i couldn't find a proper answer through internet! 回答1: Good question. This is the simplest explanation I see: A DSL can have its own concrete syntax. A framework cannot have its own syntax since it is used in the same language in which it was created. Domain Specific Languages versus Frameworks For example: HTML is a DSL, whereas directives in the AngularJS framework are

How can I define a method which arguments have no type in Ruby [closed]

我怕爱的太早我们不能终老 提交于 2020-01-03 06:01:08
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . If I defined a method: def weird_method(first_argument, second_argument) #code here end so this way I can pass arguments like : 1, :digit, 'some', "more"(Fixnum, Symbol, String etc.) , BUT what If I wanted to pass just this: argument1, argument2 , I mean values that have no type and look like local

Groovy override compareTo

烈酒焚心 提交于 2020-01-02 05:30:10
问题 I am working under DSL using Groovy categories and I need to override/overload == operator. It is however known issue, that when class implements Comparable , Groovy will call compareTo() method for == operator. I'm looking for some workaround (not AST transformation) in order to make == do exactly what I want. I have the following "toy" situation: class Base implements Comparable<Base>{ int a, b Base(int a, int b) { this.a = a this.b = b } @Override int compareTo(Base o) { return a <=> o.a /

Strategy for parsing natural language descriptions into structured data

穿精又带淫゛_ 提交于 2020-01-01 08:19:10
问题 I have a set of requirements and I'm looking for the best Java-based strategy / algorthm / software to use. Basically, I want to take a set of recipe ingredients entered by real people in natural english and parse out the meta-data into a structured format (see requirements below to see what I'm trying to do). I've looked around here and other places, but have found nothing that gives a high-level advice on what direction follow. So, I'll put it to the smart people :-): What's the best /

Using Python functions in Tkinter.Tcl()

瘦欲@ 提交于 2020-01-01 06:47:14
问题 I have a bunch of Python functions. Let's call them foo , bar and baz . They accept variable number of string arguments and does other sophisticated things (like accessing the network). I want the "user" (let's assume he is only familiar with Tcl) to write scripts in Tcl using those functions. Here's an example (taken from Macports) that user can come up with: post-configure { if {[variant_isset universal]} { set conflags "" foreach arch ${configure.universal_archs} { if {${arch} == "i386"}

Using Python functions in Tkinter.Tcl()

落花浮王杯 提交于 2020-01-01 06:46:06
问题 I have a bunch of Python functions. Let's call them foo , bar and baz . They accept variable number of string arguments and does other sophisticated things (like accessing the network). I want the "user" (let's assume he is only familiar with Tcl) to write scripts in Tcl using those functions. Here's an example (taken from Macports) that user can come up with: post-configure { if {[variant_isset universal]} { set conflags "" foreach arch ${configure.universal_archs} { if {${arch} == "i386"}

How do I create an “OR” filter using elasticsearch-dsl-py?

瘦欲@ 提交于 2020-01-01 04:58:06
问题 The query below is what I would like to construct using elasticsearch-dsl-py, but I do not know how to do it. GET /my_index/_search { "query": { "filtered": { "filter": { "bool": { "must": [ { "term": { "status": "published" } }, { "or": { "filters": [ { "range": { "start_publication": { "lte": "2015-02-17T03:45:00.245012+00:00" } } }, { "missing": { "field": "start_publication" } } ] } }, { "or":{ "filters": [ { "range": { "end_publication": { "gte": "2015-02-17T03:45:00.245012+00:00" } } },