All right. Can you all see the slides? Yes, looks good. All right. Great. Thank you for the introduction once again, and thank you all for joining me on this talk, despite this wordy mouthful of a title, which I realized in hindsight. With that said, I would like to transition to this slide which is a much simpler title, which is Simplifying Complex Next Generation Sequencing or NGS Analysis. For the remainder of the talk, I'd just like you to keep this in mind how we can create simple, easy-to-use tools. With that said, I'd just like to go over what a typical NGS workflow looks like. Let's say that you want to analyze one particular sample to see the gene expression in, let me just make sure I can get my pointer here. Let's say you want to look at a particular sample. Let's say a tumor sample and you want to see what genes are being expressed. You'd isolate that tumor, you'd extract the RNA, and then you'd fragment that and process it by adding different adapters, and then you'd sequence it typically on an Illumina sequencing platform. What that leaves you with is some raw read files which are called FASCII files. These are essentially specialized text files which contains information about what transcripts or which genes were identified in your sample. Then using these read files, you have to align it or map it to a reference genome. If we're looking at a human sample, we would align it to the human genome, obviously, and then this would give us a table of read counts. This is basically a table with genes along in the rows and then each of your samples would be in columns and there would be numbers which identify how many times that transcript was identified or detected in that particular sample. And then after that, you'd do some differential or DE analysis or some type of abundance analysis to, especially if you're comparing across multiple samples to see how those read counts change from one sample to the next. And then this will give you the differential gene expression or DGE or some type of other features of interest which will inform you on what to do next such as what other genes or pathways to investigate, which genes or pathways to target with particular drugs. So this entire process can be very complex. Of course here it seems simple for the one on depicting one sample, but this can be quite complex. Real world experiments are not as typically not as simple as this, especially when you're trying to find something groundbreaking and exciting, right? And each of these steps here can be pretty time consuming too. So let's consider one of these real world situations. So let's say you have three cancer patients and let's say you wanna see how a particular tumor, it doesn't really matter what type of tumor or what type of cancer, but let's say you wanna see how these particular tumors in these patients respond to a particular drug. So let's say through biopsies, these tumors were obtained and then let's consider this first one over here. So we take that and we grafted into two groups, two cohorts of mice. There's a control group which receives saline and then there's a drug treated group which receives your drug of interest. And these are, by the way, these are immunocompromised mice that can take up, accept a human tumor graft or human cell graft. So in each of these cohorts, there are triplicates or three mice. So we graft pieces of that tumor into these mice and then we treat each group for six weeks. And at the end of that six weeks, we excise the tumors and we prepare them for sequencing. And in this particular case, we're doing single cell RNA sequencing. So we also add some synthetic nucleotides to keep track of which sample and which replicate and which treatment group that each of these excise tumors come from. So we add those and we prepare them, we process it and we get it ready basically for sequencing. And so this is what we do for one tumor. And then for this other tumor, we do the same thing. And then also for this one here, which is grayed out just to make this figure easy to read. So here's a full look at that of the protocol. So once you process everything for sequencing and you do the actual sequencing, you do some analysis magic and you end up with these really cool looking figures that we typically get for single cell sequencing projects which are these cluster plots showing how different cells or different samples cluster in T-cell or UMAP plots. But before we get there, consider how much data that's actually here. So we have three patients. From each patient, we have two treatment groups. From each treatment group, there are three replicates which contain some synthetic or artificial nucleotide barcodes which are also sequenced. And then from each tumor, so from each of these tumors here, the leftover tumors that we're gonna sequence after the drug treatment, we're gonna roughly detect five million cells per replicate. And then because it's a single cell RNA sequencing, from each of those five million cells, we're going to detect roughly 20,000 protein-coding genes which is roughly the number of protein-coding genes that are present in the human genome. So that's a ton of data. So how do we go from all of that data that the sheer size, consider not just the values that are required at the numerical values but the actual size on disk. How do we go from there to the final and nice looking publication quality figures? So there are multiple ways to analyze these types of experiments. And you don't really need to know, I'm not gonna go over each of these different components. You can read these steps if you'd like and I've kind of put the logos of the common ones here on the side. But the takeaway is that there's really no, there's really no best way to do this. There's multiple, in each of these steps, you can swap out different components and you can run the pipeline different ways. But more or less, you're gonna get the same answer, which means that if a gene is really over-expressed or under-expressed in a tumor, you're gonna, and if it's statistically significant and if it's actually occurring, you're gonna find it despite which tool or which method you use. But the point here is that all of these methods are command line based or scripting based, which means that a typical wet lab scientist is carrying out this experiment is probably not well versed in how to analyze this data. So that's a huge roadblock for them to analyze their own data. The other thing to consider is that, like I said, at each of these different steps, you can use different tools to analyze the data. Now, when you have a pipeline, the output coming from one of those tools can't necessarily right away be fed into the next successive components. You'd have to do some modifications or some pre-processing to make sure that the next component can actually meaningfully make sense of that data. If you're not careful, if you put something in that's not compatible, it may run and you're gonna get a skewed or a statistically non-meaningful or incorrect output, which can really affect your downstream analyses. So that creates some difficulties and barriers that I encountered in NGS pipeline. So not just for single cell sequencing, but for all types of sequences too, whether it's Christmas screening, ATAC-seq, chip-seq, whole genome-seq. So when you're analyzing all these different experiments, the complexity of the amount of samples or the amount of replicates or the type of experiment that you're doing is going to affect how you analyze it. And not every experiment is unique. You could do two, we could take the experiment of the single cell sequencing experiment that I showed and you can do it for the same type of cancer from different patients. And it may not always be the same process in terms of analyzing it. You may encounter some issues with the samples. You may encounter some issues with the replicates, some sequencing errors. So you need to be able to adapt and be dynamic and not rigid in the way you analyze these. The other thing is, like I said, there's multiple tools and multiple languages and platforms. So you may do your, the alignments are typically done in bash or shell scripting. You could use R or Python for some of the differential expression analysis. Sometimes some steps are run using tools designed in Perl or C. So you need to know as bifurmiticians, if you're a bifurmitician, you know that there's multiple tools that you have to use. And then also the compute resources involved. So these are things like CPU, RAM and disk space and the larger or more samples and replicates that your experiment has, more of these resources that you will require. So sometimes these things can't really be run on a local machine. And obviously each of these things contributes a time, whether it's the time used to learn how to run the pipeline or just the sheer amount of time required to run some of the steps. So how do you solve for this? So obviously you can automate the pipelines, but just cruelly automating scripts isn't necessarily going to work that well. It's still, that still creates some rigidity, like I said, and you need to be able to be flexible for the uniqueness of different experiments. So you can provide a modular framework then. So this modular framework basically means that different modules can be shuffled in and out depending on the experiment, depending on the issues encountered during the analysis. And then you can abstract away the languages and tools from the user. So you can have one overarching programming language like Python or R that then calls all the other languages and tools that are required. So in this way, you remove the user from what languages are being used for the analysis and all of that is handled in the background. And then for the compute resources, you can make your tool cloud-based. So using something like AWS. So this makes it really easy for the user because they don't have to worry about the number of CP cores they have, the amount of disk space they have or the amount of RAM they have. Everything is done on the cloud. So they can virtually run it on any type of local machine. And then using parallel processing, we can really speed up the amount of time that it takes to analyze these types of complex experiments. So we're building a solution that is a point and click solution. So it's a graphical user interface tool to analyze experiments, a multitude of NGS experiments. And we're beginning with single cell sequencing experiments. So it's a point and click interface and the front end is built using React. So the user can point and click, upload their data, their raw read files that comes out of the sequencing platform. They can customize all of the parameters of the experiment, things like the type of experiment, how many samples they have in the replicates, any cut-off thresholds, any statistical parameters. And anytime there's several options to do a particular step, such as clustering or normalization, all of these can be customized using just selecting from a list and peering wish. They don't need to know the command line arguments to define those parameters. And then once that's done based on the parameters, an automated framework is assembled and this runs the actual analysis. And so this is really the meat of the tool, if you will. So our framework is built in, so we use Python as the overarching language and then using things like reticulate and basilless, there's interoperability with R and so they work together. And then we also respect the bi-conductor framework. So we follow the bi-conductor principles for analyzing and working with genomic data so different types of genomic data objects. And in the backend is handled via Flask. This is what allows us to quickly and efficiently shuffle the data from the backend analysis into the front end. And then of course, for the cloud we use things like EC2 for instances, EFS and S3 for the data storage and ECS for the containerization of different modules. And so you can see all the technologies we're using. Okay, so what does this actually look like though? You know, it's easy to put this in words, what does it actually look like when we create it? And this is when you see how complex it can really be. So here's still yet a more detailed but still a simplified flowchart of how the platform works. So we have the automated framework that's put together after the user defines all the parameters. And then we use an S3 bucket where the raw read files from the user are deposited. And then the EC2 instance is spun up depending on the size and parameters that the user defines. And then this in parallel does the read alignments. So for a single cell sequencing experiment, this is looking at the unique molecular identifiers from each sample and replicates and looking at the read counts per gene at each individual cell level. And at the same time, there's some demultiplexing happening to identify which replicates and control groups each of those cells belong to. So for example, the saline group or the drug trigger group and is it from which mouse is it from mouse123 and also which patient is it from patient123. So all of that data is obtained and then some quality control is performed automatically and that's saved in an intermediate data storage bucket. And then with all of these read counts, these are integrated and unified into a Serot object in R. And this prepares it for single cell sequencing analysis. And then here in a modular approach, normalization is performed, some type of filtering is performed, variable features are identified and different types of clustering can be done. And this is also done on an EC2 interface. And then the results are then stored in an R object and then saved into a final results data bucket in S3. And then there's an interactive visualization component, which is also run via EC2 automatically. And here the user can explore the data in real time and customize their outputs and generate high quality publication ready figures. So to give you an idea of the different technologies being used, here is just the logos of each technology. So as I said, the overarching tool is built using Python, the Python backend. And then that Python code calls different modules, which itself can be Python or R. And in some cases like here for normalizing, filtering and clustering, we can use either R or Python. So it depends on which is more performant for the type of data and also which types of methods or statistical methods the user wants to run. And then also the final interactive platform is a mix of Python, R, Python, React and Flask. So this is a work in progress, this solution. Our goal is to create, follow this framework for this point and click analysis tool for a multitude of NGS experiments. So we're starting with single cell sequencing but this is something that can be expanded to other things like ATAC, C, ChIPC, O, Genome C and CRISPR screening and also integrating different modalities together. So the homogenous framework allows the integration of these different things such as single cell sequencing and CRISPR screening, for example. So in the interest of time here, I'm just gonna summarize. So in summary, so I showed you just a very high level look at a point and click analysis solution that we're building which leverages different web-based technologies to make it really abstract a user away from all the complexities of analyzing the data. And by using a modular approach, this is scalable across different experiments. So it can be tweaked to run, to analyze very unique experiments and inherently then it makes reproducibility really easy because that framework can be saved as a log file and you can easily go back and reproduce the data that was run later on and it increases efficiency and it's scalable for many forever growing sizes of NGS experiments and the full pipeline is automated. And this really reduces barriers to entry for NGS analysis and it just opens the door for many people to analyze their own data even if it's just a cursory look before they do some detailed analysis with seasoned bioinformaticians. So I just like to acknowledge our team which is basically myself and Megan who are working on this project. So Megan, Megan Chang is a R and Python developer by name but I like to consider her as a multi-technology extraordinaire because I can give her seemingly impossible tasks and she comes back with amazing results and if it wasn't for her, this project would still just be an idea on a whiteboard somewhere. So with that, I will try to stop the presentation so I can see the window again. Thank you so much, Piro. I think we have about two minutes for questions. I don't see any new questions in the Q and A so I'm gonna kick it off. So I think lowering the barrier of entry to doing NGS analysis is a completely painful gap in NGS analysis and omics analysis in general and really I think delays a lot of research for unnecessarily because you have to hand things off to your bioinformatics team and really you can't do it yourself or at least it's very difficult. So I think this is very welcome. What I'm wondering though is about reproducibility and whether having a point and click kind of interface is the right way to do this if you wanna have a reproducible workflow. So my question is, do you think there should be an sort of an opinionated, tidyverse inspired modular grammar for omics analysis and I'm thinking about something along the lines of tidy models where it's modular, it wraps a ton of different existing functionality in a consistent API and seems like the process would be amenable to pipes right and it would be great to have outputs like tidy tipples that to easily work with, GGPAR, GGS summary, Deplier. So I'm wondering if that's something that you think should be done, whether that's another way that you could think about this or whether your thoughts on having a tidy grammar for this. So you can do this stuff that point and clicky stuff programmatically. Yeah, that's a great question. And I think that is something that you need to be cognizant of when developing these kinds of tools. So I think there's several ways to tackle that. And yeah, having like tidy models is great. Tidy models is a great example. So I think if we had, let's say, something called tidy genomics on the spot thinking, I think something like that that defines how these different data objects are processed and defines different methods and acts as an API, like you said, will make it really scalable for all the new types of NGS modalities that are coming out and as sequencing gets cheaper, it's gonna encourage more people to incorporate larger and larger samples and replicates and integrate many different modalities. So I think something like that will be important. The way we're handling it is kind of a different approach, kind of having a controlled containers that specify. So we're using bi-conductor framework. So we're having, for the reproducibility aspect that you touched on, we're working with Docker containers that have locked versions of the different R packages or Python packages. So based on the log file that's created when you run the tool, and if you go back to it and if you load that log file, it'll spin up the correct container to make it reproducible because these kinds of tools are stuff. So as a biochemist and bioinformatician, these kind of point-of-click tools are something I've been working on for a while. And yeah, you can have packages update and it can really break everything and it's not so reproducible then. So yeah, that's something really important you have to consider.


