Hi,

I have a basic code - which should copy source folder to destination folder

module generate

imports
libstratego-lib
libstratego-gpp
libstratego-aterm
include/SampleApp
lib/editor-common.generated
lib/compilation-library.generated


rules // Transformation
 
copy-app-folder(|path):
 ast -> None()
   with
     currentPath := <dirname> path;
     srcFldr := $[[currentPath]/src];
     destFldr := $[[currentPath]/dest];
     try (<mkdir> destFldr);
     try (<fdcopy> (srcFldr, destFldr))

But this gives me following error:

org.spoofax.interpreter.core.InterpreterException: Exception during evaluation
 at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:120)
at org.spoofax.interpreter.core.Interpreter.invoke(Interpreter.java:82)
at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:424)
at org.strategoxt.imp.debug.core.str.launching.DebuggableHybridInterpreter.invoke(DebuggableHybridInterpreter.java:150)
at org.strategoxt.imp.runtime.Environment$2.invoke(Environment.java:193)
at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:701)
at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:670)
at org.strategoxt.imp.runtime.services.StrategoBuilder.invokeObserver(StrategoBuilder.java:327)
at org.strategoxt.imp.runtime.services.StrategoBuilder.execute(StrategoBuilder.java:193)
at org.strategoxt.imp.runtime.services.StrategoBuilder.access$1(StrategoBuilder.java:177)
at org.strategoxt.imp.runtime.services.StrategoBuilder$1.run(StrategoBuilder.java:164)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: org.strategoxt.lang.StrategoException: Primitive not defined: SSL_fdcopy
at org.strategoxt.lang.Context.invokePrimitive(Context.java:214)
at org.strategoxt.stratego_lib.fdcopy_0_0.invoke(fdcopy_0_0.java)
at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:30)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:192)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:183)
at org.strategoxt.lang.InteropSDefT$StrategyBody.evaluate(InteropSDefT.java:245)
at org.strategoxt.lang.InteropSDefT$StrategyBody.eval(InteropSDefT.java:238)
at org.spoofax.interpreter.stratego.Strategy.evaluate(Strategy.java:76)
at org.spoofax.interpreter.stratego.SDefT.evaluate(SDefT.java:213)
at org.strategoxt.lang.InteropStrategy.invokeDynamic(InteropStrategy.java:57)
at org.strategoxt.lang.DynamicStrategy.invoke(DynamicStrategy.java:22)
at org.strategoxt.stratego_lib.try_1_0.invoke(try_1_0.java)
at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:40)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:192)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:183)
at org.strategoxt.lang.InteropSDefT$StrategyBody.evaluate(InteropSDefT.java:245)
at org.strategoxt.lang.InteropSDefT$StrategyBody.eval(InteropSDefT.java:238)
at org.spoofax.interpreter.stratego.Strategy.evaluate(Strategy.java:76)
at org.spoofax.interpreter.core.Interpreter.evaluate(Interpreter.java:109)

Any suggestion why ?

Submitted by Ajit on 23 June 2014 at 12:30

On 23 June 2014 at 12:47 Guido Wachsmuth commented:

According to the error message, the primitive strategy SSL_fdcopy is not defined.


On 23 June 2014 at 13:00 Vlad Vergu commented:

I suspect that copying of file descriptor is not supported in the Java backend. Perhaps copy-file is an alternative here. I don’t think it supports copying of directories though.


On 23 June 2014 at 13:01 Ajit commented:

Thanks for reply !

What do you mean SSL_fdcopy not defined?

Do we need to define it? If ? Where and why? I mean its a function from library, and that library is added to project.

Please explain this a bit more? I am very new to Spoofax and Stratego.

Also I am not getting anything about this in any documentation. So please suggest me a good documentation where things like this are defined.


On 23 June 2014 at 13:07 Ajit commented:

@Vlad: Thanks

Ya copy-file will not work here, I need to copy whole directory.


On 23 June 2014 at 13:13 Vlad Vergu commented:

Yes, i thought so. I have two options:

  1. Implement a native Strategy in Java that does this. Not so friendly, because Java won’t do cp -r simply either.
  2. Use a combination of isdir, readdir, mkdir and copy-file.

I would go with option 2.


On 23 June 2014 at 13:20 Ajit commented:

@Vlad - Hmm! I am thinking the same. I will prefer option 2 :) Thanks!

By the way just a random question - Is there any concept of Global Variables in Stratego?


On 23 June 2014 at 13:52 Vlad Vergu commented:

Glad to help. Please post back here if issue is (not) resolved.

No, there are no global variables as such in Stratego. I guess you could use unscoped dynamic rules to this end if you really really need global variables. But be aware of the implications of mutable variables in Stratego: backtracking on strategy failures (normal behavior in Stratego) cannot and will not undo side-effects. In our experience there’s usually a more elegant solution to global state. Perhaps it’s worth opening a question (https://yellowgrass.org/questions/Spoofax) to discuss why you need global variables?


On 23 June 2014 at 14:19 Ajit commented:

@Vlad - Sure I will post my solution here whens done ! Thanks for above explanation, its helpful. Basically I am a Java developer so my expectations are according to it and I am still not sure how stratego language constructs, elements how they work and overall what stratego language offers to developer. So Lets see !


On 4 November 2014 at 15:40 Gabriël Konat closed this issue.

Log in to post comments