dsl

Boost Spirit Implement small one-line DSL on a server application

做~自己de王妃 提交于 2019-12-01 10:56:26
Apologies if this question has been answered before. I want to insert a small DSL into a server application I work on. The syntax is very simple and even at this early stage I am stumped. I just can't get my head around how to construct the syntax in spirit. Here is an example of the syntax I want to test for: WHERE [not] <condition> [ and | or <condition> ] <command> [parameters] The WHERE clause will select a number of objects from an internal store by testing named properties on them. The vector of selected objects is then passed as input to the command object. There are 2 possible tests I

Boost Spirit Implement small one-line DSL on a server application

╄→尐↘猪︶ㄣ 提交于 2019-12-01 09:27:23
问题 Apologies if this question has been answered before. I want to insert a small DSL into a server application I work on. The syntax is very simple and even at this early stage I am stumped. I just can't get my head around how to construct the syntax in spirit. Here is an example of the syntax I want to test for: WHERE [not] <condition> [ and | or <condition> ] <command> [parameters] The WHERE clause will select a number of objects from an internal store by testing named properties on them. The

Implementing “Generator” support in a custom language

旧时模样 提交于 2019-12-01 08:18:14
I've got a bit of fettish for language design and I'm currently playing around with my own hobby language. ( http://rogeralsing.com/2010/04/14/playing-with-plastic/ ) One thing that really makes my mind bleed is "generators" and the "yield" keyword. I know C# uses AST transformation to transform enumerator methods into statemachines. But how does it work in other languages? Is there any way to get generator support in a language w/o AST transformation? e.g. Does languages like Python or Ruby resort to AST transformations to solve this to? (The question is how generators are implemented under

Best way to load dynamically routes in Apache Camel

眉间皱痕 提交于 2019-12-01 06:15:29
we have developped application based on Karaf and Apache Camel. While our application is entirely based on bundles ( OSGI ) we are also loading the Camel context ( and its' Route Contexts ) on startup, whcih would mean that we have defined some static routes. My question is. Is there a way to dynamically LOAD routes while the application is running without the need to reread the Camel Context as this will reset/restart the already existing routes. The same would apply to already created routes, for example if we want to edit a route whcih already exist. The whole idea is that we are planning

Implementing “Generator” support in a custom language

 ̄綄美尐妖づ 提交于 2019-12-01 05:47:40
问题 I've got a bit of fettish for language design and I'm currently playing around with my own hobby language. (http://rogeralsing.com/2010/04/14/playing-with-plastic/) One thing that really makes my mind bleed is "generators" and the "yield" keyword. I know C# uses AST transformation to transform enumerator methods into statemachines. But how does it work in other languages? Is there any way to get generator support in a language w/o AST transformation? e.g. Does languages like Python or Ruby

Integrating ANTLR 4 in a C++ application

帅比萌擦擦* 提交于 2019-12-01 04:40:16
问题 Recently I picked up a copy of The Definitive ANTLR 4 Reference and since I am sophisticated when it comes to working with grammars and languages I wanted to work on my DSL I once have written using yacc and bison . The general idea is to write a translator (with included validation for type safety (1) ) which translates the DSL to JavaScript during runtime which is then executed by v8. Although ANTLR was designed for inclusion in Java applications I would like to stay with native C++. Can

What are features of ANTLR that XText Does not provide?

Deadly 提交于 2019-12-01 02:20:53
I just came across very nice tool Xtext to create DSL as well as IDE for editing. I did some search on the web and found people saying it does not provide all the features of ANTLR. I am using ANTLR as my parser generator. I am not even sure what features of ANTLR I will need to write complete parser for my language but ANTLR is around for quite a long time and probably supports more features than Xtext. Can anyone please give some examples of what CANNOT be specified in a Xtext grammar? You cannot specify semantic predicates in an Xtext grammar. Furthermore it's not possible to include

Kotlin - Restrict extension method scope

空扰寡人 提交于 2019-11-30 22:31:35
Is there a way to restrict extension methods in DSLs? Say I have a class structure like this: class Outer { fun middle(op: Middle.() -> Unit): Middle { val middle = Middle() middle.op() return middle } } class Middle { fun inner(op: Inner.() -> Unit): Inner { val inner = Inner() inner.op() return inner } } class Inner fun outer(op: Outer.() -> Unit): Outer { val outer = Outer() outer.op() return outer } I can then create a call like so: outer { middle { inner { middle { } // Here is the problem } } } My problem is that the marked middle { } call is confusing, as it adds a Middle to the Outer

What are features of ANTLR that XText Does not provide?

别等时光非礼了梦想. 提交于 2019-11-30 21:57:00
问题 I just came across very nice tool Xtext to create DSL as well as IDE for editing. I did some search on the web and found people saying it does not provide all the features of ANTLR. I am using ANTLR as my parser generator. I am not even sure what features of ANTLR I will need to write complete parser for my language but ANTLR is around for quite a long time and probably supports more features than Xtext. Can anyone please give some examples of what CANNOT be specified in a Xtext grammar? 回答1:

Why can an instance of a class access private fields of another instance of its own type?

家住魔仙堡 提交于 2019-11-30 17:18:33
An instance of a class, in Java, can access private fields of a different instance of its own type, such as in the following listing: public class Foo { private int secret; public void bar(final Foo foo) { foo.secret = 100; } } What would be the argument for such semantics (when designing a language)? Well, first you have to ask "why have private fields at all?" Private fields are primarily for encapsulation: a user of a a class shouldn't have to know the internals of that class' implementation. In fact, they shouldn't know, because if they relied on those specifics, then the implementer would