Hi everyone, Joe for jaspyscasebrakes.com coming at you with 2021 Panini Prism draft picks football, random packed rake number 15. Big thanks to Todd and PJ for getting on this one. So, I actually need to get the, so we're here to get this. We go grab the box really quick and then we'll get this randomizer going. Be right back. All right, I'm back. And these are the last two boxes from that case that we popped open. I don't think we have any more. So break 15 will be one of these boxes and break 16 already on jaspyscasebrakes.com will be the last box. So now let's select, use that die right there. We'll go one, two, three for the left side, four, five, six for the right side. And it's three. So we're gonna do the left side right here. And this we will save for break number 16. So that'll be for RP, random packed number 16. Now let's pop this guy open, label the packs. And then we'll do the randomizer and see who ends up with what. Okey doke, let's flip back here. And now let's roll it, randomize it. Names and teams or names and pack numbers, five and a six, 11 times. One, two, three, four, five, six, seven, eight, nine, five, six, seven, eight, nine, 10 and 11 in final time, after 11. And then five and a six, 11 times for the pack numbers. One, two and 11 in final time. Four, two, one, three, five. So Todd you have pack one, PJ you have the rest. So Todd we're gonna do your pack first. And then we'll see what PJ has in his four packs. You print out the labels for this. Football, one box, random packed, the labels here. And let's roll. All right, so PJ you've got all the packs except for pack one. Todd, good luck. All it takes is one. The autograph to the back. We got JC Horne, 225. You got a DK Metcalf to 199. Silver T Higgins, a Crusade Trevor Lawrence, nice. Big Ben, Josh Kelly.  No, I'm not gonna get this. A debt, okunbo, a debtokumbo, there we go. A debtokumbo, ugandegi, got it, nailed it. Nailed it, 32 out of 49. There you go Todd. And then here is Trevor Lorenke right here. We got DK Metcalf and there's JC Horne right there. There you go Todd. Hopefully, I mean if that Notre Dame kid becomes a starter somewhere then I'll learn, isn't it? All right. There you go Todd. PJ, you've got the rest. 2354. 2354. There's gonna be weird not seeing Drew Brees on the field, but there he is. Drew Brees Red Wave, Baker Mayfield to 249. Alan Robinson, blah blah blah blah blah. Tom Brady and Shane Simpson. Here's your first autograph. All right, Red Wave Nick Bolton. We've got a Philip Rivers to 149. A Zach Wilson All-Americans Rookie Silver. It's pretty nice. It's toward love, Nick Chubb. And behind Nick Chubb is Milo Eiffler. Purple Ice, Rookie Autograph. And that's 71 out of 99. Will Fuller, there's a Joe Burrow Red to 299 in his college gear. And behind Jonathan Taylor is, is Dez Fitzpatrick. Fitzpatrick, Blue Ice, which is 74 out of 75. And the last one for PJ, good luck. There's a Monroe St. Brown. Terrence Marshall, 249. And behind Daryl Henderson is Chaz Sarat, North Carolina. And that is that, not numbered on this one. Thanks PJ, thanks Todd. Thanks everyone for watching. I'm Joe, I'll see you next time for the next break. Bye bye.


