TSCL.Parser
1.4.0
dotnet add package TSCL.Parser --version 1.4.0
NuGet\Install-Package TSCL.Parser -Version 1.4.0
<PackageReference Include="TSCL.Parser" Version="1.4.0" />
<PackageVersion Include="TSCL.Parser" Version="1.4.0" />
<PackageReference Include="TSCL.Parser" />
paket add TSCL.Parser --version 1.4.0
#r "nuget: TSCL.Parser, 1.4.0"
#:package TSCL.Parser@1.4.0
#addin nuget:?package=TSCL.Parser&version=1.4.0
#tool nuget:?package=TSCL.Parser&version=1.4.0
TSCL
TSCL or Tezz's Simple Configuration Language is a flat Configuration langauge that is mainly used for configurations and other similar ventures. TSCL doesn't have braces and nested braces which could look confusing and messy in the long run.
Instead TSCL has Pointers that points to a Section. In TSCL, this simple langauge contains only 4 parts:
- Sections
- Objects
- Arrays
- Pointers
TSCL has 4 major operations you can use:
- Write : Serializing
- Read : Deserializing
- Modify : File Modification
- Delete : Deletion of Sections or Objects
Sections
Sections are basically similar to namespaces that you can group your objects,arrays and pointers.
[Section-Name] # This is the section entry/name
ObjectName="Value" #these are the objects accompanied with their values
Object2= 21
Array="Dave","John","Micheal"
Next=@NextSection
[NextSection]
isActive=false
Members=30
Objects
You can add as many objects as you want in any section, TSCL can have any object type because after parsing. Its Typecaster will handle the conversion of the objects value.
[Section1]
Obj=true #boolean
Obj2=200 #Integer
obj3="Name" #String
Obj4=20.80 #float
# And so forth....
Arrays
TSCL arrays can be any data type now. declaring arrays is simple. You just have to put commas to add a new element to your array:
[Section]
Array="One","Two","Three" # An array of strings
Array2=1,2,3 # An array of integers
Array3=3.2,3.1,3.0 # An Array of floats
# and so on....
Pointers
Instead of nesting with messy curly braces or retyping a section inside a section, You can just use pointers instead. Pointers are basically objects that point to a Section.
[Section1]
Point=@Section2
[Section2]
isActive=true
Note: Your Pointer value has to always have a '@' symbol at the very start, other wise its just a regular object. And also your Pointer has to have the same name as your target Section
Comments
You can also insert comments in your tscl file with the '#' character, because the Parser will ignore any comments and whitespaces. So you can put as much whitespace in between your objects.
Modes
TSCL has two modes you can toggle in the Initializer class. Simply set the static bool "isUniversal" to true or false, true if you want to use TSCL's SetFile in Initializer to pass your file, that way all 3 classes will use Initializers Filename instead of their own in their constructor. However when false the 3 classes wont use the initializers, instead it will use what you pass on its constructor.
There is also "isVerbose", which basically prints all the errors in your tscl file. by setting it to true, it prints the errors on your console, but if its false it does not.
Note: Both isVerbose and isUniversal is false by default.
Data Pipeline
TSCL's data pipeline is relatively simple. Depending on your config whether isUniversal is set to true or false. TSCL's 3 main operations will first scan and tokenize your file/s upon initialization of their classes.
After you have initialized the operations. you can then begin deserializing, serializing or modifying your tscl file.
File/s->Tokenizer(Scans and Tokenizes)->Parser->TypeCaster
Usage
To use TSCL just add the namespace on top of your file and call Write to serialize and Read to deserialize. You can also use the Token struct if you want to parse an entire sections objects and use em on your program/app.
using TSCL; // Just Include this namespace to use: Read,Write and Modify
namespace Test{
public class Test{
string[] arr;
public Test(string filename){
Initialize.setFile("FilePath.tscl") //make sure you set your file before using: Read, Write and Modify
Token[] tokens;
//Deserializing
Read read = new Read()// Initialize read
read.setSection("Section1"); //We then set which section to start with
int data = read.GetValue<int>("Object_Name"); //after setting we can grab our datas value with the GetValue().
arr = read.GetArrayValue<string>("Array_Name"); //Or if its an array we can go ahead and use the GetArrayValue().
tokens = read.getSectionObjects("NextSection"); // We can also grab objects of Sections and manually use them.
// in the parameters you can put a section name to advance to that section or use the current section by
// leaving the parameter blank.
initiateFile();
}
public void initiateFile(){ // Serializing
using(Write write = new Write()) // Initialize Write
write.AddSection("SectionName"); // This is how we add our section
write.SetSection("SectionName"); //After adding our section, we need to set to use it, otherwise our current section is null
write.AddObject("key","value",Types.OBJECT) // this is how add our objects, arrays and pointers to our section, object value can be
//int, bool or string. But array values are only string.
write.WriteToFile(); //After we are done, we call the writetofile method, to confirm it.
}
public void FileModification() // File Modification
{
Modify mod = new Modify() //always make sure the file exists
mod.SetSection("Section1"); // Always set your target section before modifying
mod.ModifyObject("Object_Name","NewValue"); // Modify
}
pubic void Delete()
{
string[] skipSections = { "Section1","Section2"}; // Sections you want to skip
Delete del = new Delete("file.tscl",skipSections); // Add your file and array of sections you want to skip when initializing
del.DeleteObject("ObjectName","Section3"); // for deleting an object in a section
del.DeleteSection("Section4"); // for deleting an entire section
}
}
}
Installation
To install TSCL you can simple download this on Nuget or in Visual Studio, just go to Manage NuGet Packages and search up TSCL.
Logo

License
This Project is under the GNU General Public License. See the License File for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Changes:
- Improved Tokenizing
- Ignores invalid lines
- Added better error handling
- Added a initiater class for universal filename for all 3 classes
- Ignores comment '#'
- Handles negative numbers now
1.3
- Added missing File.WriteAllLines in Modify class.
- Added a List of Filenames in Initialize class and AddFile and UseFile methods
- Initailized uninitialized members
- Added guard clauses in addFile and useFile
- Added an Universal in initializer class, for instance based file operation.
- fixed ".tscl" to "tscl" in guard clause.
- Added support for net 9.0 - 8.0
- Changed WriteAllLines to StreamWriter in Write Class
- Optimized conditions in Reads Tokenizer
- Fixed File not set Error and extension checking
- Updated Read classes initialize read to iterate through keypair values.
- getObjectData returns token array when getting a pointer.
1.3.1
- Added isVerbose for logging
- Set both isVerbose and isUniversal to false
- fixed path issue in Modify class
1.3.2
- Added a Automatic typcaster
- getObjectValue and getArrayValue are now internal.
New methods GetValue and GetArrayValue replaces them.
1.3.2.1
- Fixed Readme typo T_T.
1.3.3
- Added support for all object and array types
- Improved error handling in GetArrrayData.
- Removed int,String and boolean guard clauses in GetObjectData, now we just
return the object as it is, for Conversion in TypeCaster.
1.3.3.1
-Fixed ReadMe
- Added Copyright to sourcecode
1.3.3.2
- Fixed empty array size issue.
1.3.3.3
- Added a guard clause when adding a section in write
- line no. starts at 0 instead of 1.
1.3.4
- Added missing xml comments
- Changed output of Error logging from Console to Debug
-Updated Readme.
1.4
- Added Delete Operarion
- Fixed Modify operations Section Detection in Initializeread()
- Modified Readme.md