Esempio n. 1
0
 //=====================================================================
 /// <summary>
 /// Processes a line which appears to define a global function.
 /// identifier "(" identifierList ")"
 /// </summary>
 /// <param name="name">the name of the function, which has already been parsed</param>
 private void ProcessFunction(String name, String line)
 {
     FunctionDef f = new FunctionDef(Path.GetFileName(CurrentFileName), LineNumber);
     f.Name = name;
     f.Description = LastComment;
     LastComment = "";
     if (! ParseArgList(ref line, f))
         return;
     this.SymbolTable.GlobalFunctions.Add(f);
     this.CurrentSourceFile.GlobalFunctions.Add(f);
 }
Esempio n. 2
0
 //=====================================================================
 /// <summary>
 /// Writes a global function description.
 /// </summary>
 public void WriteFunction(StreamWriter w, FunctionDef f)
 {
     this.WriteThingWithDescription(
         w, f.Name, f.Parameters, null, f.Description,
         false, f.Source, null, null, false);
 }
Esempio n. 3
0
        //=====================================================================
        /// <summary>
        /// Destructively parses an argument list from the given string and
        /// puts the arguments in the given FunctionDef.
        /// </summary>
        /// <returns>true on success, false on error</returns>
        private bool ParseArgList(ref String line, FunctionDef f)
        {
            line = line.Trim();
            for (;;)
            {
                // if we're out of text on this line, fetch another
                if (line == "")
                    line = GetNextLine().Trim();

                // check what we have next
                String token = GetNextToken(ref line);
                if (token == ")" || token == "{")
                    break;
                if (token == "")
                    return false;
                if (token == "[")
                {
                    // [arglist] parameter - build the whole string
                    token = GetNextToken(ref line);
                    if (GetNextToken(ref line) == "]")
                        token = "[" + token + "]";
                }
                if (token == "?" && f.Parameters.Count != 0)
                    f.Parameters[f.Parameters.Count - 1] += "?";
                else if (token != ",")
                    f.Parameters.Add(token);
            }
            return true;
        }