dsl

Cannot use “==” and “contains” in same line of scenario using conditional logic in Karate

孤者浪人 提交于 2019-11-28 10:06:08
问题 This is a follow up of a question noted here Lets says our implemented server v1 and v2 response looks as follows v1Response = { id: "1", name: "awesome" } v2Response = { id: "2", name: "awesome", value: "karate" } Similarly we define the client schema for v1 and v2 like as follows v1Schema = { id: "#string", name: "#string } v2Schema = { id: "#string", name: "#string, value: "#string" } We implement schema validation in our generic scenario as follows. We can easily set the "response" with

How to parse text for a DSL at compile time?

老子叫甜甜 提交于 2019-11-28 03:34:50
Yes. That's right. I want to be able to paste an expression like: "a && b || c" directly into source code as a string: const std::string expression_text("a && b || c"); Create a lazily evaluated structure with it: Expr expr(magical_function(expression_text)); then later on evaluate substituting in known values: evaluate(expr, a, b, c); I'd want to expand this little DSL later so does something a little more complicated using some non-C++ syntax so I can't simply hardcode my expression the simple way. The use case is that I'll be able to copy and paste the same logic from another module used in

In Kotlin, how do I add extension methods to another class, but only visible in a certain context?

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:46:26
In Kotlin, I want to add extension methods to a class, for example to class Entity . But I only want to see these extensions when Entity is within a transaction, otherwise hidden. For example, if I define these classes and extensions: interface Entity {} fun Entity.save() {} fun Entity.delete() {} class Transaction { fun start() {} fun commit() {} fun rollback() {} } I now can accidentally call save() and delete() at any time, but I only want them available after the start() of a transaction and no longer after commit() or rollback() ? Currently I can do this, which is wrong: someEntity.save()

Mini-languages in Python

这一生的挚爱 提交于 2019-11-27 17:15:08
I'm after creating a simple mini-language parser in Python, programming close to the problem domain and all that. Anyway, I was wondering how the people on here would go around doing that - what are the preferred ways of doing this kind of thing in Python? I'm not going to give specific details of what I'm after because at the moment I'm just investigating how easy this whole field is in Python. Thanks for your input! Pyparsing is handy for writing "little languages". I gave a presentation at PyCon'06 on writing a simple adventure game engine, in which the language being parsed and interpreted

Can I define custom operator overloads in Javascript? [duplicate]

丶灬走出姿态 提交于 2019-11-27 13:56:06
This question already has an answer here: Javascript: operator overloading 4 answers Overloading Arithmetic Operators in JavaScript? 11 answers Is it possible to define custom operators between instances of a type in JavaScript? For example, given that I have a custom vector class, is it possible to use vect1 == vect2 to check for equality, whilst the underlying code would be something like this? operator ==(a, b) { return a.x == b.x && a.y == b.y && a.z == b.z; } (This is nonsense of course.) I agree that the equal function on the vector prototype is the best solution. Note that you can also

What is a DSL and where should I use it?

喜你入骨 提交于 2019-11-27 13:54:34
问题 I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen Ayende's blog posts and things, but I've never really gotten exactly why I would take my business logic away from the methods and situations I'm using in my provider. If you've got some background using these things, any chance you could put it in real laymans terms: What exactly building DSLs means? What languages are you using? Where using a DSL

Ruby DSL (Domain Specific Language) repositories, examples

非 Y 不嫁゛ 提交于 2019-11-27 13:02:22
问题 I am seeking excellent examples of Ruby DSLs (Domain Specific Languages). Which repositories, projects do you know of that are worth a read? Why is it (or: are they) great examples? I am particularly interested in more complex examples that are well thought-out and designed. 回答1: Rake and Rack are some good examples of DSL's. If you want some more examples, check these out: Sinatra is a very popular DSL for building web applications, and it's open source on GitHub. Twibot is a newer DSL

When would I want to use a Free Monad + Interpreter pattern?

假如想象 提交于 2019-11-27 09:40:49
问题 I'm working on a project that, amongst other things, involves a database access layer. Pretty normal, really. In a previous project, a collaborator encouraged me to use the Free Monads concept for a database layer and so I did. Now I'm trying to decide in my new project what I gain. In the previous project, I had an API that looked rather like this. saveDocument :: RawDocument -> DBAction () getDocuments :: DocumentFilter -> DBAction [RawDocument] getDocumentStats :: DBAction [(DocId,

Tutorials for writing DSL in Ruby [closed]

空扰寡人 提交于 2019-11-27 05:12:55
问题 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 8 months ago . What are the good online tutorials on how to implement DSLs in Ruby? I am looking for hands-on examples that explain the whole process. I am aware that there is this question on good books about DSLs and Ruby: Good books on Ruby based DSL. 回答1: I think this is a great series of articles on building a dsl in

How to parse text for a DSL at compile time?

Deadly 提交于 2019-11-27 05:08:21
问题 Yes. That's right. I want to be able to paste an expression like: "a && b || c" directly into source code as a string: const std::string expression_text("a && b || c"); Create a lazily evaluated structure with it: Expr expr(magical_function(expression_text)); then later on evaluate substituting in known values: evaluate(expr, a, b, c); I'd want to expand this little DSL later so does something a little more complicated using some non-C++ syntax so I can't simply hardcode my expression the