私は ParserGenApp を実行し、結果のクラスを私のアプリで使用する文法 (以下に含まれていますが、他の例でも同じことを行います) を持っています。次のエラーで失敗します。
Expected : }
Line : 3
Near : start - >
Found : start
ただし、同じアプリで、
PKParser *parser = [[PKParserFactory factory] parserFromGrammar:bnr assembler:self error:&error];
PKAssembly *result = [parser parse:input error:&error];
うまく動作します。
文法は次のとおりです。
start = graph;
graph = strictOrEmpty graphType id '{' stmtList* '}';
strictOrEmpty = 'strict' | Empty;
graphType = 'digraph' | 'graph';
stmtList = stmt (';' stmtList)* ;
stmt = nodeDefinition | edgeDefinition;
id = Word;
nodeDefinition = id '[' nodeAttributes ']';
nodeAttributes = nodeAttribute (',' nodeAttributes)* ;
nodeAttribute = nodeAttributeKey '=' nodeAttributeValue;
nodeAttributeKey = Word;
nodeAttributeValue = Word;
edgeDefinition = id edgeLinkSymbol id;
edgeLinkSymbol = '->';