tssg-syntax-parser
tssg-syntax-parser copied to clipboard
Parser to generate AST from TSSG Syntax
TSSG Syntax Parser
Parser that generates AST for given TSSG Syntax
This is the complete rewrite of the TSSG Parser, which is now able to build the AST for TSSG Syntax V0.0.1.
Please note that this project is work-in-progress and will support other advance features soon.
Added Support
Parser supports following expressoins:
- Schemas Block Expression
- Schema Expression
- Extendable Schema Expression
- Request Bodies Block Expression
- RequestBody Expression
- Extendable RequestBody Expression
- Parameters Block Expression
- Parameter Expression
Parser support following data types:
- Literal
- Identifier
- Boolean
- Object
- Array
- Function Calls
Note: Complex data types like
ArrayofString,ArrayofObjectis also supported.
Parser also supports miscellaneous features:
- Whitespaces
- Multiline Comments
Schema Block Expression
Schemas block can be written as follow:
Schemas {
BaseUser {
name: string,
email: string
}
Employee extends BaseUser {
salary: number,
department: string
}
}
Notice how we can
extendschemas.
RequestBodies Block Expression
RequestBodies block can be written as Schemas block:
RequestBodies {
BaseListParams {
page: number,
limit: number,
totalPages: number
}
ListUsers extends BaseListParams {
filters: {
ids: string[]
}
}
}
Parameters Block Expression
Similarly parameters block can be written as:
Parameters {
GetUser {
id: string
}
}
Data Types
Data types can be used as follow:
User {
name: string,
age: integer,
address: {
city: string,
country: string,
zip: number
},
isVerified: boolean,
profileImages: {
size: {
width: number,
height: number
}
url: string
}[]
}
Notice
addresswhich is anObjectwith 3 properties. AndprofileImageswhich is anArrayofObjectswith 2 properties.
Syntax Draft Proposal
Read our Proposal Draft.
Hey there! Want to contribute?
- Update parser code and run
yarn build:prodto generate the parser. - Update transformer code and again run
yarn build:prodgenerate transformer. - Update
testsand createPR.
Read our Contribution Guidline.