Okay, good morning students. Welcome to week four of our class on Managing Family for Paula Field are doing well One welcome to the E-learning students as well as you all have come in week after week to join us with the class Trust that you're keeping pace and are blessed by the course So we let's get started and I'll start with a word of prayer And then we'll do a quick recap of what we did last week and move on with our class for today So good morning. Good morning everybody. Good morning. She's a good morning. Nina, but that's the spring Emily father we thank you Lord for this new day. Thank you for your grace and your mercy over each one of us Thank you for sustaining us Lord through the last one week or we look to you even as we explore further things about Your foundation about marriage. We pray that You would give us open hearts give us open minds You would give us Lord the ability to unlearn things that we may have learned through our experience or Through teaching that's been erroneous father Lord We pray even as we look into your word that you would lift us up You would convict us you would help us Lord to live according to what you see now Thank you for the students who joined in pray Lord for those who are yet to come Lord pray for the each of the e-learning students as well Lord, thank you that you know each of them. You know their hearts Lord You know their ways God I pray that you will continue to bless and uphold each one in Jesus name I pray All right, so welcome once again So before we get started a quick Recap about what we did the last time we've been looking at the foundation of marriage looking at the biblical foundation the kind of Establishing what God has said about marriage and this institution and so we're looking to different kinds of topics and from here on We're getting specifically into More deeper core aspects about what's managers so before we get there Would would somebody like to recap about what we did last week anyone? What were some of the just pointers is is good enough at least one or two points one point per person can help us You know figure out that everyone has been awakened class and as he has also May probably right through some notes. Yes Different realms of compatibility Spiritual emotional intellectual physical and physical Okay, great. Thank you. Thank you Nina. All right anybody else We learned about how to make a choice and the warning signs Mm-hmm Okay, wonderful. Good one more person We saw what Isaac and Rebecca like from the story of Isaac and Rebecca We saw that it depends on the willingness of the person Hmm, and we also saw how to do the seeking Okay Wonderful. Good. Thank you. Thank you so much. So so the last chapter was all about Guidelines practical and biblical guidelines on how one makes a choice and we did look at as Nina said certain realms of compatibility How do you check to see whether you're compatible with others? You looked for red red planks or science that Signs that you would reconsider potential dangers on or potential problem areas that you would need to be careful about We also looked at how You know the concept of is there this one and only person that God's kept for me We answered that question through the story of Isaac and Rebecca We looked also at how God guides and what we could do how we could depend on God's guidance through his word Through the Holy Spirit as well as through the meaning of the mind and the reasoning God's given us and also be certain guidelines of how How it is important to stay prepared and it's not just about the wedding day day, but also What are the guidelines we keep during an engagement period and lastly spoke about single hood about what are some of the reasons for Singleness, okay. All right, great. So today we're going to be looking at chapter four and This is on page. I think in the book. It's different from The PDF which is on 38. So we're at 38 the book if you have the book with you. It is on 39. Okay, so Today we're going to like I said, we're going to get into a little bit more deeper into Into how and what what happens or what takes place in marriage and how through biblical understanding how we can navigate that and So we've been looking at oneness and how you build The the man and the woman coming together as one flesh So one way to progress into that place of unity or into that place of oneness is By fulfilling the roles that God has instituted in marriage, which is the roles for the husband as well as the wife So there are specific instructions that scripture gives on To a husband and to a wife on what their roles are towards each other Towards the family and towards marriage An institution as a whole. So what we're looking through this is to understand what God expects of the husband and wife and how the husband and wife can come together as well as be able to live the roles and and Really enjoy that process of marriage again So before we get there before we talk about it It's important that we establish a specific core or a specific truth that the Bible talks about in marriage which is what what is what we would find in first Peter was first Peter chapter 3 verse 7 and It is to establish the truth that both the husband and the wife are Equals and they are joint is the forgot So let's just read that scripture and then we will unpack that a bit put somebody Read first Peter chapter 3 verse 7 first Peter chapter 3 verse 7 anyone can unmute and read Anybody the same can you hear me? Yes? Yeah The same goes for you husbands be good husbands to your wives I'm reading from the message Translation which is in the book honor them delight in them as women they lack some of your advantages But in the new life of God's grace your equals Treat your wives then as equals so your prayers don't run aground Thank you. Thank you so much Nina. So if when we look at this this this is a An instruction that's given to to us to to the husband's and the wife's is That we need to consider each other as equals Why because in the sight of God God created us as co is we are co is with Christ And when we mean by co is is with all the gifts that he has released Onto us. Okay, so this means the husband and the wife As they stand before each other stand before God It is to know that they are equal. They are seen as co is Okay, because whatever it's he who gives the graces to us. It's him who gives the spiritual Grace to each one of us. So we are to look at each other as as equals Just like you would treat anybody else because we know that that's how God treats us God sees each of us as equals another aspect of this of the truth is seen in first Corinthians 11 11 to 12 now when you look at this verse, it specifically doesn't Pinpoint at marriage. Okay, it deals with other issues, which we're not really going to bring about here But the the two verses that's there it summarizes what the the interdependence or You know being being there for each other or ensuring that both walk together And are able to do things together depending on one another So they emphasize that God has designed the man and the woman to draw from each other to be able to be Interdependent with with one another So if you look at the verse and I'll read that out. It's from the Good News Bible again It's in the book in our life in the Lord However, woman is not independent of man nor is man independent of woman for his woman Was made from man in the same way man is born of woman and it is God who brings everything into existence so The good thing about marriage is the The fact that you can draw from each other's strengths and work together as one So it's it's not working parallely but drawing from each other Which means you're interdependent on one another So that's that's what we need to establish before we get into the roles of marriage that God has created each the man and the woman the husband and the wife to be equal to be a joint there and to be Interdependent on each other now even as we speak of this the Sometimes this concept of being cool equal and joint is Can some can be a bit challenging for men Especially when we come from a background or a cultural setting or a cultural background where Generally, you know, it's it's a patriarchal family where men are considered to be much more Important or much more superior than the women So it can be a challenge But what we need to look at is when we look at God's word, okay We we align ourselves to what scripture brings about to what scripture teaches us that we need to look at men or women The same way God sees us as equal God sees us of the same priority There isn't anyone that he considers better or greater or Superior inferior he's just created us different and as a result of which because of the difference is why there are different roles And not because the one is superior or one is inferior, right? So to be able to challenge This this understanding and align ourselves to what really God teaches us in scripture is what's important, okay? So since we've established That truth, let's get into dive straight into what are some Roles of the husband and the roles of the wife So when when we look at establishing these roles We are looking Even as we're looking at scripture if you would find that a lot of At times scripture brings about a parallel between Christ and the church the relationship or how The the relationship between Christ and the relationship between the husband and wife is Parallels to what Christ means to the church and the church to Christ. So even as we're looking at some of these References we will find that and we draw our meaning and we draw our understanding from this, okay, so just the way Christ Delt with the church and the church to submit to Christ is the same way It's the same picture that we build here even in marriages, okay? So let's look at some of these verses and from here. We will pick up some Roles that that scripture has specifically talked about, okay? So let's look at Ephesians 5 21 to 33 and I won't read the entire Chapter the entire portion, but I'd just like to probably Pick up Where exactly it's put and then you know kind of build from there So we will look at Ephesians 5 21 to 23 and some of the Roles that it brings about for the husbands we look at the husband's first and then we'll get looking at the wives Is in and I'll read out the verse and then you could probably end the line or just follow through. So I'm an Ephesians 5 Ephesians 5 verse 22, okay? So it says the husband provides a leadership to his wife the way Christ does to his church Not by domineering, but by cherishing. So we see we will unpack this In a lot more a little later But I just I just wanted to pick out some of those verses right and then we can talk about that So here you see that the husband is is a leader is has been called to lead the family because The Lord has placed the husband in a position to be the leader to to do the leading Okay, verse 25 of Ephesians 5 it says Husbands go all out in your love for your wives Exactly as Christ did for church did for the church a love marked by giving not Getting and if you look through the rest of the verses it talks of how the love of Christ makes the church whole and you could You know later just go through those verses meaning that The the love of Christ is what edifies and builds the church Okay, so husbands are called to love their wives verse 31 And this is why a man leaves father and mother and cherishes his wife No longer to they become one flesh.  So that's that in Ephesians 5 21 to 30 33 we look at Colossians 3 18 to 19 and Colossians 3 19 talks This is what it says husband's love your wives and do not be harsh with them again There is an emphasis on On loving okay, and we will talk about that a little later Then the next one is first Peter chapter 3 verse 7 It says be good husbands to your wives Honor them delight in them as women they lack some of your advantages But in the new life of God's grace you have equals treat your wives then as equals as your prayers don't run the ground That's a verse that we read up earlier. Okay, and verse 8 it sums up and it says be agreeable Be sympathetic be loving be compassionate be humble now That's an instruction. That's for everyone for a man for a husband and wife, okay? So that's what we just we just will cover in For roles of the husband. I'll just read through those verses again for the wife so that you know We kind of pinpoint and Understand the role of the wife. Let's go to Ephesians chapter 5 verse 22. It says wives Understand and support your husbands in ways that show your support for Christ here You can see the parallel again how how the wives are to support and understand and submit Just like you show your submission to Christ. Okay verse 24 of Ephesians 5 So just as the church submits to Christ as he exercises such leadership leadership Wives should likewise submit to their husbands. Okay, there again is the role of submission then verse 33 Ephesians 5 verse 33 and This provides a good picture of how each husband is to treat his wife Loving himself in loving her and how each wife is to honor her husband It's both of this are there in this both the role of the husband and the wife Looking to Colossians 3 verse 18 Wives submit yourselves to your husbands for that is what you should do as Christians Moving to first Peter chapter 3 verse 1 the same goes for you wives be good wives to your husbands Responsive to their needs. They are husbands who Indifferent as they are to any words about God will be captivated by your life of holy beauty So it's specifically showing of how you submit and yield to the to the husband. Okay Now these are passages all of these passages actually describe how high How the husband and the wife need to relate to one another and the standard is Comparing the relationship between Christ and the church. Okay, so and if you look at it They parallely run together. They actually speak about the same thing. All right now when we look at some of these verses sometimes, you know Where we ask him how do we do that? But it's God who empowers us to do this if when he's put the standard for us It is it is the Lord who will Who will give us the ability to obey and give us the ability to do according to what he has planned so the so what we need to do is to ensure that we walk or we Live lives that are in accordance to what God has desired of us and what God has planned for us So let's summarize some of this and if you look in the notes It's it's put up pretty clearly and we just look through some of them So the first one we said is love and if you see that's the husband's as well as the wife's role is to love Love their wives love their husbands So when when we look at the way Christ loved the church, we see the love of Christ from From the aspect of being unconditional Meaning there aren't any conditions for that love that it isn't I will love you I will love you if you love me back. It isn't that way Okay, it is it's a love that comes without looking for anything in return It's a love that is committed. It is a love that is always there. It's a love that is loyal So that's what we call as the agape love. You would know that When in English the word love Probably has just a single meaning But when you look at it in Greek, there are different terms of that love So the love the word love used here in this aspect where the husband loves the wife Is the word agape love which means unconditional love the way that Christ loved love the church where he sacrificed his life Without expecting anything in return. Okay, this kind of a love that you would see is described in first Corinthians chapter 13 verses 4 to 8, you know, the The chapter on love where it where it talks about how you love and that's the same love that the husband Shows to the wife. Okay, those are the characteristics and you could read that later The the love of Christ to his to his church is that of a sacrificial love a love that actually builds up and equips and enriches The wife and that's the love that the husbands are called to have to word survive the agape love the unconditional love Okay The second one that we look at is to be the leader to be the leader of the home now When you look in scripture, you will see that Christ has instituted man to be the leader and That's that's the structure of God's design for marriage, right? So in God's eyes The husband is placed In position above the wife not because of his abilities to do things But because it's it's a placement that he's he's put in he's Divinely placed the husband as the head and as the authority of the wife and the authority of the home Okay, and so this this comes when the So that and it is kept in such a way so that the husband is able to provide that Loving servant leadership to his wife and his family. Okay So that leadership comes from the example of Christ being the head of the church Okay, and the the leadership again is based on the example of Christ on on the way that Christ Leads the church. So when we look at the the The entire scripture you see the way how Christ dealt with people how how Christ is coming back for his church Right. So all of our examples are from the way Jesus deals with with with his sheep with his people and This this leadership the example of this leadership What you would see in society is Maybe is a very distorted form But when we are looking at a Christian marriage, it is based on the example of Christ Okay, so what does this leadership involve this leadership does involve In taking the responsibility for managing The home for providing for the home for for being able to meet the needs of the home to be able to make those important decisions to gather people at the home to also Be the leader be the spiritual leader of the home Okay, now the leadership of the husband Has to have the characteristic of love where the the husband is a loving leader and not an authoritative leader and you know If you remember, you know being back in school, you would probably have Have the greatest affection for a teacher who's firm right rather than the teacher who's who's extremely Authoritative right, but you would have a have a affection to a teacher who's firm who knows their boundaries yet to someone Who's able who's loving and who is caring in in the way that they interact so our husband earns the wives submission by being a person of by being a man of of a strong character of a strong Nature or of being able to be the right example So that's where that leadership come comes from now Being a leader a husband being a leader It may not mean that the husband may always be right and it is important that the husband walks humbling and is willing to take the The Opinions of his wife be able to take whatever points she may have for for any decision or for for any specific Instance taking her points or her opinions into consideration and be willing to acknowledge that That you know that that is that is also right So and that's what we see in scripture in Ephesians 5 21 we read that Being able to submit to one another so it comes from that where even that the husband can draw from the from the Expertise or the opinions of the wife and that it is perfectly okay because you are called to submit to one another Okay other Roles that you would say is you would see here is How the husband needs to nourish his wife nourishing means to be able to Speak into or to to ensure that they Encourage or strengthen or to empower them to be and to build themselves up To to follow through the purposes of what god has in store for the wife. Okay nourish also means to um to give to give to His wife In all all aspects be it physically be it emotionally be it spiritually nourish is to Is to help to grow is help to grow to a certain direction just like how you nourish a plant with what it needs Right, it needs water sunlight fertilizer so that it will it will grow it will it will thrive well and that's exactly what Husband is called to do to his wife The next one is to cherish cherish means to hold As something valuable just like how you'd give to give you'd get a gift that is probably quite expensive Or or a gift from somebody you really consider Consider close to you what you would do is you would cherish it right? You wouldn't let it to rot or you wouldn't let it here and there carelessly. So how does the husband a wife? Husband cherish his wife is by communicating to her is by Helping her see that she is she is valuable by helping her In in the everyday things of life Ensuring that there is a helping hand to her by being able to set an example of of Setting an example of how he pursues God, right? So these Again cherishes is also building together the relationship and bringing about intimacy So that is what a husband is called to do to cherish his wife the other two Things is how you know and honor the wife knowing and honor the wife is Knowing her is to really understand see what they like what they don't like what pleases them what displeases them knowing what their Their desires are what they would like to do. That's what knowing is to really engage with them So that so that the husband knows what exactly the person is Okay, the next one is honor honor the honoring them is to hold them in high regard or to or to really respect who they are as people and also to Hone their gifts or whatever talents that they carry. So this is what we've seen in in the husband The roles of the husband, okay? If you look at the book This is a very practical book. So if you look at the book, there are Certain places where you can you can actually think about ways You can fulfill these roles certain practical ways. You can fulfill these roles. So, you know, for those of you Who aren't yet married, you know, this is one way to do that And those of you who are, you know, you could build on whatever you're doing The next one we look at is the role of the wife. What is the role of the wife? Now the wife is also called to love the husband And this love if you if the word the greek word that you look at That the base comes from Is what is called the philia love the philia love is the love of a companion the love of a friend Okay, so this word is used to show that you are your husband's best friend or a companion or a helper Right and and you love like like you would love a companion And this comes again also from a From a place of unconditional acceptance to be able to accept them Despite their failures despite their shortcomings and this acceptance is not really You do not just accept them because they've done what they were supposed to do But you accept them because you recognize that they carry The their imagebearance they carry the worth and the dignity that gods put on them Okay, so not just not just accepting them for what they accomplish or what they do Or how they look but for uh for the worth that gods put inside of them the value that god has placed inside of them Okay, uh, even the love for Love of a wife to a husband is also sacrificial and it is demonstrated through your service demonstrated through your Your your place to be available or willing to help or to respond to the needs of the husband Okay, it's also being responsive to whatever needs that they may have that's where we see The love that comes for the wife's role The next we're going to look at is Being able to submit now what submission means to be able to yield to the husband and show that kind of support and show the kind of The fact that you are there to support and to help him along life's journey So this is again this comes from The the willingness to submit comes from the recognition that god is the one who's appointed the husband as the head over the home It comes from that obedience obediently submitting because you recognize that that's the placement that the husband has and and you stand in as a person who who Walks walks in submission to them So when you as a wife Submit what you are also doing is you are helping your husband to take on that specific role You're empowering your husband to take on the role of a leader. You're willingly Supporting and helping your husband fulfill that role because He's going to be called or he's going to be asked about What he's done is the way that he raises his family and as a wife It's important to be able to submit to that because of what god has placed the placement that he has it will free him Of of doing what he needs to do as a leader, okay? So we looked at what submission is. Let's also look at what submission Is not when it's where submission is definitely not being inferior Submission is not That you lose who you are your Your traits your the kind of person you are your desires It doesn't mean that that you lose your identity And it doesn't mean also blind obedience that you give yourself up to be abused or To be totally manipulated or used because of that role So it comes together. It comes hand in hand the submission and the leadership Comes hand in hand.  There is a role of submission of yielding to that leadership Okay, the last two is respecting respecting the husband and helping the husband. So respecting means to be able to hold with With honor holding up with honor. So it in the ways that it is practically seen is when You're you encourage and you appreciate and you're ensuring that you Celebrate the person that your husband is right through the differences that that you may see from you being able to celebrate and honor that it also means To Give encouragement to also Means to admire, you know, I this is something that I I read in a book of and I thought it's it's Really nice of how when you treat someone with respect There are three aspects of treating them. You need to have a head of respect You need to have a heart of respect and you need to have hands of respect So the head of respect is the way that you think about your husband Or the heart of respect is the way that you feel towards your husband And the hand of respect is what you do for your husband So it starts from the way that you think about your husband. So every time, you know Maybe something has gone wrong at home or you know, they don't they fall short of certain expectations You may have there are certain thoughts that keep running in your mind And that's important to change. That's important to renew You know to be able to think of him as a god-given gift to be to think of him as a Precious gift as a good thing that God's provided for you despite the differences that it is So it starts with the respecting head of respect and then moving on to the heart of respect So the more that you think about them as the way god thinks of them You will begin to feel a sense of love and respect and cherishing and Honoring and once you're able to feel that then you're able to serve them Genuinely serve them Well, okay, so just just those three aspects is something that may just just added And the fourth one is to be is to be a helper and helper is to stand as and as a comrade as an aid for needs by assisting by supporting and encouraging things that the husband does so These are these are the certain roles. So for the husband, it's to love It's to nourish to cherish to lead to know and to honor And for the wife, it's to love to submit to respect and to help Okay, now Even as we've read through this. Yes. God has given each of us a role and he has described how it should be It should be done. So What what we should be looking at is to continuously grow into being that kind of Spouse that God has ordained for us Despite the despite seeing the flaws or the limitations we have So when we see that when the spouse when the husband fulfills his role when the wife fulfills her role The the marriage is more in the way. God has designed it to be and it is and it works Towards unity and it works towards that Oneness. Okay. All right. I'll just stop here for any questions that Y'all may have any questions Or any thoughts you don't have to have questions you can give any thoughts maybe some things that You're new differently. You understood differently and maybe this has challenged you and Really stirred your heart. It doesn't have to be a question. It can also be a comment or a or a thought or a reflection There's some some interactions, but I know everybody's on the other side and awake Something that was really Helpful for me was about when you mentioned about the head of respect in the heart and the hand. So Many times We think like, you know, we have to do it and that's why we do it But when we really think highly of them like no matter what has happened or there might be some small things That might be going on but we don't think highly and we don't feel great And when we think it's not it's not it's not actually coming out of the heart and even Jesus is also displaced In the thing but when we actually know the truth, you know, it's God who wants me to respect and admire And it is God has given him certain values And it is because he has to fit into my thinking and my way of life But I just have to value him because God has given me the best and highly that feeling and that doing that was That was really useful to me That's nice. Yes, it's really touched my heart as well. That's I shared it Anybody else one more person? Yes, go ahead My name is Shantan I'm speaking to the women in class My affiliates, I wanted to say they come to do some reading now against men If you men do have a talk The part mostly they come to they can manage from this Anand you're not very clear. I'm sorry. I can't follow what you're saying Can you come closer to the mic Please Is it okay? Okay, just speak a little slower because I'm because it's a lot of echo. I'm not able to clearly hear just speak a little slower Okay, you're somebody else. I'm sorry. Okay. All right. I don't know who that is but Okay, I understood you're calling from class. Yeah, go ahead go ahead I Okay, is that anyone else who's understood the question because I I don't think I could have I have followed anyone else understood the question yeah yeah that's better yes once again what I want to say is when it comes to a marriage nowadays you see that there's usually a imbalance in and power from both husband and wife said as in what I want to say is that usually they used to be an equal amount to understand equal amount of respect but now it seems that from the wife side they need more power or more authority that they want to be the head rather than the husband and the husbands to what happens is that they become less you know that they become submissive under the husband it's not more like an equal share of power and equality between them is what I wanted to say okay okay thank you and who's speaking please it's I didn't hear ma'am again no no I heard I heard who's speaking my name is Sean Sean okay okay thank you Sean yeah so thank you so I mean I could hear you right now so you're right Sean that when you look at at the world today and especially if you if you look at a current culture that the kind of culture that that is being built up is you know with with with women being more you're getting into a workforce women you know with with a lot more of opportunities that are there for women yes women also are are doing well in life however the idea that they can do things you know without a man or they can do things without the instruction of a man has come as a result of a lot of wrong doctrines you know the kind of movements that are there speaking of you know women can do things without without the requirement of a man all of that brings about a severe division between men and women right and and then it becomes a very competitive kind of experience but the word of God you know is so graceful that he he wants each person man or woman to be able to grow according to the way he's created them right and for us to understand that and live by it is sure there is surely a blessing right when you see this entire structure I'd call it some kind of a structure like the husband being the head the woman being being submissive to the husband when that structure is is in play or is carried out as according to God's plan the blessing of the Lord is there when you see that this gets toppled and sometimes you would see it the other way where the woman is holding the greater authority and the man you know just just just buckles under that or doesn't take on the responsibility and then it becomes like a pattern you would see that there are challenges and consequences that come so what God has instituted is is in a way for everyone to have a blessing through that okay so what you did say is right and that that is what we see is evident and that's why we align ourselves to what God has spoken about we align ourselves to bring back and rebuild that kind of a structure and this structure again like I said does not show inferiority or superiority each person has a role and we play that role it's just like if you were in a company where you have a manager above you and you report to them there is a certain structure and that's that's usually my question to couples you know if in a company you know that there is a structure like this and you submit to that structure how much more we should be submitting to the structure that God has instituted in the family right because it's for the growth and the well-being of the family yeah so thank you Sean for that I think that is that was just a statement and it wasn't a question okay all right so um so if you know especially for for all of us who are married and those who are waiting to be married that is um on page um I think it's 45 on page yes yes you uh Anand or Sean whoever is on that side of the class also this is Rin speaking yes Rin yes go ahead Rin uh yeah it's just a comment um like what what I observed was from where um it says to love as Christ loves I mean obviously only God can show this kind of agape love and conditional love but like he wants us to implement that with with a partner with her husband and yeah that's something that's hard from both sides so yeah yeah you're right and that's why we look to God for the equipping and it's you're right that it is it is difficult it is hard but a lot equips okay um so for those of you all who are interested and you know I'd really challenge you all to do especially those who are married uh is to go through that that entire page on the first Corinthians 13 it talks about what love is and how you could express it to your spouse it says love is patient love is kind it's not jealous not arrogant not proud what are some practical ways in which you can do that and so if you would like to um you know do that it's like a small little assignment that y'all can do okay uh the next portion that we're going to be looking at is how um as ministry leaders or as people who um are involved in the church community or we are in in certain positions of leadership in the church and for all of us as ministers because we are all ministers right how what what is the responsibilities that we have is something that we will we will look at because there are a lot of verses that talks about um because we are much more accountable to God right when when we are following Christ when we are in a place where we are speaking into the lives of others um our accountability our standards are much greater so we will look at that when we come back um after a break so it's 10 49 10 15 or 9 o'clock we will be back in 10 minutes at 11 so you can grab yourselves a cup of coffee and come back see you soon


