1 //===-- ResourceScriptToken.h -----------------------------------*- C++-*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===---------------------------------------------------------------------===//
10 // This declares the .rc script tokens and defines an interface for tokenizing
11 // the input data. The list of available tokens is located at
12 // ResourceScriptTokenList.h.
14 // Note that the tokenizer does not support comments or preprocessor
15 // directives. The preprocessor should do its work on the .rc file before
18 // As for now, it is possible to parse ASCII files only (the behavior on
19 // UTF files might be undefined). However, it already consumes UTF-8 BOM, if
20 // there is any. Thus, ASCII-compatible UTF-8 files are tokenized correctly.
22 // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx
24 //===---------------------------------------------------------------------===//
26 #ifndef LLVM_TOOLS_LLVMRC_RESOURCESCRIPTTOKEN_H
27 #define LLVM_TOOLS_LLVMRC_RESOURCESCRIPTTOKEN_H
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/Support/Error.h"
39 // A definition of a single resource script token. Each token has its kind
40 // (declared in ResourceScriptTokenList) and holds a value - a reference
41 // representation of the token.
42 // RCToken does not claim ownership on its value. A memory buffer containing
43 // the token value should be stored in a safe place and cannot be freed
48 #define TOKEN(Name) Name,
49 #define SHORT_TOKEN(Name, Ch) Name,
50 #include "ResourceScriptTokenList.h"
55 RCToken(RCToken::Kind RCTokenKind
, StringRef Value
);
57 // Get an integer value of the integer token.
58 uint32_t intValue() const;
60 StringRef
value() const;
69 // In case no error occured, the return value contains
70 // tokens in order they were in the input file.
71 // In case of any error, the return value contains
72 // a textual representation of error.
74 // Tokens returned by this function hold only references to the parts
75 // of the Input. Memory buffer containing Input cannot be freed,
76 // modified or reallocated.
77 Expected
<std::vector
<RCToken
>> tokenizeRC(StringRef Input
);