1

I try to get around Wisent/Semantic and I'm playing with toy languages at this point. Issue I'm stuck with is how to mark multiple variable declarations.

My toy language has only WORD terminal and all terminals should get VARIABLE-TAG. I tried this:

%token WORD
%start words

words : word
      | words word
        (append $1 (list $2))
      ;

word : WORD
        (VARIABLE-TAG $1 nil nil)
     ;

The above seems to mark only first word as variable. How to properly use VARIABLE-TAG so that all words are marked as variables?

2
  • I can't test this, and I'm not familiar with wisent but am somewhat familiar with yacc and bison. I think if you reordered your words definition to be "words word | word" it would continue past the first word. It hits the first word and checks it against "words" where the first match is just one "word" so it stops. If it checked for "words word" first before just "word" it would continue. Commented Feb 12, 2016 at 21:44
  • Wisent can handle left recursion just fine. Other wisent grammars use it in the same way. Commented Feb 12, 2016 at 21:47

1 Answer 1

0

Partial answer to my question is that Wisent loops over start rule until in arrives at the end of the buffer. The following works:

%token WORD
%start word

word : WORD
        (VARIABLE-TAG $1 nil nil)
     ;

To process nested tags two things are needed. One is to notify semantic how to follow nesting:

(define-mode-local-override semantic-tag-components ...)

and then use

(EXPANDTAG (VARIABLE-TAG $1 nil nil))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.