Ver código fonte

- documenting the script syntax of the variable declaration
- printing an error message if the variable cannot be declared

Miklos Tirpak 17 anos atrás
pai
commit
41f2e49c2a
2 arquivos alterados com 17 adições e 5 exclusões
  1. 12 4
      cfg.y
  2. 5 1
      doc/cfg.txt

+ 12 - 4
cfg.y

@@ -1110,16 +1110,24 @@ assign_stm:
 	;
 cfg_var:
 	ID DOT ID EQUAL NUMBER {
-		cfg_declare_int($1, $3, $5, NULL);
+		if (cfg_declare_int($1, $3, $5, NULL)) {
+			yyerror("variable cannot be declared");
+		}
 	}
 	| ID DOT ID EQUAL STRING {
-		cfg_declare_str($1, $3, $5, NULL);
+		if (cfg_declare_str($1, $3, $5, NULL)) {
+			yyerror("variable cannot be declared");
+		}
 	}
 	| ID DOT ID EQUAL NUMBER CFG_DESCRIPTION STRING {
-		cfg_declare_int($1, $3, $5, $7);
+		if (cfg_declare_int($1, $3, $5, $7)) {
+			yyerror("variable cannot be declared");
+		}
 	}
 	| ID DOT ID EQUAL STRING CFG_DESCRIPTION STRING {
-		cfg_declare_str($1, $3, $5, $7);
+		if (cfg_declare_str($1, $3, $5, $7)) {
+			yyerror("variable cannot be declared");
+		}
 	}
 	| ID DOT ID EQUAL error { yyerror("number or string expected"); }
 	;

+ 5 - 1
doc/cfg.txt

@@ -338,9 +338,13 @@ declare any config variable, because other modules and the core may need the
 up-to-date config.
 
 
-6. Accessing the configuration values in the script
+6. Configuration values in the script
 ===============================================================================
 
+New configuration values can be declared in the script, the syntax is:
+
+<group_name>.<var_name> = <value> [descr <description>]
+
 The values can be accessed via select calls:
 
 @cfg_get.<group_name>.<var_name>