पारसेक (पार्सर): Difference between revisions

From Vigyanwiki
(Created page with "{{Infobox software | name = Parsec | logo = <!-- Image name is enough. --> | logo alt = | logo caption = | screenshot = <!-- Image name is enough. --> | screenshot size = |...")
 
No edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 33: Line 33:
}}
}}


पारसेक [[हास्केल (प्रोग्रामिंग भाषा)]] में [[पार्सर]] लिखने के लिए एक [[लाइब्रेरी (कंप्यूटिंग)]] है।<ref>{{cite web|title=हास्केल विकी पर पारसेक|url=https://wiki.haskell.org/Parsec|website=Haskell Wiki|accessdate=29 May 2017}}</ref> यह उच्च-क्रम [[ पार्सर संयोजक ]] पर आधारित है, इसलिए एक जटिल पार्सर कई छोटे पार्सर से बनाया जा सकता है।<ref>{{cite web|url=http://research.microsoft.com/pubs/65201/parsec-paper-letter.pdf|website=Microsoft Research|title=Parsec: Direct Style Monadic Parser Combinators For The Real World|date=July 2001|accessdate=22 November 2014|ref=parsec-paper|last1=Leijen|first1=Daan|last2=Meijer|first2=Erik}}</ref> सहित कई अन्य भाषाओं में इसे दोबारा लागू किया गया है
'''पारसेक''', [[हास्केल (प्रोग्रामिंग भाषा)|हास्केल प्रोग्रामिंग भाषा]] में [[पार्सर]] लिखने के लिए एक [[लाइब्रेरी (कंप्यूटिंग)|लाइब्रेरी]] है।<ref>{{cite web|title=हास्केल विकी पर पारसेक|url=https://wiki.haskell.org/Parsec|website=Haskell Wiki|accessdate=29 May 2017}}</ref> यह उच्च-क्रम [[ पार्सर संयोजक |पार्सर कॉम्बिनेटर]] पर आधारित है, इसलिए एक कॉम्प्लेक्स पार्सर कई छोटे पार्सरों से निर्मित किया जा सकता है।<ref>{{cite web|url=http://research.microsoft.com/pubs/65201/parsec-paper-letter.pdf|website=Microsoft Research|title=Parsec: Direct Style Monadic Parser Combinators For The Real World|date=July 2001|accessdate=22 November 2014|ref=parsec-paper|last1=Leijen|first1=Daan|last2=Meijer|first2=Erik}}</ref>  
[[एरलांग (प्रोग्रामिंग भाषा)]],<ref>{{cite web|title=पारसेक एर्लांग|url=https://bitbucket.org/dmercer/parsec-erlang/|website=BitBucket|accessdate=23 November 2014|ref=parsec-erlang}}</ref>
 
[[अमृत ​​(प्रोग्रामिंग भाषा)]],<ref>{{cite web|title=फुर्तीला पारसेक|url=https://github.com/plataformatec/nimble_parsec/|website=Github|accessdate=18 December 2018|ref=parsec-elixir}}</ref>
पारसेक को कई अन्य प्रोग्रामिंग लैंग्वेज, जैसे [[एरलांग (प्रोग्रामिंग भाषा)|एरलांग]],<ref>{{cite web|title=पारसेक एर्लांग|url=https://bitbucket.org/dmercer/parsec-erlang/|website=BitBucket|accessdate=23 November 2014|ref=parsec-erlang}}</ref>[[अमृत ​​(प्रोग्रामिंग भाषा)|अलिक्सर]],<ref>{{cite web|title=फुर्तीला पारसेक|url=https://github.com/plataformatec/nimble_parsec/|website=Github|accessdate=18 December 2018|ref=parsec-elixir}}</ref>[[ओकैमल]],<ref>{{cite web|title=पारसेक ओकैमल|url=http://lprousnth.files.wordpress.com/2007/08/pcl.pdf|website=The OCaml Summer Project|accessdate=23 November 2014|ref=parsec-ocaml}}</ref> और एफ शार्प (एफ#),<ref>{{cite web|title=कॉर्सिस द्वारा एक्सपारसेक|url=http://xparsec.corsis.tech/|website=XParsec|accessdate=29 May 2017|ref=xparsec}}</ref><ref>{{cite web|title=एफपारसेक|url=http://www.quanttec.com/fparsec/|website=Quanttec|accessdate=29 May 2017|ref=fparsec}}</ref>सी शार्प (सी#),<ref>{{cite web|title=सीशार्प मोनाड|url=https://github.com/louthy/csharp-monad|website=Github|accessdate=10 December 2014|ref=parsec-csharp}}</ref> और [[जावा (प्रोग्रामिंग भाषा)|जावा]] में कार्यान्वित किया गया है।<ref>{{cite web|title=जेपारसेक|url=https://github.com/jparsec/jparsec|website=Github|accessdate=14 October 2016|ref=jparsec}}</ref>
[[ओकैमल]],<ref>{{cite web|title=पारसेक ओकैमल|url=http://lprousnth.files.wordpress.com/2007/08/pcl.pdf|website=The OCaml Summer Project|accessdate=23 November 2014|ref=parsec-ocaml}}</ref> और
 
एफ शार्प (प्रोग्रामिंग भाषा)|एफ#,<ref>{{cite web|title=कॉर्सिस द्वारा एक्सपारसेक|url=http://xparsec.corsis.tech/|website=XParsec|accessdate=29 May 2017|ref=xparsec}}</ref><ref>{{cite web|title=एफपारसेक|url=http://www.quanttec.com/fparsec/|website=Quanttec|accessdate=29 May 2017|ref=fparsec}}</ref>
चूंकि पार्सर कॉम्बिनेटर-आधारित प्रोग्राम सामान्यतः [[पार्सर जनरेटर]] प्रोग्राम की तुलना में धीमा होता है,<ref>{{Cite web |title=What is the difference between parser generators and parser combinators? |url=https://www.quora.com/What-is-the-difference-between-parser-generators-and-parser-combinators |access-date=2022-10-19 |website=Quora |language=en}}</ref> पारसेक का उपयोग सामान्यतः छोटी [[डोमेन-विशिष्ट भाषा|डोमेन-स्पेसिफिक लैंग्वेज]] के लिए किया जाता है, जबकि हैप्पी का उपयोग [[ग्लासगो हास्केल कंपाइलर]] जैसे कंपाइलरों के लिए किया जाता है।<ref>{{cite web|title=The Glasgow Haskell Compiler (AOSA Vol. 2)|website=The Architecture of Open Source Applications|url=http://www.aosabook.org/en/ghc.html|accessdate=23 November 2014|ref=aosa-ghc}}</ref>
साथ ही [[अनिवार्य भाषा]]एँ जैसे
 
सी शार्प (प्रोग्रामिंग भाषा)|सी#,<ref>{{cite web|title=सीशार्प मोनाड|url=https://github.com/louthy/csharp-monad|website=Github|accessdate=10 December 2014|ref=parsec-csharp}}</ref> और
पारसेक से प्राप्त अन्य हास्केल पार्सर कॉम्बिनेटर लाइब्रेरी में, मेगापारसेक और एटोपार्सेक सम्मिलित है<ref>{{Cite web|url=https://hackage.haskell.org/package/megaparsec-6.5.0|title=megaparsec: Monadic parser combinators|website=Hackage|access-date=2018-09-10}}</ref><ref>{{Cite web|url=https://hackage.haskell.org/package/attoparsec|title=attoparsec: Fast combinator parsing for bytestrings and text|website=Hackage|access-date=2018-09-10}}</ref>
[[जावा (प्रोग्रामिंग भाषा)]]<ref>{{cite web|title=जेपारसेक|url=https://github.com/jparsec/jparsec|website=Github|accessdate=14 October 2016|ref=jparsec}}</ref>
 
क्योंकि पार्सर कॉम्बिनेटर-आधारित प्रोग्राम आम तौर पर [[पार्सर जनरेटर]] प्रोग्राम की तुलना में धीमा होता है,<ref>{{Cite web |title=What is the difference between parser generators and parser combinators? |url=https://www.quora.com/What-is-the-difference-between-parser-generators-and-parser-combinators |access-date=2022-10-19 |website=Quora |language=en}}</ref> पारसेक का उपयोग आम तौर पर छोटी [[डोमेन-विशिष्ट भाषा]]ओं के लिए किया जाता है, जबकि हैप्पी (सॉफ़्टवेयर) का उपयोग [[ग्लासगो हास्केल कंपाइलर]] जैसे कंपाइलरों के लिए किया जाता है।<ref>{{cite web|title=The Glasgow Haskell Compiler (AOSA Vol. 2)|website=The Architecture of Open Source Applications|url=http://www.aosabook.org/en/ghc.html|accessdate=23 November 2014|ref=aosa-ghc}}</ref>
पारसेक बीएसडी-3-क्लॉज लाइसेंस के अंतर्गत जारी किया गया [[मुफ्त सॉफ्टवेयर|ओपन सॉफ्टवेयर]] है।<ref>{{Cite web|url=https://github.com/haskell/parsec/blob/master/LICENSE|title = पारसेक|date = 25 October 2021}}</ref>
पारसेक से प्राप्त अन्य हास्केल पार्सर कॉम्बिनेटर लाइब्रेरी में मेगापारसेक शामिल है<ref>{{Cite web|url=https://hackage.haskell.org/package/megaparsec-6.5.0|title=megaparsec: Monadic parser combinators|website=Hackage|access-date=2018-09-10}}</ref> और एटोपार्सेक।<ref>{{Cite web|url=https://hackage.haskell.org/package/attoparsec|title=attoparsec: Fast combinator parsing for bytestrings and text|website=Hackage|access-date=2018-09-10}}</ref>
पारसेक बीएसडी-3-क्लॉज लाइसेंस के तहत जारी किया गया [[मुफ्त सॉफ्टवेयर]] है।<ref>{{Cite web|url=https://github.com/haskell/parsec/blob/master/LICENSE|title = पारसेक|date = 25 October 2021}}</ref>




== उदाहरण ==
== उदाहरण ==
पारसेक में लिखे गए पार्सर सरल पार्सर से शुरू होते हैं, जैसे कि वे जो कुछ स्ट्रिंग्स को पहचानते हैं, और उन्हें अधिक जटिल व्यवहार के साथ एक पार्सर बनाने के लिए जोड़ते हैं। उदाहरण के लिए, <code>digit</code> एक अंक को पार्स करता है, और <code>string</code> एक विशिष्ट स्ट्रिंग को पार्स करता है (जैसे <code>"hello"</code>).
पारसेक में लिखे गए पार्सर सरल पार्सर से प्रारंभ होते हैं, जैसे कि वे जो कुछ स्ट्रिंग्स को पहचानते हैं, और उन्हें अधिक कॉम्प्लेक्स व्यवहार के साथ एक पार्सर निर्मित करने = के लिए युग्मित करते हैं। उदाहरण के लिए, <code>digit</code> एक अंक को पार्स करता है, और <code>string</code> एक विशिष्ट स्ट्रिंग(जैसे <code>"hello"</code>) को पार्स करता है।


पार्सेक जैसे पार्सर कॉम्बिनेटर लाइब्रेरी पार्सर्स को वास्तविक मूल्यों पर चलाने के लिए उपयोगिता कार्य प्रदान करते हैं। एक स्ट्रिंग से एकल अंक को पहचानने के लिए एक पार्सर को दो कार्यों में विभाजित किया जा सकता है: एक पार्सर बनाने के लिए, और एक <code>main</code> वह फ़ंक्शन जो इन उपयोगिता फ़ंक्शंस में से किसी एक को कॉल करता है (<code>parse</code> इस मामले में) पार्सर चलाने के लिए:<syntaxhighlight lang="haskell">
पार्सेक जैसे पार्सर कॉम्बिनेटर लाइब्रेरी पार्सर्स को वास्तविक मानो पर चलाने के लिए यूटिलिटी फंक्शन प्रदान करते हैं। एक स्ट्रिंग से एकल अंक को पहचानने के लिए एक पार्सर को दो फंक्शन में विभाजित किया जा सकता है: एक पार्सर बनाने के लिए, और एक <code>main</code> फंक्शन जो इन यूटिलिटी फ़ंक्शनों में से एक को कॉल करता है।<syntaxhighlight lang="haskell">
import Text.Parsec      -- has general parsing utility functions
import Text.Parsec      -- has general parsing utility functions
import Text.Parsec.Char -- contains specific basic combinators
import Text.Parsec.Char -- contains specific basic combinators
Line 61: Line 59:
-- prints 'Right "hello"'
-- prints 'Right "hello"'


</syntaxhighlight>हम परिभाषित करते हैं ए <code>Parser</code> प्रकार का हस्ताक्षर बनाने के लिए टाइप करें <code>parser</code> पढ़ने में आसान. यदि हम इस प्रोग्राम को बदलना चाहते हैं, तो किसी एक स्ट्रिंग को पढ़ने के लिए कहें <code>"hello"</code> या स्ट्रिंग <code>"goodbye"</code>, हम ऑपरेटर का उपयोग कर सकते हैं <code><|></code>, द्वारा प्रदान किया गया <code>Alternative</code> टाइपक्लास, दो पार्सर्स को एक एकल पार्सर में संयोजित करने के लिए जो या तो कोशिश करता है:<syntaxhighlight lang="haskell">
पार्सिग को सरल बनाने के लिए एक <code>Parser</code> प्रकार को परिभाषित करते हैं। यदि हम इस प्रोग्राम को परिवर्तित करना चाहते हैं तो मान लें कि स्ट्रिंग <code>"hello"</code> या स्ट्रिंग <code>"goodbye"</code> को पार्स करना है, तो हम ऑपरेटर <code><|></code> का उपयोग कर सकते हैं। <code>Alternative</code> टाइपक्लास द्वारा प्रदान किए गए, दो पार्सर को एक एकल पार्सर में संयोजित करने का प्रयास करता है:<syntaxhighlight lang="haskell">
parser = string "hello" <|> string "goodbye"
parser = string "hello" <|> string "goodbye"
</syntaxhighlight>
</syntaxhighlight>




Line 73: Line 79:
*[https://www.haskell.org/haskellwiki/Parsec Parsec on the Haskell wiki]
*[https://www.haskell.org/haskellwiki/Parsec Parsec on the Haskell wiki]
*[http://hackage.haskell.org/package/parsec Parsec on Hackage]
*[http://hackage.haskell.org/package/parsec Parsec on Hackage]
[[Category: निःशुल्क सॉफ्टवेयर हास्केल में प्रोग्राम किया गया]] [[Category: पार्सर जेनरेटर]]
 


{{free-software-stub}}
{{free-software-stub}}


 
[[Category:All stub articles]]
 
[[Category:CS1 English-language sources (en)]]
[[Category: Machine Translated Page]]
[[Category:Created On 26/07/2023]]
[[Category:Created On 26/07/2023]]
[[Category:Free software stubs]]
[[Category:Machine Translated Page]]
[[Category:Pages with script errors]]
[[Category:Templates Vigyan Ready]]
[[Category:निःशुल्क सॉफ्टवेयर हास्केल में प्रोग्राम किया गया]]
[[Category:पार्सर जेनरेटर]]

Latest revision as of 11:29, 14 August 2023

Parsec
Original author(s)Daan Leijen, Paolo Martini, Antoine Latter
Developer(s)Herbert Valerio Riedel, Derek Elkins, Antoine Latter, Roman Cheplyaka, Ryan Scott
Initial releaseNovember 2, 2006; 17 years ago (2006-11-02)[1]
Stable release
3.1.14.0 / August 10, 2019; 5 years ago (2019-08-10)[2]
Repositorygithub.com/haskell/parsec
Written inHaskell
Operating systemLinux, macOS, Windows
PlatformHaskell Platform
TypeParser combinator, Library
LicenseBSD-3
Websitehackage.haskell.org/package/parsec

पारसेक, हास्केल प्रोग्रामिंग भाषा में पार्सर लिखने के लिए एक लाइब्रेरी है।[3] यह उच्च-क्रम पार्सर कॉम्बिनेटर पर आधारित है, इसलिए एक कॉम्प्लेक्स पार्सर कई छोटे पार्सरों से निर्मित किया जा सकता है।[4]

पारसेक को कई अन्य प्रोग्रामिंग लैंग्वेज, जैसे एरलांग,[5]अलिक्सर,[6]ओकैमल,[7] और एफ शार्प (एफ#),[8][9]सी शार्प (सी#),[10] और जावा में कार्यान्वित किया गया है।[11]

चूंकि पार्सर कॉम्बिनेटर-आधारित प्रोग्राम सामान्यतः पार्सर जनरेटर प्रोग्राम की तुलना में धीमा होता है,[12] पारसेक का उपयोग सामान्यतः छोटी डोमेन-स्पेसिफिक लैंग्वेज के लिए किया जाता है, जबकि हैप्पी का उपयोग ग्लासगो हास्केल कंपाइलर जैसे कंपाइलरों के लिए किया जाता है।[13]

पारसेक से प्राप्त अन्य हास्केल पार्सर कॉम्बिनेटर लाइब्रेरी में, मेगापारसेक और एटोपार्सेक सम्मिलित है[14][15]

पारसेक बीएसडी-3-क्लॉज लाइसेंस के अंतर्गत जारी किया गया ओपन सॉफ्टवेयर है।[16]


उदाहरण

पारसेक में लिखे गए पार्सर सरल पार्सर से प्रारंभ होते हैं, जैसे कि वे जो कुछ स्ट्रिंग्स को पहचानते हैं, और उन्हें अधिक कॉम्प्लेक्स व्यवहार के साथ एक पार्सर निर्मित करने = के लिए युग्मित करते हैं। उदाहरण के लिए, digit एक अंक को पार्स करता है, और string एक विशिष्ट स्ट्रिंग(जैसे "hello") को पार्स करता है।

पार्सेक जैसे पार्सर कॉम्बिनेटर लाइब्रेरी पार्सर्स को वास्तविक मानो पर चलाने के लिए यूटिलिटी फंक्शन प्रदान करते हैं। एक स्ट्रिंग से एकल अंक को पहचानने के लिए एक पार्सर को दो फंक्शन में विभाजित किया जा सकता है: एक पार्सर बनाने के लिए, और एक main फंक्शन जो इन यूटिलिटी फ़ंक्शनों में से एक को कॉल करता है।

import Text.Parsec      -- has general parsing utility functions
import Text.Parsec.Char -- contains specific basic combinators
type Parser = Stream s m Char => ParsecT s u m String

parser :: Parser
parser = string "hello"

main :: IO ()
main = print (parse parser "<test>" "hello world")
-- prints 'Right "hello"'

पार्सिग को सरल बनाने के लिए एक <code>Parser</code> प्रकार को परिभाषित करते हैं। यदि हम इस प्रोग्राम को परिवर्तित करना चाहते हैं तो मान लें कि स्ट्रिंग <code>"hello"</code> या स्ट्रिंग <code>"goodbye"</code> को पार्स करना है, तो हम ऑपरेटर <code><|></code> का उपयोग कर सकते हैं। <code>Alternative</code> टाइपक्लास द्वारा प्रदान किए गए, दो पार्सर को एक एकल पार्सर में संयोजित करने का प्रयास करता है:<syntaxhighlight lang="haskell">
parser = string "hello" <|> string "goodbye"






संदर्भ

  1. "parsec 2.0". Hackage. Retrieved 3 September 2019.
  2. "Releases". Github. Retrieved 3 September 2019.
  3. "हास्केल विकी पर पारसेक". Haskell Wiki. Retrieved 29 May 2017.
  4. Leijen, Daan; Meijer, Erik (July 2001). "Parsec: Direct Style Monadic Parser Combinators For The Real World" (PDF). Microsoft Research. Retrieved 22 November 2014.
  5. "पारसेक एर्लांग". BitBucket. Retrieved 23 November 2014.
  6. "फुर्तीला पारसेक". Github. Retrieved 18 December 2018.
  7. "पारसेक ओकैमल" (PDF). The OCaml Summer Project. Retrieved 23 November 2014.
  8. "कॉर्सिस द्वारा एक्सपारसेक". XParsec. Retrieved 29 May 2017.
  9. "एफपारसेक". Quanttec. Retrieved 29 May 2017.
  10. "सीशार्प मोनाड". Github. Retrieved 10 December 2014.
  11. "जेपारसेक". Github. Retrieved 14 October 2016.
  12. "What is the difference between parser generators and parser combinators?". Quora (in English). Retrieved 2022-10-19.
  13. "The Glasgow Haskell Compiler (AOSA Vol. 2)". The Architecture of Open Source Applications. Retrieved 23 November 2014.
  14. "megaparsec: Monadic parser combinators". Hackage. Retrieved 2018-09-10.
  15. "attoparsec: Fast combinator parsing for bytestrings and text". Hackage. Retrieved 2018-09-10.
  16. "पारसेक". 25 October 2021.


बाहरी संबंध