-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax Overview
andydhancock edited this page Nov 16, 2023
·
1 revision
LegaleseScript is designed with readability and ease of use in mind, drawing from familiar elements of Java and C-like syntax. This overview provides a foundational understanding of the syntax used in LegaleseScript.
- Case Sensitivity: All keywords, variables, and identifiers in LegaleseScript are case-sensitive.
-
Comments: Use
//for single-line comments and/* */for multi-line comments. -
Semicolons: Each statement is concluded with a semicolon (
;). -
Blocks: Blocks of code are denoted by curly braces
{}.
LegaleseScript introduces custom data types specifically tailored for legal contracts:
- Text: For textual data.
- Number: For numerical values.
- WholeNumber: For integers.
- FractionalNumber(minFraction): For numbers with a minimum fractional part.
- Currency: For monetary values.
- Date: For dates.
- Duration: For time periods.
- Party: For parties to a contract.
- Declare variables with a data type followed by an identifier:
Text contractTitle = "Employment Agreement"; - Variables are mutable and can be reassigned.
- Sections: Represent the different clauses or sections of a contract, similar to classes in OOP.
- Obligations: Functions that specify what a party is required to do.
- Rights: Functions that specify what a party is entitled to.
- Signatures: Special functions to denote agreement by all parties.
-
Conditionals: Use
if,else if, andelsefor conditional logic. - Loops: While loops and for loops are available for iterating over ranges or collections.
- Use
throwto indicate a violation or an error in contract terms.
- Use
importto include external documents. - Legal references are created with
LawReference,CaseReference, and can be accessed using methods like.section()or.paragraph().
Here's a quick example to show the syntax in action:
section EmploymentAgreement {
version("1.0.0");
Party employer = "Acme Corporation";
Party employee = "John Doe";
WholeNumber minimumWage = 100;
obligation calculatePay(WholeNumber hoursWorked) {
if (hoursWorked <= 0) {
throw new ContractException("Hours worked must be positive.");
}
return hoursWorked * minimumWage;
}
right requestLeave(FractionalNumber(0.5) daysRequested) {
// Requests for leave must be in half-day increments.
}
signature signContract() {
// Logic to confirm that all parties have signed the contract.
}
}