Berkeley CSUA MOTD:Entry 52367
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2021/10/17 [General] UID:1000 Activity:popular
10/17   

2009/1/13-22 [Computer/Theory] UID:52367 Activity:kinda low
1/13    I am writing a commandline parser for a class and I could use some
        tips for algorithms to use. (The project is over and done so I am
        not cheating, but I am dissatisfied with my end result.) I STFW and
        didn't come up with too much I liked. I read the source for some
        shells like tcsh and that is *WAY* too complicated and relies on
        a lot of other code. I know that browsers and other apps have
        parsers, too. Is there some simple algorithm they use? I am more
        interested in algorithms than any implementation itself.
        \_ Are you looking for something like getopt?  Or is this more
           "read this line and figure out what programs to run/
            what outputs to pipe into other outputs"?  And what language
            are you using?
            \_ C language. I am interested in how something like getopt is
               designed in terms of its algorithm, particularly for multi-
               character options. Like how it distinguishes -v from -vv
               from -vvv for example? Does it read ahead? I am trying to
               do this without using other functions like strtok() but
               actually parsing a character at a time. I know I can go
               read the getopt source, but this is not that complicated.
               There must be some simple parsing algorithms these parsers
               implement.
               \_ You probably want a trie and a simple state machine.
               \_ Why would you do it a character at a time? Do you mean
                  you don't know how to implement something like strtok?
                  \_ Yes, that's what I mean. What algorithm does it use?
                     Are there better choices? What if I wanted to
                     implement a better strtok or a better getopt?
                     \_ Well, that's not really the interesting part.  If you
                        just look at strtok's header it wants you to specify
                        what constitutes a token delimiter.  So -v versus -vv
                        is pretty obvious I think...
        \_ I was once interested in parsing mathematical
           expressions.  However, rather than rolling my own, I just
           made use of python's expression parser.  This proved a good
           way to parse expressions with very little coding on my part:
           all I had to write was a little glue/wrapper.
        \_ Greed -- for lack of a better word -- is good.
           \_ why does gordon gecko get in more trouble than madoff?
        \_ If you're interested in this from a theoretical perspective,
           either take CS164 or try reading the Dragon Book. It's way
           overkill for basic command line parsing, but you said you were
           interested in the theory of parsing... that's what a lot of CS164
           is about.
           \_ What is the title of CS 164? Compilers?
           \_ What is the title of CS 164?
              \_ http://letmegooglethatforyou.com/?q=CS+164
              \_ Back in Spring '92 it was "Programming Languages and
                 Compilers".  I took it under Fateman.  We only learned a lot
                 about compilers, but very little about programming languages.
                 Other schools have separate classes for the two.
2021/10/17 [General] UID:1000 Activity:popular
10/17   

You may also be interested in these entries...
2013/5/1-18 [Computer/Theory, Computer/SW/Languages/Java] UID:54669 Activity:nil
5/1     What's the difference between CS and Computer Engineering?
        http://holykaw.alltop.com/top-ten-paying-degrees-for-college-graduates
        \_ One is science and the other is engineering.
        \_ From http://en.wikiquote.org/wiki/Computer_science
           'A folkloric quotation ... states that "computer science is no more
           about computers than astronomy is about telescopes."  The design
	...
2012/8/30-11/7 [Computer/SW/Unix, Computer/SW/Apps] UID:54470 Activity:nil
8/30    Is wall just dead? The wallall command dies for me, muttering
        something about /var/wall/ttys not existing.
        \_ its seen a great drop in usage, though it seems mostly functional.
            -ERic
        \_ Couldn't open wall log!: Bad file descriptor
           Could not open wall subscription directory /var/wall/ttys: No such file or directory
	...
2012/1/24-3/3 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc] UID:54296 Activity:nil
1/24    http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
        Amusing "history" of computer science.
        \_ Where's the mentioning of Al Gore the inventor of AlGorithm?
	...
2011/6/29-7/21 [Computer/SW/Database, Computer/SW] UID:54133 Activity:nil
6/29    "An Israeli algorithm sheds light on the Bible"
        http://www.csua.org/u/tq4 (news.yahoo.com)
        "Software developed by an Israeli team is giving intriguing new hints
        about what researchers believe to be the multiple hands that wrote the
        Bible."
        \_ "Hype developed by an American OnLine News Feed is giving
	...
2011/4/26-7/13 [Computer/Theory, Health/Women] UID:54095 Activity:nil
4/26    Is it correct to say that Godel's work on the incompleteness thm
        proved the Principia Mathematica wrong?
        \_ It didn't exactly prove it wrong; it proved that the true goal of
           PM (a complete and consistent set of mathematical truths)
           is unattainable.  -tom
           \_ Ah cool, no this is good. See ok yeah so the main goal of PM
	...
2010/8/23-9/7 [Computer/Theory] UID:53933 Activity:nil
9/20    Why does everyone talk about Turing but  nobody talks much about
        Babbage?
        \_ arithmetic vs algorithms
	...
2010/8/9-19 [Computer/SW/Security] UID:53917 Activity:nil
8/9     I got two files, one is size 522190848 and the other is size
        521648128.  Both sha256 to the same number.  (and sha1 too).
        I don't think this is supposed to happen, right? (least not with
        sha256).
        \_ how are you checking?
           \_ I burned one file to cd, so i mounted /cdrom and
	...
Cache (244 bytes)
letmegooglethatforyou.com/?q=CS+164
Advertise This is for all those people that find it more convenient to bother you with their question rather than google it for themselves. Inspired during a lunch conversation with @coderifous, @tmassing, @rmm5t, @EricStratton, and @methodvon.