Go Yacc parse results currently best be passed back through the lexer, as mentioned by Russ Cox. Although this isn't a nice practice – in terms of decoupling and accompanying separation of concerns – it offers a midway until Go Yacc allows for 'proper' parser outcome communication.
Nex appears to recognize this situation by offering a 'hook' in the generated source code. However, this also introduces a separate search and replace step, most likely done in a Makefile build step or otherwise. Although workable, I think Go offers one step better by means of the interface{} 'type'. Which is what I'm proposing through this pull request.
As an example, code like below could be added to bottom of the .nex file:
Mind you, the ast.Node type is being returned, which could be replaced with anything to your liking. One could also wholly place the 'burden' of type assertion back to the caller by changing that to be interface{}. Which adds to my point.
Well, lot of words for a small change – :smiley: Hope I've got my point of view across.
Go Yacc parse results currently best be passed back through the lexer, as mentioned by Russ Cox. Although this isn't a nice practice – in terms of decoupling and accompanying separation of concerns – it offers a midway until Go Yacc allows for 'proper' parser outcome communication.
Nex appears to recognize this situation by offering a 'hook' in the generated source code. However, this also introduces a separate search and replace step, most likely done in a Makefile build step or otherwise. Although workable, I think Go offers one step better by means of the
interface{}
'type'. Which is what I'm proposing through this pull request.As an example, code like below could be added to bottom of the
.nex
file:Mind you, the
ast.Node
type is being returned, which could be replaced with anything to your liking. One could also wholly place the 'burden' of type assertion back to the caller by changing that to beinterface{}
. Which adds to my point.Well, lot of words for a small change – :smiley: Hope I've got my point of view across.