Exemplo n.º 1
0
        private static void HandleInclude(List <token> ret, List <token> tokens, int i, Dictionary <string, List <token> > defines, Program.IncludeFileLocator file_locator)
        {
            token file_name = tokens[i].parameters[0];

            if (file_name.value == "<")
            {
                file_name = new token {
                    type = token.token_type.identifier, value = tokens[i].value.Split(' ', '\t')[1].Trim()
                }
            }
            ;
            if ((file_name.type != token.token_type.identifier) && (file_name.type != token.token_type.string_literal))
            {
                throw new Exception();
            }

            bool search_cur_dir = false;

            if (file_name.value.StartsWith("\""))
            {
                search_cur_dir = true;
            }
            string fname = file_name.value.Trim('\"', '<', '>');

            string file_text = file_locator.ReadFile(fname, search_cur_dir);

            ret.AddRange(Process(file_text, defines, file_locator));
        }