स्पिरिट पार्सर फ्रेमवर्क: Difference between revisions

From Vigyanwiki
No edit summary
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 55: Line 55:
| x के अतिरिक्त किसी भी चीज़ को मैच करें (केवल करैक्टर क्लासेज जैसे ch_p या alnum_p के साथ)
| x के अतिरिक्त किसी भी चीज़ को मैच करें (केवल करैक्टर क्लासेज जैसे ch_p या alnum_p के साथ)
|}
|}


== उदाहरण ==
== उदाहरण ==
Line 101: Line 100:
</syntaxhighlight>
</syntaxhighlight>


 
== बाहरी संबंध ==
==बाहरी संबंध==
*[https://github.com/boostorg/spirit/ Spirit parser framework github page]
*[https://github.com/boostorg/spirit/ Spirit parser framework github page]
*[https://boost-spirit.com/home/ Spirit parser framework]
*[https://boost-spirit.com/home/ Spirit parser framework]
*[http://www.boost.org/libs/spirit/index.html Documentation in the Boost project]
*[http://www.boost.org/libs/spirit/index.html Documentation in the Boost project]
*[http://www.ddj.com/article/printableArticle.jhtml?articleID=184401692&dept_url=/cpp/ Article on Spirit by designer Joel de Guzman in Dr. Dobb's Journal]
*[http://www.ddj.com/article/printableArticle.jhtml?articleID=184401692&dept_url=/cpp/ Article on Spirit by designer Joel de Guzman in Dr. Dobb's Journal]
[[Category: पार्सर जेनरेटर]]




{{programming-software-stub}}
{{programming-software-stub}}


 
[[Category:All stub articles]]
 
[[Category:Computer programming tool stubs]]
[[Category: Machine Translated Page]]
[[Category:Created On 26/07/2023]]
[[Category:Created On 26/07/2023]]
[[Category:Machine Translated Page]]
[[Category:पार्सर जेनरेटर]]

Latest revision as of 14:04, 14 August 2023

स्पिरिट पार्सर फ्रेमवर्क ऑब्जेक्ट ओरिएंटेड रिकर्सिव डिसेंट पार्सर जनरेटर फ्रेमवर्क है जिसे टेम्पलेट मेटाप्रोग्रामिंग तकनीकों का उपयोग करके कार्यान्वित किया जाता है। एक्सप्रेशन टेम्पलेट्स उपयोगकर्ताओं को विस्तारित बैकस-नौर फॉर्म (ईबीएनएफ) के सिंटैक्स को पूर्ण रूप से सी++ में अनुमानित करने की अनुमति देते हैं। पार्सर ऑब्जेक्ट ऑपरेटर ओवरलोडिंग के माध्यम से बनाए जाते हैं और परिणाम बैकट्रैकिंग एलएल (∞) पार्सर होता है जो अस्पष्ट व्याकरण को पार्स करने में सक्षम होता है।

स्पिरिट का उपयोग लेक्सिंग और पार्सिंग दोनों के लिए एक साथ या भिन्न-भिन्न किया जा सकता है।

यह फ्रेमवर्क बूस्ट सी++ लाइब्रेरीज़ का भाग है।

ऑपरेटर

सी++ लैंग्वेज की सीमाओं के कारण, स्पिरिट का सिंटैक्स सी++ की ऑपरेटर प्राथमिकताओं के निकट डिज़ाइन किया गया है, जबकि विस्तारित बैकस-नौर फॉर्म और रेगुलर एक्सप्रेशन दोनों के समान है।

सिंटेक्स व्याख्या
x >> y x के पश्चात y को मैच करें।
x > y x को मैच करने के पश्चात, y की अपेक्षा करें।
*x मैच x को शून्य या अधिक बार दोहराया गया। यह क्लेन स्टार का प्रतिनिधित्व करता है; सी++ यूनरी पोस्टफ़िक्स ऑपरेटर का अभाव है।
x | y x को मैच करें। यदि x मैच नहीं करता है, तो y से मिलान करने का प्रयास करें।
+x x की एक या अधिक घटनाओं की श्रृंखला को मैच करें।
-x x शून्य या एक बार मैच करें।
x & y x और y को मैच करें।
x - y x को मैच करें परंतु y का नहीं।
x ^ y किसी भी क्रम में x, या y, या दोनों को मैच करें।
x || y x, या y, या x के पश्चात y को मैच करें।
x [ function_expression ] यदि x मैच करें, तो function_expression द्वारा रिटर्न किये गए फ़ंक्शन/फ़ंक्टर को निष्पादित करें।
( x ) मैचिंग x (प्राथमिकता समूहीकरण के लिए उपयोग किया जा सकता है)
x % y x की एक या अधिक घटनाओं को y की घटनाओं से भिन्न करके मैच करें।
~x x के अतिरिक्त किसी भी चीज़ को मैच करें (केवल करैक्टर क्लासेज जैसे ch_p या alnum_p के साथ)

उदाहरण

यह उदाहरण दिखाता है कि सिमेंटिक क्रिया के साथ इनलाइन पार्सर एक्सप्रेशन का उपयोग कैसे करें।

#include <string>
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
 
int main()
{
  namespace qi = boost::spirit::qi;

  std::string input;
 
  std::cout << "Input a line: \n";
  getline(std::cin, input);
  std::cout << "Got '" << input << "'.\n";
 
  unsigned count = 0;
  /*  
      Next, parse the input (input.c_str()),
      using a parser constructed with the following semantics:
 
      Zero or more occurrences of (
          literal string "cat" (when matched, increment the counter "count")
      or  any character (which will be skipped)
      )

     The parser is constructed by the compiler using operator overloading and
     template matching, so the actual work is done within qi::parse(), and the
     expression starting with * only initializes the rule object that the parse
     function uses.

  */
  auto rule = *(qi::lit("cat") [ ++qi::_val ] | qi::omit[qi::char_]);
  qi::parse(input.begin(), input.end(), rule, count);
  

  // Finally, show results.
  std::cout << "The input contained " << count << " occurrences of 'cat'\n";
}

बाहरी संबंध