#!/usr/bin/env python # Display today's UKCH food plans. # Adam Sampson import re, urllib, sys def extract_javascript(s): """Extract the contents of all ', s)) class JavascriptError(Exception): pass class JavascriptEngine: """An extremely limited Javascript interpreter.""" def __init__(self, js): self.js = js self.max = len(js) self.pos = 0 self.vars = {} def _match(self, s): """Skip whitespace, then try to match a string at the current position.""" while self.pos < self.max: if self.js[self.pos] not in " \t\r\n": break self.pos += 1 l = len(s) if self.max - self.pos < l: return False if self.js[self.pos:self.pos + l] == s: self.pos += l return True return False def _token(self): """Get the next token, skipping comments.""" comments = {"