Lexical Scanning in Go - Rob Pike

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
7,463
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 30, 2011

Lexical Scanning in Go, a talk by Rob Pike at Google Technology User Group given on Tuesday, 30 August 2011.

The slides: http://rspace.googlecode.com/hg/slide/lex.html

  • likes, 2 dislikes

Link to this comment:

Share to:
see all

All Comments (9)

Sign In or Sign Up now to post a comment!
  • I wrote a lexer and parser API in Go, inspired by this presentation:

    github.com/iNamik/lexer.go

    github.com/iNamik/parser.go

  • where's Andrew's talk on using the new template system?

  • @jimmyrcom I see. Honestly, in this particular case it's just a matter of personal preference, the for-loop is "elegant enough" too.

  • @egcrosser They didn't want it in the language spec as far as I can remember. It's kinda funny too because you could see people pleading for it trying to describe exactly this type of situation. They were saying something like the stack trace is too important, use loops/gotos instead.

  • @vonschlesien You're right I didn't think the test functions would be so efficient as they are

  • @henriquedante Unicode is actually not a problem - Go as a language natively supports utf8 as its character encoding for the string type. For example, around 23:00-24:00, where you see "switch r = l.next() {...", r is the next rune in the output - i.e. the next unicode code point assembled through utf8 decoding. If you want to accept only upper case, just call the relevant test function from package unicode on the value of r :-)

  • I wonder if Go has tail call optimization. You might implement the construct described in minutes 14-15 as a tail call instead of a for-loop.

  • Main objection point is that you can't write this way if you're parsing unicode patterns. For example, what would be the accept() string for accepting upper case, lower case, etc. letters ? Nevertheless, the final scanner was extremelly clean and it must have been really fun to write.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more