| 1938 | } |
| 1939 | |
| 1940 | bool HLSLParser::ParseTopLevel(HLSLStatement*& statement) |
| 1941 | { |
| 1942 | HLSLAttribute* attributes = NULL; |
| 1943 | ParseAttributeBlock(attributes); |
| 1944 | |
| 1945 | int line = GetLineNumber(); |
| 1946 | const char* fileName = GetFileName(); |
| 1947 | |
| 1948 | HLSLType type; |
| 1949 | //HLSLBaseType type; |
| 1950 | //const char* typeName = NULL; |
| 1951 | //int typeFlags = false; |
| 1952 | |
| 1953 | // TODO: this cast likely isn't safe |
| 1954 | HLSLToken token = (HLSLToken)m_tokenizer.GetToken(); |
| 1955 | |
| 1956 | bool doesNotExpectSemicolon = false; |
| 1957 | |
| 1958 | // Alec add comment |
| 1959 | if (ParseComment(statement)) { |
| 1960 | doesNotExpectSemicolon = true; |
| 1961 | } |
| 1962 | else if (Accept(HLSLToken_Struct)) { |
| 1963 | // Struct declaration. |
| 1964 | |
| 1965 | const char* structName = NULL; |
| 1966 | if (!ExpectIdentifier(structName)) { |
| 1967 | return false; |
| 1968 | } |
| 1969 | if (FindUserDefinedType(structName) != NULL) { |
| 1970 | m_tokenizer.Error("struct %s already defined", structName); |
| 1971 | return false; |
| 1972 | } |
| 1973 | |
| 1974 | if (!Expect('{')) { |
| 1975 | return false; |
| 1976 | } |
| 1977 | |
| 1978 | HLSLStruct* structure = m_tree->AddNode<HLSLStruct>(fileName, line); |
| 1979 | structure->name = structName; |
| 1980 | |
| 1981 | m_userTypes.PushBack(structure); |
| 1982 | |
| 1983 | HLSLStructField* lastField = NULL; |
| 1984 | |
| 1985 | // Add the struct to our list of user defined types. |
| 1986 | while (!Accept('}')) { |
| 1987 | if (CheckForUnexpectedEndOfStream('}')) { |
| 1988 | return false; |
| 1989 | } |
| 1990 | |
| 1991 | // chain fields onto struct |
| 1992 | HLSLStructField* field = NULL; |
| 1993 | if (!ParseFieldDeclaration(field)) { |
| 1994 | return false; |
| 1995 | } |
| 1996 | ASSERT(field != NULL); |
| 1997 | if (lastField == NULL) { |
nothing calls this directly
no test coverage detected