Creating parsers using flex/bison - parsing

Hi I'm need to create a parser to parse search engine advanced query languages:
For instance: “food” language:es
I want to use Flex and Bison but I've never used them. I was wondering if anyone could point me to a good tutorial online, then it would be really helpful. I've been looking online but I didn't find anything useful.
Also, If anyone can provide any sample flex/bison code, I would really appreciate it.
Thanks so much in advance

I'm surprised you have been unable to find good tutorial's online, as the use of flex and bison and similar compiling tools are used in large numbers of computer science university courses world wide. As many people are learning them there are a large number of resources available. You must not have been using the right search terms. There are also numerous helpful tutorial videos on YouTube (including mine).
When I searched, this one came are the first result: http://aquamentus.com/flex_bison.html
The page suggested by #Bart Kiers http://dinosaur.compilertools.net/ is good too.

Related

F# - Resources for learning it from scratch

I appreciate there are a few posts out there, asking about F# tutorials/learning resources, but so many of the questions (and answers) assume a somewhat established knowledge or experience in C# or programming generally.
While I HAVE engaged in some programming, it's been very bitty and over many years. What I'm looking for is an F# tutorial, or series of tutorials, that walks you through from the very basics (a "complete" program that prints "Hello World!"), and progresses naturally while still showing you the complete solution. Most resources I've found cut out most things and just say "this is how you'd do it in C#, and this is now F#", leaving out other elements that complete the solution to the problem.
EDIT: I found the free course on F Sharp TV (udemy course), but didn't like how it was always exploiting F# Interactive to demo the language, as opposed to building an actually complete application.
I am very new to F#. I just started picking it up this month and I have really enjoyed it so far!
I can really relate to your question because every book or tutorial I've found assumed a lot more knowledge than I had. I would open them up start reading and then 3...2...1...and I was completely lost.
I'm sure once I am better at the language the references that are usually listed will be obviously superior to what I'm about to recommend.
One book I've enjoyed is "Functional Programming Using F#". It starts from the very, very basics and provides information about the small things in F# that I otherwise would have missed. The best part are the exercises at the end of the chapters, because someone went through all of them and posted answers here: [1]. So you can struggle through the exercises and then get an idea of how someone else approached the problem! The main drawback of this book is that the examples can be math heavy at times.
The second book I've used is called "Friendly F#". I really have never seen it linked or talked about, but I have thoroughly enjoyed it. I have found the approach the author takes to be rather novel. Instead of showing me how to implement the Fibonacci sequence in F# for the bajillionth time the author starts with projects! Real projects where you can actually visualize things! For example, in the first chapter you create an F# script where you visualize a ball bouncing in a box acted on by gravity! I know real coders are probably more worried about the esoteric features of the language but as someone starting out it was super motivating to actually be able to visualize something and more importantly to have something to show to my wife so she won't think I'm just wasting hours doing nothing. 😁
The last thing I'll recommend is Excercism. It's a great website where the tutors give great feedback. The only drawback is that you need to have somewhat of an idea of what the language can do. For me, I wasted countless hours trying to solve one of the problems only to realize that there is something called Seq.zip which would have solved the problem instantly. So, I recommend sitting down with a problem thinking hard on it for an hour and then googling "fsharp excercism solutions insert problem name here". Luckily, you can navigate directly to the solutions page and go through hundreds of solutions that other folks came up with. That's how I learned forever what Seq.zip is.
EDIT:
I also wanted to add this video [2]. It's not going to teach you all you need to know about F# in one video. However, it will give you a great overview of the language so while you are learning it in more depth you have an idea of what the language is capable of.
I hope this helps!!
[1] - https://github.com/TorbenRahbekKoch/Functional-Programming-Using-FSharp
[2] - https://www.youtube.com/watch?v=c7eNDJN758U
As mentioned in the comments, some might think this answer can be seen as opinion motivated. I feel that those resources could be a good entry point to learning more about the language.
Reference: sachabarbs.wordpress.com/1406-2
Reference en.wikibooks.org/wiki/F_Sharp_Programming
Bonus: Getting started with F# in the cloud with Azure, take a peek at this awesome reference!
Reference: Getting started with F# with Azure Notebooks
I would recommend first fsharpforfunandprofit.com - clearly a big starting point. You have the complete. This is a great section to "thibk functionally". https://fsharpforfunandprofit.com/series/thinking-functionally.html
When you get used to the language (a little bit), I would recommend "Stylish F#" . It is a very recent well written book on good practices for beginners (but who can write a bit of F#). Really liked it.

Best intro to dialects and parse?

I'm new to Rebol, and am working with a small corporate-based group to evaluate it for use in some areas that time and again have proven themselves highly resistant to change and to concepts such as DSLs.
Can anyone suggest what they have found to be a good intro to dialecting via "parse"? I have been reading the available docs from the Rebol 3 site, as well as the programmer's guide by Auverlot and Wood, and that may be more than enough -- but if anyone has suggestions for other related material or examples, I'd be appreciative of the advice.
PS: I'm also new to stackoverflow, and so don't yet have the magic 20 points for chat...
Some tutorials on parse:
9.3 Parse (REBOL's Answer to Regular Expressions)
Computer Programming Tutorial, by Nick Antonaccio
a parse tutorial sort of.
Dialecting from same guy:
9.21 Bindology, Dialects, Metaprogramming and Other Advanced Topics
Followed by some examples that show a few examples
If you search on Stack Overflow with the [parse][rebol] tags, you should have quite a few nice and simple examples, with lots of meaty explanations and comments about them.

Differences between (R)Unified Process And Extreme Programming

I've searched for at question like this and i dont think there are one.
As the title says... I know there are huge differences between how to do things in (R)UP and in XP as a way of developing systems, but what are the really?
I'm trying to write a nice explanation that i can give to other people so they hopefully easy can understand the differences.
I want to compare the following subjects:
Design
Documentation
Prototyping
User involvement
Usability
Technical quality
Test
I'm not trying to start a discussion, just want to know if you know any good sites that could have the information i'm looking for or if you have a answer for one of the subjects. I have allready written some of it myself but due to the fact that i dont want it to be a subjective comparison, i then ask you.
You might find this useful
XP vs RUP (pdf)
RUP and XP are not mutually exclusive. Comparing the two is like comparing apples and oranges -- you can enjoy both. Many companies following RUP choose to include some or all of XP practices.
For the basics, the wikipedia articles are a good start:
http://en.wikipedia.org/wiki/IBM_Rational_Unified_Process
http://en.wikipedia.org/wiki/Extreme_programming_practices

introduction to latex

what's a good website that has an introduction to latex for window users? I will be using it mainly to write math homework problems and probably then converting it to a PDF to print out. I'm hoping somebody has bookmarked a good link already so I don't have to search. Thanks!
You should start from this "not so short introduction to latex"
http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
I recommend this one: http://en.wikibooks.org/wiki/LaTeX
LaTeX works the same across platforms (and even across its distros, except some may provide features that others don't), so it doesn't really matter what your platform is.
I find that Andy Roberts's site is perfect for beginners, it has a lot of newbie exercises and takes you by the hand in a perfectly controlled fashion. It is my online reference for my basic latex questions.
http://www.andy-roberts.net/misc/latex/index.html
The LaTeX Community site doesn't seem to have any beginner tutorials, but it does have a number of articles that go into specific uses. If one of those articles covers what you're trying to do, then it may give you a headstart.
Outside tutorials, as a beginner getting into LaTeX, I found the TeXnicCenter Open Source IDE to be very useful. It makes life a lot easier when you get some syntax colouring and templates to help with common structures like tables.

Parsing, where can I learn about it

I've been given a job of 'translating' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to learn more about lexical analysis and parsers?
If you want to get "emotional" about the subject, pick up a copy of "The Dragon Book." It is usually the text in a compiler design course. It will definitely meet your need "learn more about lexical analysis and parsers" as well as a bunch of other fun stuff!
IMH(umble)O, save yourself an arm and/or leg and buy an older edition - it will fill your information desires.
Try ANLTR:
ANTLR, ANother Tool for Language
Recognition, is a language tool that
provides a framework for constructing
recognizers, interpreters, compilers,
and translators from grammatical
descriptions containing actions in a
variety of target languages.
There's a book for it also.
Niklaus Wirth's book "Compiler Construction" (available as a free PDF)
http://www.google.com/search?q=wirth+compiler+construction
I've recently been working with PLY which is an implementation of lex and yacc in Python. It's quite easy to get started with it and there are some simple examples in the documentation.
Parsing can quickly become a very technical topic and you'll find that you probably won't need to know all the details of the parsing algorithm if you're using a parser builder like PLY.
Lots of people have recommended books. For many these are much more useful in a structured environment with assignments and due dates and so forth. Even if not, having the material presented in a different way can help greatly.
(a) Have you considered going to a school with a decent CS curriculum?
(b) There are lots of online lectures, such as MIT's Open Courseware. Their EE/CS section has many courses that touch on parsing, though I can't see any on parsing per se. It's typically introduced as one of the first theory courses as language classification and automata is at the heart of much of CS theory.
If you prefer Java based tools, the Java Compiler Compiler, JavaCC, is a nice parser/scanner. It's config file driven, and will generate java code that you can include in your program. I haven't used it a couple years though, so I'm not sure how the current version is. You can find out more here: https://javacc.dev.java.net/
Lexing/Parsing + typecheck + code generation is a great CS exercise I would recommend it to anyone wanting a solid basis, so I'm all for the Dragon Book
I found this site helpful:
Lex and YACC primer/HOWTO
The first time I used lex/yacc was for a relatively simple project. This tutorial was all I really needed. When I approached more complex projects later, the familiarity I had from this tutorial and a simple project allowed me to build something fancier.
After taking (quite) a few compilers classes, I've used both The Dragon Book and C&T. I think C&T does a far better job of making compiler construction digestible. Not to take anything away from The Dragon Book, but I think C&T is a far more practical book.
Also, if you like writing in Java, I recommend using JFlex and BYACC/J for your lexing and parsing needs.
Yet another textbook to consider is Programming Language Pragmatics. I prefer it over the Dragon book, but YMMV.
If you're using Perl, yet another tool to consider is Parse::RecDescent.
If you just need to do this translation once and don't know anything about compiler technology, I would suggest that you get as far as you can with some fairly simplistic translations and then fix it up by hand. Yes, it is a lot of work. But it is less work than learning a complex subject and coding up the right solution for one job. That said, you should still learn the subject, but don't let not knowing it be a roadblock to finishing your current project.
Parsing Techniques - A Practical Guide
By Dick Grune and Ceriel J.H. Jacobs
This book (freely available as PDF) gives an extensive overview of different parsing techniques/algorithms. If you really want to understand the different parsing algorithms, this IMO is a better reference than the Dragon Book (as Parsing Techniques focuses entirely on parsing, while the Dragon Book covers parsing only as one - although important - part of the compiler construction process).
flex and bison are the new lex and yacc though. The syntax for BNF is often derided for being a bit obtuse. Some have moved to ANTLR and Ragel for this reason.
If you're not doing much translation, you may one to pull a one-off using multiline regexes with Perl or Ruby. Writing a compatible BNF grammar for an existing language is not a task to be taken lightly.
On the other hand, it is entirely possible to leverage any given language's .l and .y files if they are available as open source. Then, you could construct new code from an existing parse tree.

Resources