Syntax error when executing NVC modifier train

19 views
Skip to first unread message

Helen

unread,
Aug 21, 2025, 7:52:54 PMAug 21
to forum
I've recently run into a mysterious syntax error (on J9.6.3) when executing phrases of the form N(NVC)N / V(NVC)N / etc:
   0 ([. ] ].) 1 NB. works fine, gives 1
   0 (0 ] ].) 1 NB. syntax error, would expect this to give an identical result

I wanted to use this because I needed a modifier of the form {{N V (u A)}}, and to do this, I wrote (NV([.A)) ], which (I believe) would do the job, were it not for the error.

There are other ways to write such a modifier, such as (AV~N"_) ([.].) '', so it is possible to circumvent the syntax error, but I thought it worth reporting.
(Alternatively, of course, I could also use an explicit modifier!)

Kind regards,
Helen

Henry Rich

unread,
Aug 22, 2025, 11:26:44 AMAug 22
to fo...@jsoftware.com
Thanks for the report.  For some reason I had flagged a syntax error if certain components returned certain parts of speech.  I was probably worried about infinite recursion, but I no longer see how that could happen, so I have removed all those audits.  For the next beta.

It's good to see the modifier trains getting used.  May I ask, What is your application that makes this train useful?

It looks like you want an adverb.  NVC will produce a conjunction; how about (N&V@A) ?

Henry Rich
To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Helen

unread,
Aug 22, 2025, 8:15:47 PMAug 22
to forum, Henry Rich
I wanted to be able to write a modifier that looks like (u1 A1) , (u2 A2) , (u3 A3), whilst also being able to specify each of these verbs individually. My approach was to provide u1 and u3 together, as u1`u3, and then use adverbs to process u1`u3 back into u1 and u3 inside the modifier, e.g.:
   three_argument_modifier=:([. get_u1 A1) , (]. A2) , ([. get_u3 A3) NB. rough pseudocode
I should have mentioned in my first post that the intent is for the modifier train to evaluate to a noun (so that it can then be used in (...)`:6 to produce the correct verb).

My original implementation of "get_u1" was (using (NVC)V to effectively create an ""NVA fork""):
   first_verb=:(0 { ([.`''))`:6 ] NB. accepts either a verb or a gerund, and (interpreting it as a list of verbs) evaluates to the first verb provided
and this is where ran into the syntax error that I then reproduced in my original post.

Some solutions are:
   first_verb=:((]:`'' {~ 0"_) ([.].) '')`:6 NB. using the original solution I mentioned
   first_verb=:(0&{@(]:`'') ([.].) '')`:6 NB. using the solution you provided
   first_verb=:(0&{ ([.].) ]:`'')`:6 NB. an extra solution (N&V ([.].) A) inspired by your solution

The broader context is that I am writing an interpreter in J, and I wanted testing verbs to create sample nouns that might appear as the results of parsing code, and in my case, these nouns all have a similar structure that would benefit from generating all the verbs from a common modifier. I am currently writing the part of the interpreter that executes the code, and wanted to be able to test it separately from the parser.
Having said this, however, I decided to forgo writing verbs specifically to create testing data, and simply use the parsing verbs directly to create the data from a sample code snippets. (I am reasonably convinced the parsing verbs work as intended, due to the way they were written.)

Thanks for the fast response + insight,
Helen

Raul Miller

unread,
Aug 22, 2025, 8:42:34 PMAug 22
to fo...@jsoftware.com, Henry Rich
What are A1, A2 and A3 here? (Are they nouns? If so, are there any
constraints on these nouns?)

Thanks,

--
Raul

Helen

unread,
Aug 22, 2025, 9:16:55 PMAug 22
to forum, Raul Miller, Henry Rich
I hadn't settled on specific values for A1, A2 and A3 before changing tack, but they're all adverbs meant to "post-process" the results of u1,u2,u3 so that they are always compatible to be joined together. I think I would have likely gone for something along the lines of
   A1=:A2=:A3=:boxopen"1@

Kind regards,
Helen
Reply all
Reply to author
Forward
0 new messages