No description
  • C 98.7%
  • CMake 1.3%
Find a file
2026-08-18 17:07:25 +01:00
src rearranges files 2026-08-18 17:07:25 +01:00
CS23820_Assignment2024.pdf rearranges files 2026-08-18 17:07:25 +01:00
CS23820_Examples.pdf rearranges files 2026-08-18 17:07:25 +01:00
README.md rearranges files 2026-08-18 17:07:25 +01:00

Example Video

See a video of this program running here

Basic Overview

This program works in 2 stages

  • Parsing
  • Processing and Output

Parsing

Parsing is done with the functions in ParsingMethods.h. This reads through the given file and passes the first word found into a switch statement, this leads it to code expecting certain following parameters which are parsed and this cycle is then repeated.

Parsed parameters are used to create structs stored in "Symbols", these symbols just hold a name along with said struct. Over time the structs inside the symbols will reference one another and their values will be combined eventually leading to one final symbol with the root branch in. This is then returned to the main method to be used in the second phase.

Processing and Output

Processing is done recursively, a method to handle a set of branches is called and this will intern either output graphics to an svg file or call itself. This has a few extra features such as optionally adding in graphics for transforms if their colour is defined.

Files And Their Purposes

This project contains a number of files each header contains documentation of its individual methods but an overview of the file as a whole can be found below.

Branch.h

A definition of the branch struct and methods for inspecting it

BranchProcessing

BranchProcessing.h, Methods for recursively running through a branch struct and outputting it to an svg file

CommandDictionary.h

A dictionary of commands (GRAPHIC, TRANSFORM, BRANCH) and something a bit like manually written hash values for them along with a method to read it. This allows me to use switch statements on strings of commands.

GraphicsStructs.h

Structs to represent graphical concepts such as points and transforms along with methods to manipulate and interact with them.

ParsingMethods.h

Methods to convert the nfsf file into structs to be processes. These methods collect "symbols" which represent important values such as a graphic or a transform it then will place the items stored within these symbols into each other to produce a single final list of branches that represent one fractal.

SvgOutMethods.h

Methods for outputting to an svg file, this mostly involves outputting points to a file.

SymbolTable.h

This defines a symbol struct, a linked list of symbols and methods to add and find them in the list

FileHandlingMethods.h

These are small generic methods for interacting with files, offering methods such as peeking and generating output file names

External Standards

The code in this program follows strict ANSI C standards, this is maintained with compile flags -ansi, -Wall and -Wpedantic. This has lead to some odd quirks I don't normally see in C code, for instance, apparently single comments aren't in the ansi standard as isn't the ability to add declarations into for loops so all comments are done using multi-line syntax and most for loops will appear as so.

int i = 0;
for(; i < 10; i++)

Internal Standards

This section lists important details about the standard this program follows:

  • All symbol names have a maximum length of 25
  • All fscanf's within the code should use trailing spaces rather than leading spaces
  • Ranges are inclusive

Compilation

No external libraries are required, you should be able to just run cmake on the CMakeLists.txt file and have a full build. Note you should have the c "math.h" library installed but this is generally standard and comes with all compilers.