small medium large xlarge

14 Dec 2011, 16:21
Brooks Boyd (2 posts)

The “” example of writing a parser for a different sort of language structure works if the whole structure is imported as a string and acted upon:

phoneNumbers := doString(s) # Works
phoneNumbers := doString("{ 
    \"Bob Smith\": \"5195551212\",
    \"Mary Walsh\": \"4162223434\"
}") # Works

But I can’t seem to get it to work just as embedded code in the same page:

phoneNumbers := { 
    "Bob Smith": "5195551212",
    "Mary Walsh": "4162223434"

The above fails out with a “Sequence does not respond to ‘:’” exception, like the ‘:’ is not viewed as an Operator after the “Bob Smith” Sequence.

Later, the “” script is able to create a new language structure using the “forward” method override, which allows for adding the generating code right in the same script. Is that possible to be done with the “” method?

11 Feb 2018, 19:24
D.R. (1 post)

Probably way too late, but for people reading the book nowadays and stumbling upon the same problem: has the answer: you have to put the operator-table-change into a separate file. The operator table is only loaded once at the beginning of the file, changing it will only affect further files, never the current file.

You must be logged in to comment