Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好吧,这就是我所做的:
[a] returns A [b] returns B
%toke A B %% s: B | a B; a: A | a A;
现在我如何只接受那些字符串 where n>=10?
n>=10
我想到了:
s : B | A A A A A A A A A a B
还有其他想法吗?
您可以为此使用 YYFAIL 或 YYERROR:
%{ #include <stdio.h> int aCount=0; %} %token A %token B %% s : aList B { if (aCount<10) { YYFAIL; } } anA: A {aCount++}; aList: anA | aList anA; %%