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

From Vigyanwiki
No edit summary
No edit summary
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>





Revision as of 11:56, 4 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 वह फ़ंक्शन जो इन उपयोगिता फ़ंक्शंस में से किसी एक को कॉल करता है (parse इस मामले में) पार्सर चलाने के लिए:

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"'

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

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.


बाहरी संबंध