Branch: Tag:

2001-02-09

2001-02-09 11:15:24 by David Norlin <norlin@roxen.com>

Handling of ::, lfun:: and predef:: in declarations.

Rev: lib/modules/Tools.pmod/AutoDoc.pmod/CExtractor.pmod:1.9
Rev: lib/modules/Tools.pmod/AutoDoc.pmod/DocParser.pmod:1.19
Rev: lib/modules/Tools.pmod/AutoDoc.pmod/PikeExtractor.pmod:1.6
Rev: lib/modules/Tools.pmod/AutoDoc.pmod/PikeObjects.pmod:1.8
Rev: lib/modules/Tools.pmod/AutoDoc.pmod/PikeParser.pike:1.8

21:    array(PikeObject) decls = ({});    string belongs = 0;    string appears = 0; -  int global = 0; +    }      constant EOF = .PikeParser.EOF;
584:    ++i;    tokens[0 .. i - 1];    MetaData meta = MetaData(); +  string scopeModule = 0; +  int global = 0;    foreach (tokens[0 .. i - 1], [string keyword, string arg])    switch (keyword) {    case "class":
610:       case "decl":    { +  int first = !meta->type;    if (!meta->type)    meta->type = "decl";    else if (meta->type != "decl")
622:       .PikeParser declparser = .PikeParser(arg);    PikeObject p = declparser->parseDecl( -  ([ "allowArgListLiterals" : 1 ]) -  ); // with constants/literals +  ([ "allowArgListLiterals" : 1, +  "allowScopePrefix" : 1 ]) ); // constants/literals + scope::    string s = declparser->peekToken();    if (s != ";" && s != EOF)    parseError("expected end of line, got %O", s); -  +  int i = search(p->name, "::"); +  if (i >= 0) { +  string scope = p->name[0 .. i + 1]; +  p->name = p->name[i + 2 ..]; +  if (!first && scopeModule != scope) +  parseError("@decl's must have identical scope:: prefix"); +  scopeModule = scope; +  } +  else if (!first && scopeModule) +  parseError("@decl's must have identical scope:: prefix");    meta->decls += ({ p });    }    break;
635:    if (meta->type == "class" || meta->type == "decl"    || meta->type == "module" || !meta->type)    { -  if (meta->global) +  if (global)    parseError("duplicate @global"); -  +  if (scopeModule) +  parseError("@global combined with scope prefix");    .PikeParser ucko = .PikeParser(arg);    if (ucko->peekToken() != EOF)    parseError("expected end of line, got %O", arg); -  meta->global = 1; +     }    else    parseError("@global not allowed here");
654:    parseError("duplicate @appears");    if (meta->belongs)    parseError("both @appears and @belongs"); +  if (scopeModule) +  parseError("both scope:: and @appears");    .PikeParser idparser = .PikeParser(arg);    string s = idparser->parseIdents();    if (!s)
672:    parseError("duplicate @belongs");    if (meta->appears)    parseError("both @appears and @belongs"); +  if (scopeModule) +  parseError("both scope:: and @belongs");    .PikeParser idparser = .PikeParser(arg);    string s = idparser->parseIdents();    if (!s && idparser->peekToken() != EOF)
698:    parseError("illegal keyword: @%s", keyword);    }    tokens = tokens[i ..]; +  if (scopeModule) +  meta->belongs = scopeModule; +  if (global) +  meta->belongs = "predef::";    return meta;    }    -  +     array(array(string)) getMetaDataOLD() { // OLD VERSION    // collect all meta info at the start of the block    int i = 0;