Esempio n. 1
0
 public BasicCppMacro(Token token)
 {
     Add (token);
 }
Esempio n. 2
0
        private void ParseCppMessage(Token directive, bool fatal)
        {
            var message = new TokenList (ConsumeCppDirective ());
            LogWarning (directive, message.ToString ());

            if (fatal) {
                throw new ApplicationException ("#error directive reached");
            }
        }
Esempio n. 3
0
 private void UnexpectedToken(TokenType expected, Token got)
 {
     throw new ApplicationException (String.Format ("Unexpected token {0} at [{1}:{2}]; expected {3}",
         got.Type, got.SourceLine, got.SourceColumn, expected));
 }
Esempio n. 4
0
        private void ParseCppDefine(Token define)
        {
            CppMacro old_macro = null;
            var new_name_token = CheckScan (TokenType.Identifier);
            var name = (string)new_name_token.Value;

            var new_macro = new CppMacro (ConsumeCppDirective ()) {
                Parent = new_name_token,
                InputName = InputName
            };

            if (ParserState.CppDefines.TryGetValue (name, out old_macro)) {
                LogWarning (define, String.Format ("\"{0}\" redefined", name));
                LogWarning (old_macro.InputName, old_macro.Parent, "this is the location of the previous definition");

                ParserState.CppDefines[name] = new_macro;
            } else {
                ParserState.CppDefines.Add (name, new_macro);
            }
        }
Esempio n. 5
0
 private void LogWarning(string inputFile, Token offender, string message)
 {
     Console.Error.WriteLine ("{0}:{1}:{2}: warning: {3}", PwdRelativePath (inputFile) ?? "Unknown",
         offender.SourceLine, offender.SourceColumn, message);
 }
Esempio n. 6
0
 private void LogWarning(Token offender, string message)
 {
     LogWarning (InputName, offender, message);
 }
Esempio n. 7
0
 private IEnumerable<Token> ExpandToken(Token token)
 {
     if (token.Type != TokenType.Identifier) {
         yield return token;
     } else {
         CppMacro macro = null;
         if (ParserState.CppDefines.TryGetValue ((string)token.Value, out macro)) {
             foreach (var node in macro) {
                 foreach (var expanded_node in ExpandToken (node)) {
                     yield return expanded_node;
                 }
             }
         } else {
             yield return token;
         }
     }
 }
Esempio n. 8
0
 public void SetBasicMacro(string name, Token value)
 {
     SetBasicMacro (name, new BasicCppMacro (value));
 }