Welcome to the lecture on lexical analysis part 3. So, in part 1 we covered the basics of lexical analysis, the motivation etcetera and we covered the theoretical fundamentals, finite automata, regular expressions and transition diagrams in part 2. Today, we will continue a little more about transition diagrams and generation of lexical analyzers and then study lexical, you know lex which generates lexical analyzers. So, to do a bit of recap, transition diagrams are generalized deterministic finite automata, but there are a few differences. The edges may be labeled by a symbol, set of symbols or a regular definition. Some accepting states may be indicated as retracting states and when we reach a retracting state, we really do not consume the symbol which brings us to that particular state and then with each accepting state, there is an action which is executed when that state is reached. Typically, we use this action to return a token and its attribute value, but very important transition diagrams are meant for you know manual translation and not for machine translation. So, let us understand how exactly transition diagrams can be translated to lexical analyzers. So, the first transition diagram we will be considering is the one for reservoirs and identifiers. So, this is a fairly simple and straight forward transition diagram. We start in state 0 then on a letter, we reach state 1. We keep on consuming letters and digits in state 1 and when we finally, get some other symbol other than letter or digit, we reach state 2 where we return the token code say for the reserved word or for the identifier itself. So, how does this really translate to a program? So, the lexical analyzer you know is called get token and it returns a type called token. So, inside the lexical analyzer, we have two local variables my token and c. So, there is a while loop which runs until the end of file. So, which has a switch on the state. So, to begin with will always be in state 0 and then you know for this particular transition diagram will be in state 0 and as we read a character in state 0, if it is a letter we change to state 1, otherwise we report it as a failure that is because here the only legal character is letter and in state 1 we check whether it is a letter or digit after reading a character, if so we remain in the same state otherwise we switch to state 2. In state 2 we have actually we have got ready to announce a token. So, the symbol which brought us to state 2 is not consumed it is pushed back into the input the token is obtained by searching the table of tokens. So, if it is a reserved word then you know the reserved word token is returned by the search token and if it is an identifier then we simply get the string corresponding to the identifier put it in my token dot value and return my token. Similarly, when we want to write you know catch constants various types of constants hexa, octa etcetera, etcetera we start in state 0 and on little x or x we go to the hex constant part and on the octal digit we come to the octal part, we keep consuming digits here until we return a token. So, this is the scheme both for hexa digital and octal you know digits rather constants. So, this is fairly straight forward we remain you know if the character is a 0 then it is an octal constant. So, we go to state 4 and if it is not a 0 then it is a failure because it is an illegal character and in state 4 we check you know whether it is an x or x. So, it could be a hexadecimal constant or it could be an octal constant. So, instead you know if it is hexadecimal we go to state 5 and if it is octal then we go to state 9 and so the two constants hexadecimal and octal are separated by you know one of them the hexadecimal is prefixed by x whereas, the octal constant is not prefixed by x. So, if neither of these appear in the input then it is a failure. In state 5 you go on checking the for the hexadecimal digits and we go to state 6 on receiving a hexadecimal digit. We remain in state 6 until we get hexadecimal digits and then we either go to state 8 or state 7 depending on the qualifier presence or otherwise. So, here again you know we return the token called integer constant because hexadecimal constants are also integers. So, after and we evaluate the hexadecimal number and return its value as the attribute of the token. So, in state 9 we do something similar and check the octal digits here. So, and finally, we return into constant and the evaluated octal number as the token and its value. So, for integer constants it is even simpler any number of digits are consumed and then the qualifier or otherwise is checked and we return and into constant. So, the integer constants are very easy we check whether it is a digit otherwise it is a failure we consume digits and finally, in state 15 we get the we return the integer constant token along with its value. So, this is an overview of how the transition diagrams are translated into you know lexical analyzer programs, but there are some reality checks that must be done here. So, we actually saw program segments corresponding to different you know transition diagrams. So, these transition diagrams must be combined appropriately to make a big transition diagram and then that transition diagram will have to be translated to manually into a lexical analyzer program. Unfortunately, combining the transition diagrams is definitely not trivial and it is possible to you know one possibility is order the transition diagrams in particular order say transition diagrams for reserved words then constants then identifiers and operators. Try each of these transition diagrams in the in that order. So, in other words the programs are also listed exactly in that order. So, when there is a failure it goes to the next transition diagram and starts looking at that particular diagram. So, if this is followed you know it is fairly easy to program. However, this does not use the longest match characteristics in other word the word t h e n e x t would be an identifier and not a reserved word then followed by identifier e x t. So, it should not be rather, but what happens is if you actually order the transition diagram for identifier first the next would be an identifier, but if you order the reserved word transition diagrams first then you know you would have the reserved word then followed by identifier e x t. Really in reality it is better to use the longest match. So, in fact the next should be identifier rather than then followed by identifier e x t. So, how do we get this longest match the transition diagrams must be tried in you know all of them must be tried then all the matches must be recorded and the longest match must be used. So, if this is done or if the programmer is able to order the transition diagrams appropriately in either case the longest match can be used. Using lex to generate lexical analyzers really makes it easy for the compiler writer. So, we will see how this works in the next few slides. So, now you know so far we saw how to generate regular how to generate lexical analyzers you know manually using transition diagrams. This of that approach is fine as far as small lexical analyzers small languages are concerned. However, for professional languages such as c c plus plus java the lexical analyzers are very difficult to write by hand. So, there is a language and corresponding tool available for describing lexical analyzers. So, lex is such a tool available in unix. So, lex has a language for describing regular expressions which are at the heart of lexical analysis. So, you just write down you know all the regular expression specifications for each of the patterns that are used that we are going to detect in lexical analysis. Then it generates a pattern matcher for the regular expression specifications which are given to the lex tool and once it is done in the lex tool generates programs which are appropriate for the lexical analysis. We are going to see how this is done the general structure of a lex program is that you have definitions we will see what these are. Then we have what are known as rules and finally, we have user subroutines out of these definitions are optional, but rules and user subroutines are essential parts of a lex program or lex specification and on a unix system how do we use lex to create a lexical analyzer. So, you just type lex ex dot l and you create a c program by the name lex dot y y dot c then compile the program using g c c it produces e x dot o and e x dot o is your lexical analyzer which curves out tokens from its input. So, now let us see how exactly a simple lex program looks like and then go into some details. So, here is a comment lex specification for the example this is a c style comment and we do not have any definitions in this particular program. So, between these two percentage marks we have the patterns and then we have a little bit of you know user written code. So, this is very simple there is a main program which calls lex and there is a y y wrap program which wraps up the lexical analysis and in fact y y wrap hardly has anything unless we want some files to be closed explicitly. We want we will see examples of this little later coming back to the rules section or the patterns section. This is a pattern a dash z plus which stands for you know any of the letters a to z any number of times one or more. So, this is a set notation a you know a to z. So, all the characters a to z are in that set and a to z plus implies any of these characters any number of times ones are more times. So, if this pattern is detected then the echo statement generates you know echoes the pattern which is rather the text which is matching this pattern and then it prints out a new line character dot you know bar slash n indicates dot indicates any character, but new line and slash n indicates new line. So, if in the absence of a match here all other characters are actually matching here and we ignore them the semicolon is just empty code. So, it ignores all other characters. So, here is a sample. So, we have input here which contains both lower case and upper case characters, but the output filters and produces only the upper case characters. So, that is very easy to see. So, a to z plus matches all these w you know w e u etcetera etcetera and then for each of the matches it prints out the character switch match and followed by a new line and it ignores all other lower case or any number characters etcetera etcetera. The definitions section of the lex program it contains you know we have already seen regular definitions. So, they are similar to that there are regular definitions written here and there is also some code which can be included for initialization and other purposes. So, definitions are like macros and they are actually like short hands. So, and they have the fam name followed by its translation there are two simple examples here. The name digit really stands for the set 0 to 9 and the name number stands for you know the digit pattern which is defined here followed by digit star which implies 0 or more occurrences of digit. So, here we are writing a regular expression digit digit star and the digit part is defined here. So, these two together define a number as 0 to 9 followed by you know any one of 0 to 9 followed by any one of 0 to 9 0 or more times. So, that is the number and this is the you know definition for that number. So, when we use such definitions it becomes easier for us to write bigger regular expressions as we are going to see very soon. So, any code for initialization etcetera that we include here any variables that we want to use are all included between this percent bracket and present bracket. So, that is the initialization part. The rules part it contains the is the heart of any LEX specification or LEX program. It contains patterns and it contains C code. So, a line starting with white space or material enclosed in the percent bracket etcetera is C code. So, any C code lines are copied verbatim to the output to the generated C file they are not changed in any fashion and a line starting with anything else is a pattern drawn that is inside the rule section. So, pattern lines contain a pattern followed by some white space and then followed by some C code which is optional. So, that is here. So, there is a pattern followed by some white space then there is C code. So, this C code and the initialization C code are all copied exactly in the same order to the output C code file there is no change at all. So, what happens to the patterns? The patterns are nothing but regular expressions. They are first translated to NFAs then the NFAs are converted to DFA's. So, we have not studied the you know particular algorithm for optimization of DFA, but let me tell you that DFA's can be compressed and optimized. So, that they are compacted rather compacted and optimized the number of states of the DFA the number of transitions they make etcetera can all be made you know optimal and it so happens that you can find for the same language any other NFA or DFA will always be optimized to a particular unique DFA. So, these DFA's are stored in the form of a table and a driver routine as well. So, this is easy to understand the driver routine on a particular state looks up the table and then finds out what the action is and performs that particular action on that symbol. The action associated with the pattern is executed when DFA recognizes a string which brought you to that particular final state. So, once we reach a final state we may want to announce a token and that can be done with the help of this particular action. So, now let us go into details of the syntax of lex and then take up adequate number of examples to understand them. So, strings in lex are nothing but concatenation of various characters. So, integer then a 5 70 hello these are all examples of strings any symbols which actually you know can be put together and made into a string, but there are some operator symbols which need to be handled in a special way. So, for example the double code, the backslash, the square brackets, this carrot, etcetera, etcetera, star plus, mid, this you know bar, etcetera. They are all special operators we are going to understand their work and you know usage as we go on. So, to begin with the backslash is an escape character. So, if you want to use any its usage is similar to that of C. So, if you want to use any of these special characters in your string representation then you can say backslash question mark or backslash dot to get that particular dot as a character into a string. Now, very important notation is that of character classes. So, we have left bracket square bracket and right square bracket anything which is enclosed in between is a character class. So, inside only you know the backslash the dash and the carrot have special meaning all others are just characters inside the set notation. So, for example, the notation minus plus in one square bracket pair another pair contains 0 dash 9 plus.  So, this is a regular expression as you can see it starts with either minus r plus followed by you know any of the digits any number of times. So, similarly a to d 0 to 4 a to c. So, this says any character a to d followed by any of the let you know characters 0 to 4 and finally, any of the characters capital A to capital C. So, this is the set of characters corresponding to this regular expression notation. This notation says a character a, b, c inside the square brackets. So, this simply says it is a complement operator all characters except a, b or c. So, a, b, c as usual stands for a or b or c and a character in front complements the set and it says all characters except a, b or c and this includes all the special and control characters as well. So, two more examples plus backslash minus followed by 0, 5 plus. So, as I said this backslash really stands for the backslash minus really stands for the minus operator itself. So, it is either plus or minus. So, here the difference is minus started in the beginning. So, it was actually understood as the minus character, but here we wanted to make it the second character which cannot be done because it is used to you know used as when it is used as second character there should be a third character as well. So, to get rid of this problem we use a backslash in order to put this man in minus character. So, and the 0 to 5 plus is 0, 1, 2, 3, 4 or 5 plus. So, again character a to z, a to z says all characters which are not letters. So, this is a to z is all lower case characters, capital a to z is all upper case characters and the character complements them. So, it all characters which are not letters. So, that means you know the all the digits special characters etcetera all included in this set. There is a dot operator which matches any character except new line and the question mark operator is used to implement the epsilon or null string option. For example, a b question mark c stands for a followed by b or epsilon followed by c. Then we also have repetition, alternation and grouping characters. So, a b bar c d plus question mark e f star. So, this is a regular repetition which stands for. So, observe that we have used ordinary parenthesis and not the square brackets. So, a b is the string a b, c is the string c, d plus stands for d any number of times. Then the question mark says epsilon in place of any of these. So, that is bar epsilon and then the e f star says e f repeated any number of times. So, that is the e f star. So, this is the regular expression notation in the ordinary form whereas, this is the lex notation. There are context sensitivity operators as well slash then the carrot and dollar. So, if we use carrot as the first character of an expression, then the expression is matched only at the beginning of a line. So, for example, if you say carrot a b is the pattern on its own, remember the carrot character inside the square bracket has a different meaning. This is outside the square bracket. So, this means line beginning with a b. So, it is matched only if the line starts with a b, a b dollar the dollar is the end of line end of you know it matches only the last if the line ends with a b. So, dollar if the last character of an expression is dollar then the expression is matched only at the end of a line. So, then the look ahead operator is a little more complicated. We want to say that d o is a pattern which should be matched provided there is a pattern following it and the string matches this particular pattern. So, that is letter r digit star equal to letter r digit star comma. So, if this entire big pattern matches after the d o then d o is a pattern is a string which is to be pattern which is to be matched not otherwise. So, in that sense the slash operator is a look ahead operator which looks at all this the pattern which is following, but it does not consume the symbols which match the following pattern. It consumes only the two characters d and o the rest is going to be you know matched again after the d o matches finalized. What are the actions of lex for example, the default action is to copy input to output. So, those characters which are unmatched. So, if there is no match it just copies it to output. So, we need to provide patterns which really catch characters that is our purpose and what is caught is retained in the buffer y y text. So, echo actually empties the y y text into the output y y length contains the number of characters which are matched and whose character string is present in y y text. So, lex always tries the rules in the order written down and the longest match is preferred. So, remember we discuss this longest match requirement in the lexical analyzer and you know the transition diagram part. So, for example, here this is a word integer and here is a regular expression corresponding to any lower case character a to z plus. So, corresponding to it the integer is action 1 and corresponding to the second one is action 2. So, if you have a minor variation and we say it is integers, then really speaking integer there are several possible matches. Integer matches the first part, yes matches the second part. It is also possible to match the entire thing integers in the second with the second pattern as well. And since the longest pattern is always used it this is the pattern which actually matches our input integers. So, now let us start looking at several examples to understand how exactly lex performs its matching. So, in fact the files which contain these programs are all mentioned here e x 1 2 etcetera. So, they will all be available in the NPTEL repository and you can download them, compile them and execute them to see whether the output is generated properly, try with different variations and so on and so forth. So, for example, this is the program which we already saw. So, let us not discuss it once more. It captures all the uppercase characters in the input. So, a to z plus is printed out along with a new line. So, this is the input. So, all the uppercase characters are printed out along with new lines that is a fairly simple and straight forward program. So, let us take another simple example. So, the first pattern says you know beginning with any number of blanks 0 or more blanks followed by a new line. So, this is the pattern. So, in other words the simple explanation is all blank lines. So, they may contain a blank space character or they may contain only a new line character or they may contain several blank spaces followed by a new line. But in essence they must all be blank lines completely blank lines without containing any other character. So, if this is the pattern which is got it is ignored there is no action corresponding to it. Then remember the ordering of these as well. So, if it is a new line character the new line is echoed and the variable y y line number is incremented. Any other character apart from new line dot star any number of them is caught in the third pattern and when this matches it prints out y y line number corresponding to that particular line and y y text which matches the pattern dot star. So, this is printed out. So, the y y wrap routine does nothing it just you know is required for to complete some formality and in the main program we initialize y y line number to 1 and call y y legs. So, the way this operates the in the input all the blank lines are ignored and then since the longest match is suppose there are non blank lines containing other characters as well along with blanks. Then they would match this, but the new line will not match dot star as I told you dot matches only all characters except new line. So, all the characters all the lines which contain non blank characters will match this first for all the non blank characters except new line and this next for the new line character. So, between these two they print out the characters and also the line number. So, let us see how the input is transformed to an output. So, here is a non blank line this is another non blank line then we have a blank line.  So, overall there are 1, 2, 3, 4 and 5 non blank lines. So, we have 1 the first non blank line 2 followed by the second blank non blank line 3 the third 4 the 4 and finally 5 the 5th. So, remember the blank characters which are here you know in the input are also copied what is important is that they contain non blank characters. Suppose we had after this a couple of blanks followed by a b this particular line would still be written out as all this followed by 2 blanks or 3 blanks whatever is the in the present in the input followed by a b. So, the blanks in the non blank lines are all copied as they are, but if the input is a complete blank line for example, a third line here and the fifth line here they are complete blank they are not copied to the output they are ignored. So, this is what this was supposed to do all the non blank characters caught here the new line caught here, but all blank characters blank lines caught here. So, now the example becomes a little more complicated. So, here we have a code part in which we describe you know there is a declaration called file star decl file. So, we have declared a file variable for use in our actions later on and then we have a remember the this declaration is a user return code and it is enclosed in these two special markers following that are a number of declarations rather patterns.  So, whenever a declaration is caught it is printed out to a file called decl file which we have already declared and what is printed out the corresponding text corresponding you know which was matched. In the y y wrap routine we just call f close to close the declaration decl file variable and in the main program we open the decl file for write purposes and then call the lexical analyzer. So, let us look at the output and go back to the patterns after that. So, this is the input this is the you know matched output and this is the rejected input. So, as if you look at the matched input which is printed out as output.  Now, let us see what happens in the what is present in the input there are a number of you know variables here followed by semicolon then there is int a b comma float c d comma e f and then another set of characters another int g h t etcetera. So, in this input which seemingly seems to be meaningless there are actually some c type declarations. So, the purpose of the lex program that we are now going to discuss is to extract these meaningful c declarations from this seemingly meaningless input and the rest of it is ignored. So, this is the our exercise so let us see how we can do it. So, there are a number of short hand notations that we write down for example, blanks. So, blank or tab so observe the you know back slash escape character for tab. So, blank slash tab so blank or tab any number of times letter is any lower case letter a to z that is the notation for set anyway. The digit short hand is 0 to 9 then an identifier would be a letter r an underscore followed by a number of letter r digit r underscore any number of times. So, this is the standard you know pattern for identifiers that we know of any letter followed by letter or digit star, but we have also included the underscore here. Then we have a number which is one or more digits so digit plus this is the regular expression notation digit digit star then we permit an array declaration part which says an identifier followed by the left square bracket followed by a number followed by the right square bracket. So, observe that this is a pattern which uses patterns declared before. So, in other words for the array declaration part we must have a name followed by a number. So, that is exactly what we have in our output here name followed by a number name followed by a number etcetera. So, that is the array declaration part and then the short hand notation declaration part says either an array declaration or a simple name. So, the simple name is you know any name that we have already seen here for example, this G H T I R E D E H etcetera are all you know I sorry F U I R etcetera are all simple names. Then the declaration list basically it is a number of declarations. So, declaration part followed by any number of blanks then there must be a comma any number of blanks again and then you know followed by this entire thing declaration comma is repeated any number of times including 0 followed by declaration part. So, in other words we want to generate a list of declarations. So, this helps us in doing that then a complete declaration would be beginning with a resolved word int or float followed by a declaration list. So, this gives us something like this you know float C D comma a int G H T S G H W 37 etcetera. So, this is the int this is your declaration list containing either a name a simple id or an array declaration part. So, separated by these semicolons and ending with a sorry separating by commas and ending with a semicolon. So, each of these is a repeated as in any number of times. So, there is one declaration here another here third here. So, you can have as many of them as you wish. So, that is our declaration and then we have you know a the pattern in the rule section which is a declaration. So, here this is what we are looking at this is the declaration that we know of. So, any number of them. So, declaration whenever there is a match for the declaration it prints out that particular declaration. So, observe here each declaration has int or float followed by a declaration list. So, this is one declaration. So, whenever this declaration is followed by of course, a semicolon here. So, whenever this declaration is matched in the input it prints out that particular declaration into the declaration file all others are a characters which are ignored. So, now let us see how it works here. So, this sequence you know is a sequence of characters it is an identifier, but then suddenly ends with a semicolon. We are going to start processing it as a declaration only when it starts with int or float. So, this part is ignored. So, this starts very promisingly with an int then there is an identifier also and then there is a comma as well, but then suddenly you know instead of a semicolon we have a float. So, therefore even this sequence of characters is ignored and copied into the rejected part whereas, again it starts with a float. So, a new declaration pattern is you know going to start here and this happens to be a correct declaration because it says float c d comma e of semicolon. So, that part is separated out as a declaration. So, after the semicolon it ends. So, we start processing a new declaration if possible. So, this entire thing does not correspond to a declaration because it does not begin with int this begins with int. So, int g h t a s j h e w 37 f u i r comma g j 45 and semicolon this entire thing is a valid declaration it is copied to the output as valid. This is you know invalid. So, it is a rejected this is valid. So, it is copied here and this is invalid. So, this is also rejected. So, the example really shows that for processing or catching declarations in a programming language you know you can actually write lex programs for it even though we are going to do this more meaningfully using yag a little later. That is after we learn parsing we will see how to do all this using yag which is actually a more meaningful way. But it is not as if lex is less powerful lex can do quite a bit of work it can actually catch all the declarations in the program etcetera. That is simply because the declaration part of a program is really regular in nature you know it is corresponds to a regular language. Whereas, when we get into a nesting of statements and records etcetera it does not happen to be a regular language anymore and we will require a more complicated machinery. Now, we move on to the next example that we have that is the you know how do we combine identifiers, result words and then hex constants, oct constants, normal integers etcetera etcetera. So, I told you that this is a fairly intricate problem when we dealt with transition diagrams. So, let us see how you know you are writing a lex specification simplifies this problem and makes it easy for us to write the specification. So, this lex program also has an initialization code. So, we have a variable hex which is initialized to 0, variable oct which is initialized to 0 and variable regular which is initialized to 0. Then, we have a host of these patterns we will discuss them shortly. So, here are a host of these patterns corresponding to reserved words and then the other constants as well and finally, you know a main program which calls y y lex. So, let us also see the input and output and understand it before we discuss the patterns. So, obviously this is the input and this part is the output you or me happens to be a simple identifier it is caught as an identifier while is a reserved word. So, it is printed out as a reserved word. We have 0 3 4 5 l a. So, out of this it actually the 0 3 4 3 4 5 l happens to be an octal constant 229, but the a part is a simple identifier which is printed out as an identifier. Similarly, we have 4 5 6 u b the 4 5 6 u part is a normal integer 4 5 6 and the b is an identifier b here is a hex constant 0 x 7 8 6 you know l. So, this much is a hex constant 1 9 2 6 and then the h a b c part is an identifier and now watch this we have b followed by 0 x 3 4 here it is not recognized as b an identifier followed by a hex constant because of the longest match characteristic b followed by this entire sequence of 0 x 3 4 is actually matched against an identifier and it is denoted as an identifier. So, you know this is how the longest identifier match is useful in identifying various tokens. So, let us go back to the patterns and study them in full. So, here is a letter which is already well known a to z or a to z followed by r underscore. So, any little lower case or uppercase character r underscore is a letter for us digit is 0 to 9 digits is digit any number of times 1 or more digit number octal is just 0 to 7 0 1 2 3 4 5 6 r 7 digit hex would be 0 to 9 or a to f. So, any of these are hexa digits integer qualifier is u capital u lower case l or capital l blanks as usual blank or tab any number of times 1 or more. Now, we look at identifiers. So, letter followed by a letter or digit star. So, this is a well known regular expression for identifiers. Then we have integers digits followed by integer qualifier optional. So, this question mark remember implements epsilon. So, this is really speaking integer qualifier or epsilon digits followed by integer qualifier or epsilon would make up an integer. This constant is 0 followed by either this is remember this is square bracket x x square bracket. So, either little x or bigger x followed by hexa digits any number of times once or more followed by integer qualifier either you know or epsilon. So, we have any 0 followed by x followed by any number of x digits of course, integer qualifier is optional. Octal constant similarly is 0 followed by octal digits any number of times followed by integer qualifier optional. Then we have the reserved words if else while and switch. So, now we come to the rules section with a percent percent. So, for the 5 reserved 1 2 3 4 4 reserved words the action is simply print out the reserved word and then the identifier. So, since we have written down the reserved words and then the identifier the characters which correspond to these will never be matched against identifier. Whereas, if we have a word such as switches then even though part of it matches here it will be the longest match will be that of an identifier. So, if we place the identifier before i f that is the reserved words here be sure to try it out once these 4 will never match everything matches against the identifier. Now, the hexadecimal constants when they are caught the s k n f is used to read the integer inside the hexadecimal notation and print it out along with the text. Similarly, octal constants are converted to decimal constants using the scan f function and print it out. Integers are also converted to the normal integer the characters are converted to normal integer and printed out. Finally, any other character which is caught is ignored so dot or new line they are all ignored. So, this is what we just now went through. So, the patterns are all caught and the output is generated. So, let us look at the floating point numbers which are a little more complicated than normal integers. So, as usual we have the lexical analyzer program for floats in C the digits are 0 to 9 plus and then we have an exponent which is either big e or small e followed by plus or minus it is optional the sign is optional followed by digits. So, if we write e plus 9 or e 9 it amounts to the same number same exponent then the blanks blank tab or new line any number of times and floating qualifier is f, f, l, l. So, then there are the patterns. So, let us look at the output and then go back to the pattern itself. So, 1, 2, 3 then 3, 4, 5 dot dot 4, 5, 6, 5 dot 3. So, really the first output is generated here because we do not catch pure integers we do not catch anything which does not have a blank after a dot. So, this is ignored. So, 4, 5, 6, 5, 0.3 is you know optional integer part. So, this could have been a dot 3 as well 6, 7, 5, e minus is float with no fraction then 5, 23, 0.4 e plus 2 again with optional integer part. Next one is also with optional integer part 234.3.4 corresponds to 3.4 234 dot should have had a blank after that. So, it does not. So, that is ignored 3.5 dot has a blank. So, that is caught here as optional float with optional fraction then dot 3, 4 e plus 0 9 l is caught as an optional integer you know possibly no integer part here and similarly in 987 is without fraction and the last one with optional fraction. So, let us study the patterns here. So, these are the first part first one is digits followed by exponent followed by optional floating qualifier followed and then followed by blanks. So, remember the look ahead operator. So, this pattern is valid provided it is followed by blanks otherwise it is not valid. So, this will match float with no fraction. So, digits followed by exponent. So, this is and this of course, is optional. So, this corresponds to floats with no fraction. So, float with no fraction is here 987 e minus 6 f here we have a number of digits you know 0 to 9 star 0 or more time iteration here followed by a dot compulsorily. So, before the dot there can be an integer part or no integer part. So, this is optional integer part, but once there is an optional integer part we must definitely have digits followed by an optional exponent followed by an optional floating qualifier follow and of course, it matches only if there are blanks after that. So, the integer part is optional but the rest is compulsory at least the digits part is compulsory exponent is optional. Here we have digits followed by a dot followed by the optional fraction 0 to 9 star optional exponent optional floating qualifier, but followed by blanks compulsorily. So, these are the various patterns which match here. So, one with no fraction second one with optional integer part third one with optional fraction. So, these are the various outputs that we already looked at. So, let us look at another example which is used with the desk calculator as a lexical analyzer to generate a lexical analyzer for the desk calculator which we are going to study later. Number is 0 to 9 plus followed by a dot optionally. So, this is a dot or epsilon followed by 0 to 9 star sorry this is a this is r. So, this is the bar here which gives you two options. So, either 0 to 9 plus followed by a dot or 0 to 9 star followed by a dot then followed by a number of digits. So, the difference between the two is the integer part here is compulsory whereas, the fraction is not where here the fraction the integer part is optional, but the fractional part is compulsory. You cannot have both of them as optional otherwise you would have just a dot name is as usual a to z a to z followed by a to z a to z 0 to 9 star. So, this is the identifier part. So, when a number is caught it is converted to a number using a scan f and it returns a token called number. The value actually you know is here you know. So, that is read into a variable called y y l val dot d val which is a parser variable. So, I am introducing this example just to show how interfacing with yak happens. So, y y l val is a parser variable used by yak and this value of number is put into that variable. Whenever there is a name caught it is looked up in a symbol table and if the name is present you know that pointer is returned to is otherwise if the name is absent in the symbol table it is entered into the symbol table and the token name is returned. For plus plus we return post plus minus minus we return post minus for a dollar we return a 0 and new line or any other character is just written that simple character itself. So, this is just to show you that it is possible to do some symbol table operations along with name search etcetera inside a lex program as well. So, lex programs can become as technical and as complicated as we want them to be. So, with this background let us stop the lecture in the next lecture we will start studying parsers. Thank you.