मैं एएनटीएलआर 3.2 को सी ++ में पार्सर/लेक्सर उत्पन्न करने के लिए कड़ी मेहनत कर रहा था। यह फलहीन था। हालांकि जावा & सी के साथ चीजें अच्छी तरह से चली गईं।क्या एएनटीएलआर 3.2 में सी ++ कोड पीढ़ी तैयार है?
मैं इस ट्यूटोरियल उपयोग कर रहा था आरंभ करने के लिए: http://www.ibm.com/developerworks/aix/library/au-c_plusplus_antlr/index.html
जब मैं * .stg फ़ाइलों की जाँच की, मैंने पाया कि:
सीपीपी केवल
./tool/src/main/resources/org/antlr/codegen/templates/CPP/CPP.stg
सी है तो कई फाइलों है :
./tool/src/main/resources/org/antlr/codegen/templates/C/AST.stg
./tool/src/main/resources/org/antlr/codegen/templates/C/ASTDbg.stg
./tool/src/main/resources/org/antlr/codegen/templates/C/ASTParser.stg
./tool/src/main/resources/org/antlr/codegen/templates/C/ASTTreeParser.stg
./tool/src/main/resources/org/antlr/codegen/templates/C/C.stg
./tool/src/main/resources/org/antlr/codegen/templates/C/Dbg.stg
और अन्य भाषाओं।
मेरे C.g फ़ाइल:
grammar C;
options { language='CPP'; }
/** Match things like "call foo;" */
r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;
ID: ('a'..'z'|'A'..'Z'|'_')('0'..'9'|'a'..'z'|'A'..'Z'|'_')* ;
WS: (' ' |'\n' |'\r')+ {$channel=HIDDEN;} ; // ignore whitespace
त्रुटियाँ:
error(10): internal error: group Cpp does not satisfy interface ANTLRCore: missing templates [lexerRuleRefAndListLabel, parameterSetAttributeRef, scopeSetAttributeRef, returnSetAttributeRef, lexerRulePropertyRef_text, lexerRulePropertyRef_type, lexerRulePropertyRef_line, lexerRulePropertyRef_pos, lexerRulePropertyRef_index, lexerRulePropertyRef_channel, lexerRulePropertyRef_start, lexerRulePropertyRef_stop, ruleSetPropertyRef_tree, ruleSetPropertyRef_st]
error(10): internal error: group Cpp does not satisfy interface ANTLRCore: mismatched arguments on these templates [outputFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment, recognizer, name, tokens, tokenNames, rules, cyclicDFAs, bitsets, buildTemplate, buildAST, rewriteMode, profile, backtracking, synpreds, memoize, numRules, fileName, ANTLRVersion, generatedTimestamp, trace, scopes, superClass, literals), optional headerFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment, recognizer, name, tokens, tokenNames, rules, cyclicDFAs, bitsets, buildTemplate, buildAST, rewriteMode, profile, backtracking, synpreds, memoize, numRules, fileName, ANTLRVersion, generatedTimestamp, trace, scopes, superClass, literals), lexer(grammar, name, tokens, scopes, rules, numRules, labelType, filterMode, superClass), rule(ruleName, ruleDescriptor, block, emptyRule, description, exceptions, finally, memoize), alt(elements, altNum, description, autoAST, outerAlt, treeLevel, rew), tokenRef(token, label, elementIndex, hetero), tokenRefAndListLabel(token, label, elementIndex, hetero), listLabel(label, elem), charRangeRef(a, b, label), ruleRef(rule, label, elementIndex, args, scope), ruleRefAndListLabel(rule, label, elementIndex, args, scope), lexerRuleRef(rule, label, args, elementIndex, scope), lexerMatchEOF(label, elementIndex), tree(root, actionsAfterRoot, children, nullableChildList, enclosingTreeLevel, treeLevel)]
error(10): internal error: C.g : java.lang.IllegalArgumentException: Can't find template actionGate.st; group hierarchy is [Cpp]
... और इतने पर।
कृपया कृपया सलाह दें। धन्यवाद! मैं तेंदुए 10.5.8 का उपयोग कर रहा
CLASSPATH=:/Users/vietlq/projects/antlr-3.2.jar:/Users/vietlq/projects/stringtemplate-3.2.1/lib/stringtemplate-3.2.1.jar:/Users/vietlq/projects/stringtemplate-3.2.1/lib/antlr-2.7.7.jar
हाय बेन, क्या आप ओपन सोर्स लाइसेंस के तहत अपना सी ++ टूल जारी करेंगे? धन्यवाद! – Viet