error keyword as in yacc

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by David Chang - Software Engineer, a.i. solutions, Inc.
Version: 4.0.0280
Avatar
Hi,

I have a grammar which has the following form:

'command' ('option1'|'option2'|'option3') 'commandtail1' 'commandtail2'

I am trying to use ReportSyntaxError() so I can display syntax error with the error wavy line.

What I can do without any problem is the following:

1: 'command'
2: ('option1'|'option2'|'option3')
3: 'commandtail1<- this.ReportSyntaxError("'commandtail1' expected."); return false; ->'
4: 'commandtail2<- this.ReportSyntaxError("'commandtail2' expected."); return false; ->'

but I don't know how to work on the alternations in line 2.

I know that in yacc you can have a fourth alternation of error and call ReportSyntaxError () in there as follows:

2: ('option1'|'option2'|'option3'|'ErrorToken<+ this.ReportSyntaxError("'option1', 'option2', or 'option3' expected."); return false; +>')

Is the same feature available in your grammar generator or there is another way to handle the same thing?

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David, a trick you could do is an always-true condition like:
| <? true ?><% your code here %>


Actipro Software Support

Posted 10 years ago by David Chang - Software Engineer, a.i. solutions, Inc.
Avatar
Hi,

This is good trick!

I'll try it right now.
The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.