Commit Graph

48 Commits (f6853ed368c3ba81c346884df4cf3f4c23e0da08)

Author SHA1 Message Date
Giel van Schijndel b5ff9610ea * Remove TODO comment about needing to add an IMD_Model type, because that type already exists
* Add a comment, describing the `flameModel` field


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5465 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 11:03:39 +00:00
Giel van Schijndel a80776b9fa don't use the file header template if it isn't available in the c_structdef code generator
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5464 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 10:58:13 +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 1170798c66 Add a field to hold a component's body points (COMPONENT now fully matches COMPONENT_STATS from statsdef.h)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5458 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 19:17:19 +00:00
Giel van Schijndel c6c5c981e6 Remove all TECH_LEVEL related cruft from the code as it's read from the stats files but unused throughout the rest of the code.
Read into a temporary dummy variable when loading stats.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5453 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 18:28:37 +00:00
Giel van Schijndel 44f3bf5f69 Only declare the function name of the %loadFunc directive to be declared in the file where the %loadFunc directive is located.
Don't declare the return type and parameter list to originate from the "original" source file.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5452 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:55:18 +00:00
Giel van Schijndel be7aef1a17 Convert dashes (-) to undersquores (_) as well in header guards (fixes a syntax error with C's preprocessor)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5451 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:45:56 +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 c8dbcd6d2d * Don't refer to a "flame IMD" when loading an IMD_Model, refer to "the IMD for field \"$fieldName\"" instead
* Reference records by their ID number (unique_inheritance_id) instead of some user-code dependent function

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5444 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:30:13 +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 d3c8f34aaf Add function prototypes for the SQLite DB load functions (declared using %loadFunc) to the struct definition header
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5442 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:25:42 +00:00
Giel van Schijndel 052c32e8ec Slightly rework c_structdef_cg.pm's header-template processing code to be more similar to c_sqliteload_cg.pm's header-template processing code
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5441 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:02:10 +00:00
Giel van Schijndel df7b09c6fa Wrap the "header/start/leader" template contents in #line directives for the SQLite C code generator's output
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5440 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:01:02 +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 46fc5cc97e * Make it possible to use forward declarations to the generated struct types
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5436 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:59:23 +00:00
Giel van Schijndel 707d5cf718 * Print from a template for the C struct definition code generator as well
* Add a template for the struct definition header; adds some #include directives required to be able to compile the generated header


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5435 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:57:26 +00:00
Giel van Schijndel 2d1b9d8694 Only shift the next parameter from ARGV if there are more than one (1) left in the C SQLite code generator
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5434 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:49:49 +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 af1b99b30d Line out the field names correctly with the rest of the struct definitions
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5380 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-04 12:51:06 +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 0c28d0493f Fix a syntax error introduced in r5374
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5375 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 22:14:41 +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 bf5230b419 Don't fetch the primary key, as we probably don't need it
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5373 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 20:07:58 +00:00
Giel van Schijndel 00ffe3f55d Generate multi-line SELECT statements instead of single-line ones
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5372 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 20:03:38 +00:00
Giel van Schijndel 0cf5917686 Don't create an unnecessary temporary
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5371 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 20:03:27 +00:00
Giel van Schijndel 8a0dcfa4ac Add Makefile to produce test-output from test-input for DB mini language code generators
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5370 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:23:38 +00:00
Giel van Schijndel 14d3ccca36 Remove commented out & useless code
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5369 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:10:57 +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 6d7cbe3576 Code generators don't need to know how many code to generate anymore
A slight modification to the code generators removes their need for needing to know how many elements (enums or structs) it needs to generate code.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5366 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:10:25 +00:00
Giel van Schijndel f5055899db Add a code generator for SQL SELECT statements
Add a new code generator for the database mini-meta-language. It creates SQL SELECT statements that use INNER JOINs to join all fields across the inheritance hierarchy in a single result row.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5365 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:05:43 +00:00
Giel van Schijndel fc1f447adf Only auto-increment the ID for the base class
Don't add an AUTOINCREMENT clause to the PRIMARY KEY, ID column if it we're not working on the abstract base class.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5364 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 19:04:10 +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 309517fc95 Rename test_code to test_code.tpl
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5362 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 18:56:34 +00:00
Giel van Schijndel cc3f64a21a Rewrite SQL table generator for new parser architecture
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5361 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-03 18:55:26 +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