Return to Video

04-62 Conclusion

  • 0:00 - 0:02
    You've just learned how to encode a grammar
  • 0:02 - 0:04
    for HTML and JavaScript,
  • 0:04 - 0:06
    and that is no mean feat.
  • 0:06 - 0:08
    In fact, a number of years ago,
  • 0:08 - 0:11
    for my research, I had to do something similar--
  • 0:11 - 0:13
    but for perhaps an evil or more production,
  • 0:13 - 0:16
    more popular language--Java.
  • 0:16 - 0:18
    We wanted to analyze Java programs,
  • 0:18 - 0:20
    to look for particular errors
  • 0:20 - 0:23
    and there weren't really any convenient parsers
  • 0:23 - 0:25
    available at the time.
  • 0:25 - 0:27
    So I was faced with a decision:
  • 0:27 - 0:29
    Should I use a tool that didn't really fit the bill?
  • 0:29 - 0:31
    Or should I try and write my own?
  • 0:31 - 0:34
    And I thought, boy, Java's a Real World production language;
  • 0:34 - 0:37
    it's got to be really hideous to write down a parser for it--
  • 0:37 - 0:41
    I'm sure its grammar is really hard to follow.
  • 0:41 - 0:44
    So I figured I'd give myself a day to look at the official Java grammar
  • 0:44 - 0:46
    and try to write a parser for it,
  • 0:46 - 0:49
    using the same sorts of techniques we've covered in this class.
  • 0:49 - 0:51
    Imagine my surprise, when it turns out
  • 0:51 - 0:54
    that the official Java language specification
  • 0:54 - 0:57
    actually uses the same sort of format--
  • 0:57 - 1:00
    the same sort of context-free grammar that we've been going over here.
  • 1:00 - 1:02
    In fact, if you'll take a look,
  • 1:02 - 1:04
    their handling of if-then-else statements
  • 1:04 - 1:06
    or argument lists
  • 1:06 - 1:08
    should look very familiar to you.
  • 1:08 - 1:11
    It's, more or less, exactly what we covered for JavaScript.
  • 1:11 - 1:14
    And I ended up writing a parser
  • 1:14 - 1:16
    for Java 1.1 at the time--
  • 1:16 - 1:19
    this was many years ago--that worked for our research.
  • 1:19 - 1:21
    I was able to make a tool that fit me,
  • 1:21 - 1:23
    even though there was none available,
  • 1:23 -
    using exactly the sort of techniques that you have just mastered through.
Title:
04-62 Conclusion
Description:

dummy description

more » « less
Video Language:
English
Team:
Udacity
Project:
CS262 - Programming Languages
Duration:
01:28
Amara Bot added a translation

English subtitles

Revisions