]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parse.c
Remove trailing whitespace from everything
[xonotic/gmqcc.git] / parse.c
diff --git a/parse.c b/parse.c
index 4b4f1e62a233cd051048a9bd331d23a7134af11f..c4fb8e056040c9de8d789d7e77a78ecbcc716c55 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 
+ * Copyright (C) 2012
  *     Dale Weiler
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -48,34 +48,34 @@ void compile_constant_debug() {
  * Generates a parse tree out of the lexees generated by the lexer.  This
  * is where the tree is built.  This is where valid check is performed.
  */
-int parse_gen(lex_file *file) {    
+int parse_gen(lex_file *file) {
     int     token = 0;
     while ((token = lex_token(file)) != ERROR_LEX && file->length >= 0) {
         switch (token) {
             case TOKEN_TYPEDEF: {
                 char *f; /* from */
                 char *t; /* to   */
-                
-                token = lex_token(file); 
+
+                token = lex_token(file);
                 token = lex_token(file); f = util_strdup(file->lastok);
-                token = lex_token(file); 
+                token = lex_token(file);
                 token = lex_token(file); t = util_strdup(file->lastok);
-                
+
                 typedef_add(file, f, t);
                 mem_d(f);
                 mem_d(t);
-                
+
                 token = lex_token(file);
                 if (token == ' ')
                     token = lex_token(file);
-                    
+
                 if (token != ';')
                     error(file, ERROR_PARSE, "Expected a `;` at end of typedef statement");
-                    
+
                 token = lex_token(file);
                 break;
             }
-            
+
             case TOKEN_VOID:   goto fall;
             case TOKEN_STRING: goto fall;
             case TOKEN_VECTOR: goto fall;
@@ -85,20 +85,20 @@ int parse_gen(lex_file *file) {
             fall:;
                 char *name = NULL;
                 int   type = token; /* story copy */
-                
+
                 /* skip over space */
                 token = lex_token(file);
                 if (token == ' ')
                     token = lex_token(file);
-                
+
                 /* save name */
                 name = util_strdup(file->lastok);
-                
+
                 /* skip spaces */
                 token = lex_token(file);
                 if (token == ' ')
                     token = lex_token(file);
-                    
+
                 if (token == ';') {
                     /*
                      * Definitions go to the defs table, they don't have
@@ -108,12 +108,12 @@ int parse_gen(lex_file *file) {
                     token = lex_token(file);
                     if (token == ' ')
                         token = lex_token(file);
-                    
+
                     /* strings are in file->lastok */
                     switch (type) {
                         case TOKEN_VOID:
                             error(file, ERROR_PARSE, "Cannot assign value to type void\n");
-                            
+
                         /* TODO: Validate (end quote), strip quotes for constant add, name constant */
                         case TOKEN_STRING:
                             if (*file->lastok != '"')
@@ -133,13 +133,13 @@ int parse_gen(lex_file *file) {
                             float compile_calc_z = 0;
                             int   compile_calc_d = 0; /* dot?        */
                             int   compile_calc_s = 0; /* sign (-, +) */
-                            
+
                             char  compile_data[1024];
                             char *compile_eval = compile_data;
-                            
+
                             if (token != '{')
-                                error(file, ERROR_PARSE, "Expected initializer list {} for vector constant\n");    
-                            
+                                error(file, ERROR_PARSE, "Expected initializer list {} for vector constant\n");
+
                             /*
                              * This parses a single vector element: x,y & z.  This will handle all the
                              * complicated mechanics of a vector, and can be extended as well.  This
@@ -188,7 +188,7 @@ int parse_gen(lex_file *file) {
                                 compile_calc_s = 0;                                                                                                                        \
                                 compile_eval   = &compile_data[0];                                                                                                         \
                                 memset(compile_data, 0, sizeof(compile_data))
-                            
+
                             /*
                              * Parse all elements using the macro above.
                              * We must undef the macro afterwards.
@@ -197,14 +197,14 @@ int parse_gen(lex_file *file) {
                             PARSE_VEC_ELEMENT('y', y);
                             PARSE_VEC_ELEMENT('z', z);
                             #undef PARSE_VEC_ELEMENT
-                            
+
                             /* Check for the semi-colon... */
                             token = lex_token(file);
                             if (token == ' ')
                                 token = lex_token(file);
                             if (token != ';')
                                 error(file, ERROR_PARSE, "Expected `;` on end of constant initialization for vector\n");
-                                
+
                             /* add the compile-time constant */
                             compile_constants_add((constant){
                                 .name   = util_strdup(name),
@@ -218,7 +218,7 @@ int parse_gen(lex_file *file) {
                             });
                             break;
                         }
-                            
+
                         case TOKEN_ENTITY:
                         case TOKEN_FLOAT: /*TODO: validate, constant generation, name constant */
                             if (!isdigit(token))
@@ -236,7 +236,7 @@ int parse_gen(lex_file *file) {
                 }
                 mem_d(name);
             }
-                
+
             /*
              * From here down is all language punctuation:  There is no
              * need to actual create tokens from these because they're already
@@ -261,10 +261,10 @@ int parse_gen(lex_file *file) {
                         token = lex_token(file);
                     if (token == '\n')
                         return error(file, ERROR_PARSE, "Invalid use of include preprocessor directive: wanted #include \"file.h\"\n");
-                        
+
                     char      *copy = util_strdup(file->lastok);
                     lex_file  *next = lex_include(file,   copy);
-                    
+
                     if (!next) {
                         error(file, ERROR_INTERNAL, "Include subsystem failure\n");
                         exit (-1);
@@ -283,7 +283,7 @@ int parse_gen(lex_file *file) {
                 while (token != '\n')
                     token = lex_token(file);
                 break;
-                
+
             case LEX_IDENT:
                 token = lex_token(file);
                 break;
@@ -301,4 +301,4 @@ int parse_gen(lex_file *file) {
                mem_d(compile_constants_data);
        }
     return 1;
-}    
+}