docs: function nonlocal_tokens(codestr, filename, options) {
    options = options || {};
  
    // get the base dialects for this file type:
    var fileext = utils.getFileExt(filename, "slisp");
    baseDialectNames = options.baseDialectNames || filetypes[fileext];
    if(!baseDialectNames) {
      throw new Error(filename + " is not a recognized sugarlisp file type.");
    }
  
    // note we manually ensure the lexer has the appropriate bases dialects below
    // (this is normally taken care of by reader.read_from_source() but not here)
    var lexer = new lex.Lexer(codestr, filename, {wrapOuterForm: 'no'});
  
    // we always bootstrap the core dialect which everything must have
    use_dialect('core', lexer);
  
    // And then add the extension dialects the file depends on
    baseDialectNames.forEach(function(dialectName) {
      use_dialect(dialectName, lexer);
    })
  
    // Just read each token and return them all...
    var token;
    var tokens = [];
    while(token = lexer.next_token()) {
      // we can't handle local dialects but at least we
      // can handle file level #used ones:
      if(token.text === "#use") {
        tokens.push(token); // push the "#use"
        tokens.push(lexer.next_token()); // push the opening quote
        var dialectNameToken = lexer.next_token();
        tokens.push(dialectNameToken);
        use_dialect(dialectNameToken.text, lexer);
      }
      else {
        tokens.push(token);
      }
    }
    return tokens;
  }