Commit Graph

46 Commits (73a29daefd0d614ab0a86347fbead470810133c7)

Author SHA1 Message Date
Giel van Schijndel 1f4e369cf2 * Add a new struct-level qualifier: %csv-field-override
- This qualifier allows overriding of CSV field numbers given in base classes
  - This is required for the WEAPON stats because it differs from most other stats in that it doesn't have the "designable" field as the last CSV field
 * Specify all CSV field numbers for the fields in struct WEAPON
 * Generate SQL INSERT statements from weapons.txt


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6553 4a71c877-e1ca-e34f-864e-861f7616d084
2009-01-22 22:18:48 +00:00
Giel van Schijndel 3d92823e49 * Use the more readable $arrayreference->[$index] and $hashreference->{$key} instead of ${$arrayreference}[$index] and ${$hashreference}{$key} respectively
* Use 'my $var = $expression || "";' instead of 'my $var = ""; $var = $expression if $expression;'

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6366 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-23 13:32:02 +00:00
Giel van Schijndel d11d2411bd * Prevent writing to regex-capture variables, e.g. \$1
- Use a temporary variable instead


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6346 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-17 08:51:07 +00:00
Giel van Schijndel bec2172caa Allow passing of multiple strings for an enum value
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6339 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-16 17:25:40 +00:00
Giel van Schijndel 167510f3e7 * Add the option to specify custom string values for enums (which are * used when processing the database contents)
- New enum-field level qualifier: `%string "<string to use>";`
 * Use this to specify the custom strings for enum SENSOR_TYPE

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6335 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-16 16:28:17 +00:00
Giel van Schijndel 4e43102df3 Add the ability to retrieve the current row number by means of $rowNum
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6324 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-16 03:33:43 +00:00
Giel van Schijndel 1835d9aa04 Add a new code generator to generate a series of INSERT statements from the CSV files to fill a database with
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6322 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-16 02:20:42 +00:00
Giel van Schijndel d2c8fbc5a8 * Change the database meta language script parser such that it's first parameter has to be a valid relative path to the code generator to use
* Change the make rules for all files produced from the database meta language such that they have the language parser and code generator as dependency as well (i.e. if they change their files will be rebuilt)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6312 4a71c877-e1ca-e34f-864e-861f7616d084
2008-11-15 21:39:00 +00:00
Giel van Schijndel 2c8a322504 * Don't manually maintain a line-count variable as Perl does this (I found out while reading the Camel book) automatically in the $. variable
* Include the filename of the currently being parsed file in error messages
 * Make sure to reset Perl's line counter ($.) when we start parsing a new file (when using <> as file handle)


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6101 4a71c877-e1ca-e34f-864e-861f7616d084
2008-10-01 14:53:46 +00:00
Giel van Schijndel aad47ff640 Add a new struct level qualifier: %fetchByRow
* User code can use this to provide code that the SQLite code generator can use to get a pointer to some other struct
 * Make it so that you can only declare member fields with a `struct` type when the respective struct has a %fetchByRow directive in it
 * Generate loading code for struct-type fields in the c_sqliteload codegenerator by means of the code provided by the %fetchByRow directive


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5523 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 21:30:05 +00:00
Giel van Schijndel 9eb61150c0 Add a new datatype to the mini database schema meta language: `struct`
* Allows "linking" in the database to other struct instances
 * Will be represented as a pointer to the target struct in the C datastructures
 * Will be represented as an integer ID in tables


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5519 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 19:48:39 +00:00
Giel van Schijndel 2e5fab25f8 Attach line numbers to the AST of field declarations, and use it when reporting field-related errors
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5513 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 22:14:09 +00:00
Giel van Schijndel 65dee90e74 Accept all of ([US]D?WORD|[US]BYTE) as "transition" types in the mini database schema meta language
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5511 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 21:53:10 +00:00
Giel van Schijndel e33f083aaf Give errors when encountering unmatched struct-level and enum-level directives
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5510 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 21:48:34 +00:00
Giel van Schijndel 7f75a8f3c7 Add a new %nomacro directive to prevent macro definition of a struct and its children if the parent of that struct has a %macro directive
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5505 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 16:41:59 +00:00
Giel van Schijndel d8d2ad0dd6 Add a transition type "UDWORD" to the mini database schema meta language
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5501 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 15:30:32 +00:00
Giel van Schijndel 8ce0412a28 * Add new %macro, %macroprefix and %macrosuffix directives to the mini database schema meta language
* Generate macro definitions similar to our current "inheritance-like" structure as created by macros when the above %macro directive is used


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5498 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 14:02:17 +00:00
Giel van Schijndel 51370fcdbd Add a new enum-level directive: %valsuffix which (similar to %valprefix) adds a suffix to al enum's values
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5491 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 11:17:08 +00:00
Giel van Schijndel dc0aa99fac Allow empty value prefixes as well (using the %valprefix directive)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5486 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 22:23:19 +00:00
Giel van Schijndel b1d12b5a1a * Add a new enum-level qualifier: %valprefix; this changes the default prefix (which is just the enum's name with '_' appended) prefixed to all enum values
* Add a new enum that uses this: COMPONENT_TYPE


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5484 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:24:39 +00:00
Giel van Schijndel 87ad15af6a * Add a new struct-level directive: %suffix
- This directive adds a suffix to the names of structs (in the generated C code) and the subclasses that inherit from that struct
 * Use %suffix instead of %prefix in test_code.tpl


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5483 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:11:24 +00:00
Giel van Schijndel 2a11247d7e Add a new enum-level directive: %max "param":
* This will add an enumerator to the end of the generated C enum code with "param" as its name (prefixed by the enum's name of course)


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5482 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:02:58 +00:00
Giel van Schijndel 118a83f42a Slight change in syntax to not require (and disallow) a semi-colon after struct-level directives that open a new scope (terminated with "end\;"
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5480 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 20:52:09 +00:00
Giel van Schijndel c5b87954bc Add a new field type to the mini database scheme meta language: C-only-field
* This is a dummy type that causes the rest of the line to be included literally in the struct's definition
 * Use this field type to add ppIMDList (member var of BODY_STATS in statsdef.h)


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5460 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 20:47:17 +00:00
Giel van Schijndel db03e5b276 include (perl directive "require") code generators from the same directory as the language parser
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5450 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:15:44 +00:00
Giel van Schijndel 2e3280a845 Pass the output file as a command line parameter (and fall back to stdout if none is provided)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5446 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 16:05:41 +00:00
Giel van Schijndel 03cf003811 * Add line information to the AST of %preLoadTable and %postLoadRow struct-level directives
* Use these line numbers in the output of the SQLite C loading code generator to produce #line directives

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5443 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:25:46 +00:00
Giel van Schijndel f8f4ce0854 Make sure to count __all__ lines, also those who start a new "scope" (anything that finishes with "end")
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5439 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:58:04 +00:00
Giel van Schijndel 3b57831282 * Add line numbers to the AST for %loadFunc directives
* Utilize these line numbers to generate #line directives in the output file


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5438 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:47:16 +00:00
Giel van Schijndel 1ceafee327 Add line-counting code to the mini database scheme meta language parser
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5437 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:36:27 +00:00
Giel van Schijndel 74784e3f6e Add two new struct-level directives to the mini database scheme meta language:
* %preLoadTable which specifies a code block to be executed just __before__ loading in all rows in a database
 * %postLoadRow which specifies a code block to be executed after every row has been succesfully loaded in a struct


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5433 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:09:53 +00:00
Giel van Schijndel 2b6b037ade * Rename and modify the SQL SELECT statement code generator to a code generator that produces C code for loading in the contents of database tables
* Add a template file which is used by this new code generator as a file "header"
 * Add a new struct-level directive to the mini database meta scheme language: %loadFunc which specifies that the above code generator should generate a loading function for this type plus what its name should be
 * Add a new entry for this code generator to the Makefile for testing purposes


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5432 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:04:10 +00:00
Giel van Schijndel 40742f8d8a Give the code generators the ability to process command line arguments (before the parsing begins)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5431 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 12:46:53 +00:00
Giel van Schijndel 3f0b1959f2 For struct-fields of an enum type store references to the enum instead of just their name
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5430 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 12:16:55 +00:00
Giel van Schijndel 40b6a5acf7 Don't store the name of the struct we inherit from in the "inherit" field, instead store a reference to that struct
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5419 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-08 11:37:23 +00:00
Giel van Schijndel c07a24b90a Add some basic syntax/semantics checking to the parser of the database schema meta language.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5383 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-04 13:53:09 +00:00
Giel van Schijndel 191a130f86 Add a new field qualifier to the meta database schema language:
* "optional" which specfies that the given field is optional and can thus be NULL.
 * Only allow this keyword for the string and IMD_model types

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5381 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-04 12:51:09 +00:00
Giel van Schijndel abad9943c6 In the %field hash store the field-qualifiers as an array instead of storing only a single qualifier.
This will allow for adding multiple qualifiers to the same field later on.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5379 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-04 12:50:58 +00:00
Giel van Schijndel f31772dda3 Add IMD_model as a dedicated type to the mini-meta database schema language
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5376 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 23:21:45 +00:00
Giel van Schijndel 6e853b04d1 Don't print directly from the code generators, instead append to an output string for printing at a later time.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5374 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 21:51:23 +00:00
Giel van Schijndel a1cb6521fc "die" on a parsing error, don't just print "Unmatched line"
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5368 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:10:46 +00:00
Giel van Schijndel c6647ae996 Move duplicated looping out of the code generators
Move the duplicated effort of looping over all structs and enums out of the code generators and into the code that invokes the code generator. Thus instead of invoking the code generator once to generate code for all structs and enums, we now invoke it once for every struct and enum.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5367 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:10:36 +00:00
Giel van Schijndel 0814e56caa Add file headers and leaders to generated files
Give the code generators the opportunity to print something at the start and the end of the file. E.g. header guards for C files, and some notice about the file being automatically generated for all types.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5363 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:04:00 +00:00
Giel van Schijndel 505446f69a Don't process the "set" field type as a field qualifier. Instead rename and modify preProcessQualifiers and postProcessQualifiers to preProcessField and postProcessField respectively. These functions now parse the field's types as well as the field's qualifiers.
In addition we now also parse the "unique" keyword in set and enum lines and thus process it there as well.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5360 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 18:55:17 +00:00
Giel van Schijndel 3df34aeaa7 Rewrite the code generator and parser for the database metalanguage to perform less (or no) parsing in the code generators.
Instead we now have a two phase process:
 * First parse and build an abstract syntax tree (AST)
 * Secondly loop over the generated AST to produce useable code for the target language.

NOTE: Currently only the C struct definition generator is rewritten to this new architecture.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5359 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 18:55:06 +00:00
Giel van Schijndel 9db4235480 Add a code generator for my database meta-language
This code generator is still in a prototyping phase. It'll probably get rewritten entirely.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5358 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 18:45:32 +00:00