dsl

For what kind of problems do you write a DSL?

痴心易碎 提交于 2019-12-31 19:22:06
问题 I'm just curious about Domain-Specific Languages. I have seen them several times in articles, and it seems that they can be used outside assurance or bank data definition problems. So I come to SO to have some concrete input. Did you ever use a DSL? Write one. If yes, what's it feel like? Do you think one of your projects could be better (more productive, more maintainable, ...) with a DSL? Edit : I'm sorry to put this after, but i was meanning a specific DSL that you wrote yourself. It's

Ruby: looking for ruby-embeddable interpreter or scripting language [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-30 13:35:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . In response to a previous question, @Pablo Fernandez suggested I implement a simple interpreter using Treetop to embed in my RoR application. It looks like a good approach. But I can't help but wonder: hasn't anyone written a toy interpreter to embed in a Ruby app? I don't need any I/O functions -- in fact, I

Typed abstract syntax tree with function application

烂漫一生 提交于 2019-12-30 04:56:09
问题 I am trying to write a typed abstract syntax tree datatype that can represent function application. So far I have type Expr<'a> = | Constant of 'a | Application of Expr<'b -> 'a> * Expr<'b> // error: The type parameter 'b' is not defined I don't think there is a way in F# to write something like 'for all b' on that last line - am I approaching this problem wrongly? 回答1: In general, the F# type system is not expressive enough to (directly) define a typed abstract syntax tree as the one in your

Printing an AST with variable names

家住魔仙堡 提交于 2019-12-30 02:27:06
问题 I am trying to implement an EDSL in Haskell. I would like to pretty print the AST with the variable names that are bound (if I can't get the real names then some generated names would do). This is how far I have got with a simple example: import Control.Monad.State data Free f a = Roll (f (Free f a)) | Pure a instance Functor f => Monad (Free f) where return = Pure (Pure a) >>= f = f a (Roll f) >>= g = Roll $ fmap (>>= g) f data Expr a = I a | Plus (Expr a) (Expr a) deriving (Show) data

Flexible English date phrase library for Python?

牧云@^-^@ 提交于 2019-12-29 09:58:28
问题 I'm looking for a function that can convert an English date phrase to some kind of Python date object representing the appropriate date. An example of the kinds of things I'm looking for (though I'm flexible): Three days from now yesterday In a month Next year January 18, 2011 Next Wednesday Is there such a thing? Is there one perhaps in another language? 回答1: parsedatetime, always a classic: http://code.google.com/p/parsedatetime/ 回答2: I think the best bet here would be the mxDateTime. The

Need Groovy syntax help for generating a Closure from a String

扶醉桌前 提交于 2019-12-29 09:14:26
问题 I'm trying to generate a closure from a string. The code inside the closure references a DSL function build(). The errors I'm getting imply that Groovy is trying to execute the closure instead of just declaring it. What is the correct syntax for this? Here are some of the constructs I have already tried. sh = new GroovyShell() cl = sh.evaluate( '{ build("my job") }' } => Ambiguous expression could be either a parameterless closure expression or an isolated open code block; sh = new

Drools - Grouping multiple dsl conditions in dslr's when part throws error

∥☆過路亽.° 提交于 2019-12-25 09:03:07
问题 Am creating a small rule engine and using drools for it. My design is like the developer (that's me :)) will develop dsl and a business user can create rules (dslr). dsl file [When]When [Pp]urchase amount is greater than "{Value}" = e : Event(EventAction.isPurchaseGreaterThan(e,{Value})) [When]If [Cc]ustomer tier equals to "{CustomerTier}"=e1 : Event(EventAction.isCustomerTierEqualTo(e1,"{CustomerTier}") [Then]Give "{Discount}" Percentage Discount = RewardAction.applyDiscount(e, {Discount});

Populate domain objects from tabular data in groovy

混江龙づ霸主 提交于 2019-12-25 02:38:09
问题 Have been using Spock a fair bit, and really like the ability to use tables in tests for input/output scenarios. example from spock docs: class Math extends Specification { def "maximum of two numbers"(int a, int b, int c) { expect: Math.max(a, b) == c where: a | b | c 1 | 3 | 3 7 | 4 | 4 0 | 0 | 0 } } I work in the finance industry where we deal with a lot of trading "books". Would be great to represent those books in tabular form. So instead of using builders, e.g: builder.addQuote( 1000000

is SFig language syntax efficient and clear (and better than Spring-Framework's XML DSL)?

主宰稳场 提交于 2019-12-25 01:19:09
问题 ADDENDUM EDIT: Have not accepted an answer to this as there has not been any feedback from experienced Spring Framework developers. I've been working on a replacement DSL to use for Spring-Framework applicationContext.xml files (where bean initialization and dependency relationships are described for loading up into the Spring bean factory). My motivation is that I just flat out don't like Spring's use of XML for this purpose nor do I really like any of the alternatives that have been devised

Extending the Kotlin Data Class for use with JPA?

狂风中的少年 提交于 2019-12-24 19:28:08
问题 Kotlin has a Data class that automatically implements equals and hashcode , but these are still not automatically usable in a JPA context. In order to remedy this I was wondering what it would take to extend the Data type in order to either assign a "Business Key" or an id property that is final and non updatable and is initialized with a UUID that serves as the business key, and have equals() and hashcode() methods use that property for their implementation. I was thinking roughly something