jjmerelo
jjmerelo

Reputation: 23517

Checking syntax of a string or file

Is there any internal (as in memory-only) equivalent to running raku -c on a file to check the syntax? So far, there are two methods

I am looking for a safe (as in perl6 -c) and fast (as in EVAL) alternative. Any idea?

Upvotes: 7

Views: 153

Answers (1)

codesections
codesections

Reputation: 9600

As noted in the comments above, Raku now supports this by letting you pass the :check named parameter to EVALFILE (to check the syntax of a file) or to EVAL (to check the syntax of a string). In either case, the function will return Nil if the syntax is valid and will throw the relevant exception if it is not.

Upvotes: 3

Related Questions