Count number of tokens in compiler design | Lexical Analyzer
Summary
TLDRThe video script discusses the tokenization process of a lexical analyzer program, explaining how it converts a given program into tokens. It emphasizes the importance of using a deterministic finite automaton for tokenization and the concept of longest matching. The script explores various examples, including identifiers, keywords, special symbols, and operators, to illustrate how tokens are identified and categorized. It also touches on common errors such as token errors and the significance of comments in a program.
Takeaways
- 📘 The video discusses how a lexical analyzer program converts given code into tokens, emphasizing the importance of tokens in identifying elements within the code.
- 🔍 Two important points for tokenization are highlighted: the use of a deterministic finite automaton (DFA) and the process of doing tokenization by giving importance to the longest matching.
- 👉 The lexical analyzer always gives importance to the longest matching token, which means it combines characters into the longest possible token that matches the token definitions.
- 🌐 The script explains the concept of tokens, variables, keywords, and special symbols, and how they are identified and converted during the tokenization process.
- 🔢 The process of counting tokens is discussed, noting that it is crucial to correctly identify the number of tokens present in a given code snippet.
- 💡 The video clarifies that the lexical analyzer does not check for syntax or semantic errors; it only scans the program to convert it into tokens.
- 🚫 The difference between lexical errors and syntax or semantic errors is explained, with lexical errors being those that prevent the creation of valid tokens.
- 🔑 The role of comments in a code snippet is discussed, noting that the lexical analyzer will remove them, affecting the token count.
- 🔄 The concept of 'longest matching' is repeatedly emphasized, as it is a key principle in tokenization to avoid errors and ensure accurate token identification.
- 📖 The script serves as an educational resource, aiming to provide a comprehensive understanding of lexical analysis and tokenization in programming.
- 🔍 The video concludes by covering various scenarios and examples to illustrate the tokenization process, including handling of strings, operators, and potential errors.
Q & A
What is the primary function of a lexical analyzer in a compiler?
-The primary function of a lexical analyzer is to convert a given program into tokens, which are meaningful words or symbols in the program.
What are tokens in the context of lexical analysis?
-Tokens are meaningful words or symbols identified by the lexical analyzer, such as keywords, identifiers, operators, and special symbols.
What are the two important points to understand about how a lexical analyzer converts a program into tokens?
-The two important points are: 1) The lexical analyzer uses deterministic finite automata (DFA) to perform tokenization. 2) During tokenization, the lexical analyzer always gives importance to the longest matching sequence.
How does the lexical analyzer handle keywords and identifiers?
-The lexical analyzer reads characters sequentially and tries to match the longest sequence of characters that form a valid token, such as a keyword or an identifier. It checks for the next character to determine if the sequence forms a complete token.
Why is the concept of 'longest matching' important in lexical analysis?
-The concept of 'longest matching' is important because the lexical analyzer must ensure that it identifies the longest possible sequence of characters that form a valid token. This avoids prematurely identifying partial tokens and ensures accurate tokenization.
What happens if a program contains a syntax error during lexical analysis?
-The lexical analyzer does not rectify syntax or semantic errors. Its job is to scan the program and convert it into tokens. Syntax errors are checked by the syntax analyzer, and semantic errors are checked by the semantic analyzer.
How does the lexical analyzer handle special symbols and operators?
-Special symbols and operators are treated as individual tokens. The lexical analyzer identifies these symbols directly and does not require reading additional characters for confirmation.
What is the role of deterministic finite automata (DFA) in lexical analysis?
-Deterministic finite automata (DFA) are used by the lexical analyzer to recognize patterns in the input program and convert them into tokens. DFA helps in identifying the longest matching sequence of characters for each token.
What is the difference between deterministic finite automata (DFA) and non-deterministic finite automata (NFA) in the context of lexical analysis?
-DFA has a single path for each input character leading to a unique next state, making it efficient for lexical analysis. NFA can have multiple paths for a single input character, but it can be converted to DFA for practical use in lexical analyzers.
How does the lexical analyzer handle strings and comments in the input program?
-Strings are treated as single tokens starting and ending with double quotes, and the content within the quotes is not further tokenized. Comments are removed by the lexical analyzer and are not converted into tokens.
Outlines
🔍 Introduction to Lexical Analysis
The script begins with an exploration of lexical analysis, explaining the process of converting a program into tokens using a lexical analyzer program. It emphasizes the importance of understanding two key points: the use of deterministic finite automata in lexical analysis and the concept of longest matching during tokenization. The paragraph discusses how to identify tokens such as identifiers, keywords, and special symbols, and how to handle situations where the next character read may or may not be necessary for determining the token.
📈 Detailed Explanation of Tokenization
This paragraph delves deeper into the tokenization process, highlighting the importance of longest matching to avoid errors in counting tokens. It discusses various examples, including the handling of binary addition and unary increment operators, and clarifies the concept of combining tokens to form the correct token sequence. The summary also touches on the significance of recognizing constant values and understanding the role of syntax and semantic errors in the context of lexical analysis.
🛠️ Handling of Syntax and Lexical Errors
The script continues with a discussion on syntax and lexical errors, explaining the difference between them and how they are treated during lexical analysis. It points out that lexical errors are not checked by the lexical analyzer, which only focuses on converting the input program into tokens. The paragraph provides examples to illustrate common mistakes, such as using variables before declaration and incorrect use of operators, and emphasizes the importance of proper variable declaration and usage order.
📝 Impact of Comment Lines on Tokenization
This section of the script addresses how comment lines are treated during lexical analysis. It explains that the lexical analyzer will remove comment lines, which may affect the count of tokens and the overall structure of the program. The paragraph illustrates how spaces and other elements are handled after the removal of comments, ensuring that the token count remains accurate and reflecting the impact on the program's syntax.
🔧 Final Thoughts on Lexical Analysis
The final paragraph wraps up the discussion on lexical analysis by summarizing the key points covered in the script. It reiterates the importance of using the longest matching strategy during tokenization and the role of the lexical analyzer in identifying meaningful words and converting them into tokens. The summary also touches on common errors that can occur, such as unclosed strings, and the need to be aware of these issues when writing programs.
Mindmap
Keywords
💡Lexical Analyzer
💡Token
💡Deterministic Finite Automaton (DFA)
💡Longest Matching
💡Identifier
💡Keyword
💡Variable
💡Operator
💡Comment
💡Syntax Error
💡Semantic Error
Highlights
Introduction to lexical analyzers and the concept of tokenization in programming.
Explanation of tokens as meaningful words in the context of programming.
The importance of deterministic finite automata in lexical analysis.
Discussion on how lexical analyzers use a deterministic finite automaton for tokenization.
The significance of longest matching in lexical analysis to avoid syntax errors.
How lexical analyzers give importance to the longest matching token.
The process of identifying tokens in a given program and the role of the initial state.
Explanation of how a lexical analyzer determines the first token in a program.
The role of variables in tokenization and their identification as tokens.
How to handle the reading of the next character in tokenization when necessary.
The concept of non-deterministic finite automata and their conversion in tokenization.
Practical examples of tokenization, including keywords, variables, and special symbols.
The process of eliminating comments in a program during lexical analysis.
How lexical analyzers ignore syntax and semantic errors, focusing solely on meaningful words.
The importance of counting tokens correctly to avoid mistakes in lexical analysis.
Examples illustrating the concept of longest matching in tokenization.
Discussion on the handling of syntax and semantic errors in programming.
Final thoughts on the role of lexical analyzers in generating tokens from a program.
Transcripts
सो इस वीडियो में हम लोग डिस्कस करेंगे
किस तरीके से लेक्सिक एनालाइजर प्रोग्राम
को टोकन में कन्वर्ट करता है तो टोकन क्या
होता है बेसिकली ठीक है इट्स अ मीनिंगफुल
वर्ड जिसमें आपका
आइडेंटिफिकेशन
क्या-क्या होते हैं अब इस वीडियो में हम
लोग डिस्कस करेंगे कि कोई भी आपका गिवन
प्रोग्राम है उसको किस तरीके से टोकन में
कन्वर्ट करेंगे मतलब लेक्स एनालाइजर किस
तरीके से टोकन में कन्वर्ट करता है तो
उसके लिए दो इंपोर्टेंट पॉइंट है जो कि
जानना बहुत जरूरी है पहले लेक्सिक
एनालाइजर यूस डिटरमिनिस्टिक फाइना इट
ऑटोमेटर जो हम लोग टीसी में डिस्कस किए थे
डीएफए एनएफ फाइना इट ऑटोमेटर वही डीएफ
डीएफए टू डू टोकेनाइजेशन पहला पॉइंट दूसरा
पॉइंट वाइल डूइंग टोकेनाइजेशन
लेक्सिक एनालाइजर य लेक्सिक एनालाइजर
लिखना लेक्सिक एनालाइजर ऑलवेज गिव्स
इंपॉर्टेंस टू लांगेस्ट मैचिंग अब इस
दोनों जो है पॉइंट का क्या मतलब है ये
आपका गिवन प्रोग्राम है सी प्रोग्राम अब
इसमें हमें फाइंड आउट करना है कि कितने
नंबर ऑफ टोकन प्रेजेंट है तो सबसे पहला
देखते हैं तो सबसे पहला टोकन क्या आएगा
इंटी जर तो ये सबसे पहला टोकन हो जाएगा ये
हो जाएगा टोकन नंबर वन लेकिन आएगा कैसे तो
डीए किस तरीके से डिजाइन होता है लेट्स
सपोज हम ये हमारा ये स्टेट है इनिशियल
स्टेट ओके उसके बाद क्या कर र है i को ये
रीड करेगा और नेक्स्ट स्टेट पे चला जाएगा
ओके तो जैसे ही हमको फाइनल स्टेट मिलेगा
वहीं स्टॉप कर जाएंगे और क्या हो जाएगा वो
आपका टोकन हो जाएगा तो आ क्या हम आ पे
स्टॉप कर सकते हैं क्योंकि आ भी आपका एक
वेरिएबल हो सकता है वेरिएबल क्या होता है
आइडेंटिफिकेशन
टोकन तो क्या हम यहीं स्टॉप कर जाएंगे
नहीं जब भी कोई वेरिएबल आएगा यहां दो
तरीके से हम लोग इसको डिस्कस करेंगे कि
कभी-कभी हमें नेक्स्ट सिंबल रीड करना
पड़ेगा नेक्स्ट कैरेक्टर और कभी-कभी ऐसे
जो है सिंबल्स आएंगे जिसके लिए नेक्स्ट
मतलब ये नेक्स्ट आपका कैरेक्टर रीड करने
की जरूरत नहीं है खैर वो कैसे आएगा देखते
हैं तो आपका आई आया तो ऐसी पॉसिबिलिटी हो
सकती है कि भाई ये आइडेंटिफिकेशन
ए के बाद यहां आए उसके बाद आई ए मिला अब
उसके बाद फिर क्या करेंगे नेक्स्ट
कैरेक्टर चेक करेंगे मिला उसके बाद यहां आ
ग अभी भी हम शर नहीं है कि हो सकता है कि
इंट के बाद किसी ने इस तरीके से लिख दिया
किसीने लिख दिया आई एन
टी प इस तरीके से भी कुछ लिख सकता है तो
क्या होगा ये ये इंजर य आपका कीवर्ड नहीं
होगा ये पूरा मिला के क्या हो जाएगा एक
आईडेंटिफायर होगा इसलिए हम यही स्टॉप नहीं
करेंगे नेक्स्ट क्या होगा नेक्स्ट चेक
करेंगे लेट सपोज इस तरीके से लिख नेक्स्ट
आपका ब्लैंक ओके तो ब्लैंक इस तरीके से अब
तब जाके हमें पता चलेगा ओ अब हम क्या
करेंगे क्योंकि इंट के बाद जैसे हमने
ब्लैंक क्रिएट किया ऐसे ही पता चल गया कि
अच्छा ये तीनों मिला के क्या आ रहा है
आपका एक कीवर्ड हो रहा है इंटी जर डेटा
टाइप तो इसलिए हमें कभी-कभी नेक्स्ट सिंबल
रीड करके तब फाइनल स्टेट प पहुंचेंगे और
कभी-कभी ऐसा होगा कि हमें जो है नेक्स्ट
सिंबल रीड करने की जरूरत नहीं पड़ेगी अभी
उसपे आते हैं देखते हैं तो इसका मतलब इंट
आपका क्या हो गया एक कीवर्ड हो गया ये
पहला कीवर्ड हो गया नेक्स्ट इसी तरीके से
क्या है मेन देख लेते हैं एक और देख लेते
हैं अब सपोज दैट हमें यहां मिला ए
ए ये भी हो सकता है कि भाई आपका येय
आइडेंटिफिकेशन
ब्रैकेट आया इसका मतलब ये पता चल गया कि
भाई ओपन ब्रैकेट का मतलब इससे पहले क्या
था आपका फंक्शन और ये क्या आपका मेन
फंक्शन तो दूसरा जो
है
क्या कहते हैं टोकेंस दूसरा टोकन क्या हो
जाएगा आपका मेन हो जाएगा तो यहां देखो मेन
रीड करके यहां तक पहुंचे अब नेक्स्ट सिंबल
जो है रीड करना जरूरी है क्यों क्योंकि हम
आइडेंटिफिकेशन
का नाम इस तरीके से लिख सकता है ऐसा सिर्फ
यहीं तक जाके हम नहीं कह सकते कि अच्छा
मेन जो है आपका फंक्शन नहीं हमें नेक्स्ट
सिंबल भी रीड करना पड़ेगा अब देखो तो
इसलिए हम फाइनल पर पहुंच जाएंगे और यह
डायग्राम हम पूरा नहीं बना रहे क्योंकि य
स्पेस है नहीं सारे बस यह समझ लो इस तरीके
से ये क्या है आपका एक टम डिटरमिनिस्टिक
फाइना इट ऑटोमेटा नहीं लेकिन अगर कोई आपका
नॉन डिटरमिनिस्टिक फाइट ऑटोमेटा भी बन रहा
है तो उसको हम डीएफ में कन्वर्ट कर सकते
हैं तो इसलिए कहीं कहीं आपको फाइना इट
ऑटोमेटा भी लिखा होगा तो उसमें कंफ्यूज
नहीं होना है लेक्सिक एलाइजर यूस डीएफ टू
डू टोकेनाइजेशन तो इस तरीके से वो
टोकेनाइजेशन करेगा अब नेक्स्ट नेक्स्ट
क्या है ओपन ब्रैकेट अब इसके लिए हमें
नेक्स्ट है कोई भी नेक्स सिंबल उसको रीड
करने की जरूरत नहीं वो सेल्फ सफिट है
अच्छा य एक स्पेशल सिंबल है इसका मतलब वो
क्या टोकन है यह भी क्या आपका टोकन है तो
इस लाइन में टोटल नंबर ऑ टोकन टूथ
4 फोर टोकन हो गया यह भी आपका टोकन है
इसका मतलब यहां इस लाइन में फ हो गया यह
आपका टोकन 6 से 8 ओके तो यहां तक गए हम
लोग कितना मिला 8 मिल गया देखो ये आपका एक
कीवर्ड है टोकन ये आपका एक वेरिएबल है
टोकन स्पेशल सिंबल टोकन यहां तक 8 हो गया
अब ये क्या है अब डायरेक्टली हम लिख रहे
हैं 4 9 10 11 12 13 14 15 16 17 18 ओके य
18 उसके बाद 19 अब यहां ये समझना बहुत
जरूरी यहां तक 19 आया लो यहां लिख लेते
हैं यहां तक 19 आया अब यहां प्लस प्लस है
ओके तो अब
देखो यहां आए सपोज ट ये आपका एक प्लस है
तो हो सकता है कि आपका बाइनरी जो है एडिशन
हो
लेकिन ऐसा भी हो सकता है कि आपका यह प्लस
प्लस में तब जाके हम फाइनल में पहुंचेंगे
क्योंकि ये हो सकता है कि आपका यूनिरी
इंक्रीमेंट भी हो तो कब इसका मतलब क्या है
वाइल डूइंग टोकेनाइजेशन लेक्सिक एलाइजर
ऑलवेज गिव इंपोर्टेंस टू द लांगेस्ट
मैचिंग लांगेस्ट का मैचिंग लांगेस्ट अगर
यह आपका एक टोकन है और यह भी टोकन और
दोनों कंबाइन होके अगर आपका टोकन मिला है
तो उसको हम क्या करेंगे कंबाइन करके
लिखेंगे इसलिए लांगेस्ट मैचिंग लिखा हुआ
है तो ये जो टोकन है ये एक होगा तो यहां
19 यहां तक हुआ था फिर 20 21 ओके ये आपका
21 यहां तक हुआ फिर 22 इस लाइन में 22 हो
गया फिर ये आप गया 23 24 25 ये 26 27 यहां
तक 27 मिला अब यहां देखो देखो लांगेस्ट
मैचिंग इ इससे समझते हैं
102 वन अपने आप में एक कांस्टेंट है तो
क्या होगा टोकन रो अपने आप में एक
कांस्टेंट है ओके ये भी एक टोकन होगा टू
भी अपने आप में एक कांस्टेंट है तो ये
अलग-अलग क्या आ रहा है आपका टोकन आ रहा है
लेकिन यहां क्या है आपका एक साथ लिखा हुआ
है तो पूरा हम क्या करेंगे एक साथ लिखेंगे
लांगेस्ट मैचिंग का मतलब ये कि तब तक हम
उसको इंक्लूड करते जाएंगे एक ही टोकन में
जब तक
कि मतलब ये कि वो अलग ना हो तो इसका मतलब
102 अपने आप में एक टोकन है तो यहां तक 27
हो गया था ओके काउंटिंग देख लेना ओके
काउंटिंग में हो सकता है मिस्टेक हो जाए
बट कांसेप्ट हमें समझना है 27 उसके बाद
यहां है 28 ओके पूरा प्रिंट अफ क्या है ये
भी आपका एक फंक्शन 28 29 ओके ओ है 29 यहां
तक पहुंचा अब यहां ये समझना है जैसे ही
आपका अ जो भी आपका मतलब ये प्रिंट अफ के
अंदर जो डबल कोट्स में लिखा होगा वो यहां
से स्टार्ट करेंगे और डबल कोट्स के खत्म
होने तक ये पूरा एक टोकन होगा इसमें हमें
कंफ्यूज नहीं होना इसके अंदर हमें चेक
करने की जरूरत नहीं क्या लिखा हुआ है डबल
कोट्स पूरा एक क्या होगा टोकन होगा तो 27
यहां तक हो था 28 29 30 31 32 33 34 ओके
35 ये मिला के 36 ये 37 यहां तक 37 आया 38
रिटर्न 39 40 41 यहां तक 41 मिला और ये
क्या हो गया आपका 42 तो फाइनल आंसर जो आ
रहा है वो क्या आ रहा है आपका 42 तो इसमें
सिर्फ दो ही इंपॉर्टेंट पॉइंट है समझने के
लिए कि आपका लेक्सिक एनालाइजर डीएफ यूज
करता है इस तरीके से डायग्राम वो
इंपोर्टेंट नहीं है उतना बस हमें क्या
करना है क्वेश्चन किस तरीके से आएंगे कि
आपको एक प्रोग्राम दिया रहेगा नंबर ऑफ
टोकन वहां क्या करना है ये टर्म बहुत ही
इंपॉर्टेंट ओके लांगेस्ट मैचिंग जैसे हमने
लांगेस्ट मैचिंग के लिए कौन सा एग्जांपल
दिया प्लस प्लस का और 102 का क वन भी अपने
आप में क्या है कांस्टेंट मी टोकन जीरो भी
लेकिन कंबाइन अगर आपका प्लस टोकन है और यह
प्लस टोकन लेकिन दोनों कंबाइन होके प्लस
भी तो टोकन है बाइनरी एडिशन लेकिन अगर ये
आपका प्लस आ रहा तो दोनों मिला के अगर
टोकन है दोनों मिला के लिखेंगे ऐसा नहीं
है कि इसको अलग और इसको अलग लिखेंगे नहीं
ऐसा नहीं लिखना तो इस पर्टिकुलर क्वेश्चन
के लिए नंबर ऑफ टोकन क्या आएंगे 42
काउंटिंग में हो सकता है कोई मिस्टेक हो
गई हो तो प्लीज उसको आप जो है काउंट करके
देख लेना लेकिन कांसेप्ट तो आई थिंक समझ
में आ गया होगा किस तरीके से टोकन काउंट
करना है तो टोटल क्या हो जाएगा 42 सो एक
प्रॉब्लम और डिस्कस करते हैं ये प्रॉब्लम
बहुत ही इंटरेस्टिंग है समझने के लिए कि
किस तरीके से लेक्सिक एनालाइजर टोकन में
जनरेट करता है प्रोग्राम को अब देखो यहां
हैब हम डीएफए बनाने नहीं जा रहे हैं बस
खाली हमें देखना है अच्छा ये मेन आपका एक
जो है टोकन हो गया अब इसके बाद क्या आ रहा
है आपका क्लोज ब्रैकेट पहले ही आ गया ओके
तो लेक्सिक एनालाइजर क्या करता है उसका का
काम सिर्फ इतना ही होता है कि कोई भी आपका
गिवन प्रोग्राम है उसको टोकन में कन्वर्ट
कर दो वो सिंटेक्स और सिमटिक एरर को
रेक्टिफाई नहीं करता वो सिंटेक्स एरर जो
होगा वो सिंटेक्स एनालाइजर देखेगा और जो
सिमटिक से रिलेटेड चीजें होंगी वो सिमटिक
एनालाइजर देखेगा लेक्सिक एनालाइजर सिर्फ
क्या करेगा प्रोग्राम को स्कैन करेगा अगर
उसको मीनिंगफुल वर्ड मिला तो उसको टोकन
में कन्वर्ट कर देगा ओके तो ये मीनिंगफुल
वर्ड है यस क्या है ये आप क्लोज ब्रैकेट थ
तो यहां तक हमको क्या मिल गया तीन टोकन इस
लाइन में मिल गए ये चौथा टोकन हो गया तो
टोटल फोर गया अब देखो देख लेते हैं पहले 4
5 6 7 8 9 10 11 12 यहां तक हमको 12 मिल
गया 13 14 कॉमा क्या हो जाएगा 15 16 17 18
19 20 21 यहां तक 21 मिल गया 22 23 24 25
26 27 यहां तक 27 मिल गया और ये क्या आपका
28 तो टोटल कितना मिला है
28 लेकिन क्या इस अगर देखें प्रोग्राम में
तो प्रोग्राम में एक तो पहली बात य कि
सिंटेक्स एरर है य देखो यह तो वैलिड है
नहीं य हमने फलोर बकेट पहले क्लोज लिखा य
ओपन लिखा हुआ है जबक ऐसा होता नहीं है जो
सिंटेक्स सी के प्रोग्राम को पहले य ये
आना चाहिए य बाद में आना चाहिए लेकिन लेसल
ये लेक्सिक एरर नहीं लेक्सिक एरर क्या
होती है व भी हम लोग डिस्कस करने वाले
नेक्स्ट एग्जांपल में अब दूसरी प्रॉब्लम
क्या है इसमें सिंटेक्स एरर है नो डाउट
ओके तो इसमें सिंटेक्स एरर है ओके
सिंटेक्स एरर क्या इसमें सिमटिक एरर भी है
मतलब सेम वही है सिटेक्स एरर सिमटिक एरर
सिमटिक एरर का मतलब क्या होता है देखो
यहां हमने x = a + ब स् स पहले लिखा हुआ
है दैट मीन यहां हम एक्सप्रेशन सारे
वेरिएबल हम पहले यूज करें डिक्लेयर बाद
में करते हैं मतलब नहीं बाद में कर रहे
हैं तो होता क्या है कि अगर आपको
प्रोग्राम लिखना है तो सबसे पहले वेरिएबल
को डिक्लेयर करते हैं उसके बाद जो है उसको
यूज करते हैं यहां क्या हो गया उल्टा हो
गया और दूसरी चीज y तो हमने यहां डिक्लेयर
भी नहीं किया फिर भी हम वहां y यूज करें
ये क्या अनडिक्लेयर्ड वेरिएबल तो इसमें
क्या है कि 70 एरर सिंटेक्स लेकिन इसमें
कोई भी लेक्सिक एरर नहीं आएगी तो जब भी
कोई भी एग्जांपल आए तो उसमें हमें इमोशनल
नहीं होना कि अरे इसका सिंटेक्स तो गलत हो
गया तो इसलिए हम इसका नंबर ऑफ टोकन नहीं
क्रिएट कर सकते नंबर ऑफ टोकेंस लेक्सिक
एनालाइजर टोकन जनरेट करेगा बस खाली हमें
ना सिंटेक्स देखना है ना सिमटिक देखना है
सिर्फ ये देखना है कहीं कोई उसमें लेक्सिक
एरर है कि नहीं अगर लेक्सिक एरर होगा तब
तो वो टोकन में जनरेट नहीं कर पाएगा
लेक्सिक एरर क्या होती है देखते हैं
सिंटेक्स और सिमटिक लेक्सिक एनालाइजर चेक
नहीं करता है ओके सो अब एक एग्जांपल और
डिस्कस कर ओके यही आपका सेम मेन है
टूथ इस लाइन में कितने थ्री इसको मिला
कितना हो गया फोर अब देखो यहां इंट एक्स
अब देखो यहां डबल इक्वल है यहां एक इक्वल
है ये भी आपका क्या है टोकन क्योंकि क्या
है असाइनमेंट सॉरी असाइनमेंट ऑपरेटर और
दूसरा भी क्या है आपका असाइनमेंट ऑपरेटर
लेकिन अगर इन दोनों को कंबाइन करेंगे तो
क्या आ जाता कंपैरिजन ऑपरेटर हां ठीक है
यहां हम कंपैरिजन नहीं कर सकते उसके लिए
हमें क्या करना होगा ए या मब कोई ना कोई
कंडीशनल स्टेटमेंट लगाना होगा यहां हम
क्या कर ें असाइन कर रहे वैल्यू लेकिन ये
क्या है ऑपरेटर असाइनमेंट ऑपरेटर नहीं
इक्वल टू ऑपरेटर जो कि कंपैरिजन के लिए
यूज कर ले सिंटेक्स एरर नहीं चेक करता
लेक्सिक लेजर अभी जो हम लोगों ने डिस्कस
किया प्रीवियस एग्जांपल में सिंटेक्स और
सिमटिक एरर के बारे में हमें नहीं सोचना
है बस ये देखना है क्या आपको मतलब लेक्सिक
लाइजर को ये मीनिंगफुल वर्ड दैट मींस टोकन
मिल रहा है अगर टोकन मिल रहा है तो वो
हैवली कन्वर्ट कर देगा ये दोनों कंबाइन
होके आ रहे हैं ओके क्योंकि ये देखो ये जो
हमने डिस्कस किया लांगेस्ट मै बार-बार
इसीज पे एमफसा क्यों कर रहे हैं क्योंकि
हो सकता है इसी में गलती हो कि अच्छा ये
भी इक्वल है ये भी इक्वल है तो दो अलग-अलग
ऑपरेटर हो नहीं दोनों को कंबाइन करके अगर
एक ऑपरेटर बना है तो उसको भी उसी को हम
टोकन कहेंगे अलग-अलग नहीं लिखना है फाइन
ये हो गया उसके बाद यहां हो गया ये टोकन
है ये टोकन है अब देखो यहां लेस देन है ये
भी एक आपका ऑपरेटर है और इक्वल भी एक
ऑपरेटर लेकिन अगर इन दोनों को अप्लाई करें
तो क्या होता है लेस दन और इक्वल टू ये
सिंगल ऑपरेटर होगा तो ये दोनों मिला के
क्या होगा एक टोकन यहां भी एक टोकन यहां
भी तो क्या हो जाएगा फोर वहां तक था 5 6 7
8 9 10 11 12 13 यहां तक क्या आया
13 उसके बाद 14 15 ओके और इसके अंदर जो भी
होगा एक सिंगल लेंगे तो 15 के बाद ये 16
17 18 19 20 यहां तक 20 आ रहा और लास्ट
वाला गया आपका 21 अब यहां एक चीज यहां भी
आएगी देखो सिंटेक्स क्या यहां परसेंटाइल
डी थ्री बार जो है तीन बार लिखे हुए हैं
लेकिन यहां वेरिएबल सिर्फ एक ही बार लिखे
हुए हैं ये क्या आपका सिंटेक्स एरर है
सिंटेक्स एरर नहीं चेक करना बार-बार इस
चीज को इसलिए रिपीट कर रहे हैं क्योंकि
मोस्टली गलती ही होती है अच्छा यहां
सिंटेक्स एरर नहीं करना हमें टोकन में
कन्वर्ट ही नहीं करना नहीं ऐसा नहीं करना
है लेक्सिक एनालाइजर सिर्फ जो आपका
प्रोग्राम होता है उसको टोकन में कन्वर्ट
कर देता है तो इस प्रोग्राम के लिए टोटल
नंबर ऑफ टोकन कितने आएंगे 21 ओके तो इस
प्रॉब्लम को सॉल्व करते हैं ये बहुत ही
इंटरेस्टिंग प्रॉब्लम है ओके तो सेम यही
टूथ एंड 4 यहां तक तो सब कॉमन है फोर ये
हो गया ठीक है वन अब यहां देखो ये समझना
जरूरी है ये क्या है आपका स्टार सी तो हम
यहां इसको पॉइंटर नहीं समझना यहां सिर्फ
लेक्सिक एनालिसिस हो रही है दैट मींस जो
भी मीनिंगफुल वर्ड मिला उसको टोकन में
कन्वर्ट कर दे रहा है तो स्टार स्टार का
मतलब सिंपली मल्टीप्लिकेशन या ये पॉइंटर
या डी रिफरेंस ऑपरेटर या रिफरेंस सॉफ्टवेर
कुछ नहीं समझेगा नॉट रिफरेंस डी रिफरेंस
ये क्या है आपका स्टार सी पॉइंटर तो
डिक्लेयर हो रहा है लेकिन इसको ये
मल्टीप्लिकेशन समझेगा और यहां क्या है
आपका कैरेक्टर तो अपने आप में ये क्या हो
जाएगा आपका एक टोकन और ये दूसरा टोकन हो
जाएगा फाइन और ये नेक्स्ट टोकन होगा और
स्ट्रिंग का मतलब ये पूरा एक टोकन है और
ये एक टोकन तो कितना हो जाएगा ट 3 4 5 6 6
प् 4
10 ओके इवन अगर कहीं इस तरीके से लिखा हुआ
स्टार स्टार सी ओके तो यह भी एक टोकन होगा
यह भी एक टोकन होगा यह भी एक टोकन होगा ये
भी इस तरह के भी प्रॉब्लम बहुत सारे
प्रॉब्लम हम इसलिए डिस्कस कर रहे हैं ताकि
कहीं भी किसी भी तरीके का कोई क्वेश्चन हो
तो हर एक कांसेप्ट उसमें हर तरह की
वैराइटी अगर इंक्लूडेड रहेगी तो कोई भी जो
है दिक्कत नहीं आएगी सारी चीज सॉल्व हो
जाएंगे नेक्स्ट
टूथ फर 5 तो कितना हो गया 15
टू 3 4 5 20 ट 3 4 5
25 अब देखो ये समझने इस क्वेश्चन में
सिर्फ यही इंपोर्टेंट था समझना बाकी तो
ऑलरेडी पता है किस तरीके से कर अब देखो य
आई ए है और इसके बाद क्या ब्लैंक उसके बाद
टी है तो क्या इसको हम एक कीवर्ड समझ
मानेंगे नहीं ये कीवर्ड नहीं है लेजर क्या
करेगा इसको अलग कर देगा इसको अलग कर देगा
इसको अलग कर देगा ये आपका इंट स्पेस है
बीच में आई ए के बाद तो इसका मतलब ये ये
इसको अलग आइडेंटिफिकेशन
में कन्वर्ट कर देगा ये हो जाएगा ये हो
जाएगा ये तो कितना हो जाएगा 1 2 3 4 5 6
तो 25 प् 6
31 ओके अब आते हैं नेक्स्ट लाइन नेक्स्ट
लाइन में क्या आ आपकी कॉमेंट लाइन तो
कॉमेंट लाइन क्या करता है प्रीवियस वीडियो
में हमने डिस्कस किया था लेक्सिक लाइजर की
डेफिनेशन के टाइम कि लेक्सिक एनालाइजर
क्या करता है जब प्रोग्राम को स्कैन करता
है तो अगर उसमें कोई भी कमेंट लाइन उसको
रिमूव कर देगा तो जैसे ही ये कमेंट लाइन
रिमूव हुई रिमूव होने के बाद यहां एक
स्पेस बचेगा तो आ और t में भी स्पेस रहेगा
तो ये वाली लाइन ये वाली लाइन दोनों सेम
ही है इन दोनों में कोई डिफरेंस नहीं है
यहां कितना आया था 1 2 3 4 5 6 तो यहां भी
सिक्स आ रहा है 31 + 6 च इज इ 37 काउंटिंग
आप देख लेना ओके नेक्स्ट अब यहां क्या है
स और इसके बीच में स्पेस है और देन एर है
ये कैप
कीवर्ड नहीं है ये सीच और ए आर अलग अलग
चीज है इसका मतलब ये आपका एक टोकन हो गया
दूसरा ये हो गया तीसरा ये हो गया चौथा ये
हो गया पांचवा ये हो गया छ ये हो गया ट 3
4 5 6 तो 37 प् 6 य लिख 37 प् 6 ये क्या
हो जाएगा
43 तो यहां तक 43 अब देखो वही सेम चीज
यहां भी क्या है आपका कमेंट लेंथ वो रिमूव
हो गया तो सी स्पेस ए इन दोनों में कोई भी
डिफरेंस नहीं आएगा वही सेम टू सेम आएगा तो
कितना आ रहा है 1 2 3 4 5 6 तो यहां भी
सिक्स मिला तो
43 + 6 49 यहां तक मिलेगा और यह क्या हो
गया
50 तो वैरायटी ऑफ प्रॉब्लम का मतलब यही
होता है कि हर तरह के एस्पेक्ट को कवर कर
लिया जाए तो यहां बहुत ही इंपॉर्टेंट ये
है कि जैसे ही कमेंट लाइन रिमूव बस इस
एग्जांपल में यही हमें बताना था कि कमेंट
लाइन जैसे ही रिमूव करेंगे तो इसमें देखो
ये दोनों लाइन भी क्या है सेम टू सेम है
ओके सो एक एग्जांपल और डिस्कस करते हैं और
ये लास्ट एग्जांप है इसमें मैंने जो है
टोकन एरर दैट मींस लेक्सिक एरर को भी
इंक्लूड किया हु ये पांच लाइन है और इसमें
पूछा जा रहा है क्वेश्चन में कि हर एक
लाइन में कितने टोकेंस होंगे तो देखो टोकन
नंबर वन टोकन नंबर टू 3 4 5 ये आपकी कमेंट
लाइन है लेक्शन एनालाइजर इसको रिमूव रिमूव
कर देगा कैसे हम
आइडेंटिफिकेशन ये क्या होता है आपका कमेंट
लाइन की स्टार्टिंग होती है और इसके बीच
में कुछ भी है वो कुछ भी कंसीडर नहीं करे
जैसे ही म मल्टीप्लिकेशन और डिवाइड मिला
कमेंट लाइन वहां फिनिश हो जाएगा तो दैट
मीस ये पूरा पार्ट रिमूव कर देगा टोटल
कितना है टूथ 4 5 इसमें मिला फ अब यहां
आते हैं x सॉरी टोकन होगा उसके बाद हमें
क्या मिला ट्रिपल इक्वल टू तो क्या ये कोई
ऑपरेटर होता है नहीं सिंगल होता है
असाइनमेंट ऑपरेटर अगर इन दोनों को हमने
इंक्लूड कर दिया तो क्या हो गया आपका
कंपैरिजन ऑपरेटर तो ये एक टोकन हो जाएगा
अब हमारे पास सिर्फ बचा ये ये दोनों मिला
के दो टोकन हो जाएंगे ये एक टोकन होगा ये
एक टोकन होगा फाइन उसके बाद ये हो जाएगा
टोकन
अब देखो यहां से कमेंट लाइन स्टार्ट हुई
चलते चले जाएंगे चलते चले जाएंगे चलते चले
जाएंगे यहां क्या हो रहा है ये आपकी कमेंट
लाइन फिनिश हो गई तो ये सीधे क्या करेगा
इसको एलिमिनेट कर देगा और यह नॉर्मल
मल्टीप्लिकेशन है यहां कोई भी डिवीजन
स्टार्ट नहीं हो रहा किय आप कमेंट लाइन
होगी कमेंट लाइन नहीं होगी यह भी एक आपका
क्या होगा टोकन होगा उसके बाद ए बी सीडी
पूरा एक टोकन होगा ओके ये पूरा अलग अलग
उसको कैरेक्टर देखो य इसलिए अभी इसको
मिटाए नहीं है लांगेस्ट मैचिंग लांगेस्ट
मैचिंग का मतलब a के बाद अच्छा b आ गया b
के बाद यह पूरा मिला के एक वेरिएबल की तरह
आइडेंटिफिकेशन
ये डिवीजन और ये गया आपका सेमीकलन तो ये
हो जाएगा 1 2 3 4 एलिमिनेट कर दिया 5 6 7
8 9 टोटल कितना आ रहा है नाइन इसमें आ रहा
है अब आते है इन स्टार स्टार प ओके तो ये
आपका हो जाएगा दूसरा यह होगा तीसरा ये
होगा चौथा ये होगा पांचवा ये होगा तो
इसमें टोटल कितने आ रहे पांच यहां इसमें
कंफ्यूजन हो सकते अच्छा स्ट क्या
मल्टीप्लिकेशन दूसरा स्टार क्या है
मल्टीप्लिकेशन तो दोनों अपना अपने आप में
क्या है आपके टोकन इन दोनों को कंबाइन
करेंगे क्या कोई टोकन मिल रहा है क्या कोई
ऐसा ऑपरेटर होता है ससी प्रोग्रामिंग
जिसको कहते हैं डबल डबल स्टार नहीं कोई
ऑपरेटर नहीं होता इसलिए हम इन दोनों को
अलग-अलग जो है टोकन कंसीडर करेंगे नेक्स्ट
ये आपका एक हो जाएगा दूसरा तीसरा चौथा ये
क्या हो जाएगा ये पांचवा हो जाएगा ये छठा
हो जाएगा और ये सा आन टोटल यहां भी क्या आ
रहा है आपका न आ रहा है ओके देखो प्लस
यहां मल्टीप्लिकेशन के केस में दोनों मिला
के कोई एक ऑपरेटर नहीं बन रहा लेकिन यहां
प्लस क्या है आपका बाइनरी अगर इन दोनों को
मिला दिया तो यरी अपने आप में ये भी टोकन
इसलिए लांगेस्ट मैचिंग तो ना आ गया अब
देखो एक दो तीन अब ये क्या है आपका डबल
कोट यहां से स्ट्रिंग की स्टार्टिंग है
लेकिन यहां स्ट्रिंग देखो कहीं एंड नहीं
हो रही है तो यहां क्या हो जाएगा आपका एरर
जिको क्या कहेंगे टोकन एरर या लेक्सिक एरर
तो टोकन एरर क्या होती है हमने स्टार्ट तो
किया स्ट्रिंग को लिखने के लिए डबल कोट्स
में लेकिन इसको क्लोज नहीं किया इसलिए
क्या आ जाएगा आपका टोकन तो एक एग्जांपल
मैंने ले लिया ताकि आपको पता रहे टोकन एरर
बेसिकली क्या हो है लेकिन मोस्टली अगर
प्रोग्राम लिखेंगे उसमें सिंटेक्स या
सिमटिक एरर ही आती है ओके तो आई होप मैंने
ऑलमोस्ट जितनी भी पॉसिबल जो है प्रॉब्लम
हो सकती तो सब कुछ कवर किया हुआ है तो ये
था आपका लेक्सिक लेजर के बारे में ये
पॉइंट है आपका कि डीएफए यूज करता है और
दूसरा क्या है आपका मेन इंपॉर्टेंट जो इस
पूरे पॉइंट का यानी इस पूरे टॉपिक का जो
क्रक्स है वोय है लांगेस्ट मैचिंग का हमें
ध्यान रखना है टोकन लिखते वक्त ये था आपका
टोकेनाइजेशन ओके
5.0 / 5 (0 votes)