Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate unsupported parenthetical primitive constraints #1044

Open
andrewemeryanz opened this issue Sep 2, 2020 · 1 comment
Open

Deprecate unsupported parenthetical primitive constraints #1044

andrewemeryanz opened this issue Sep 2, 2020 · 1 comment

Comments

@andrewemeryanz
Copy link
Contributor

Purpose

Following on from this comment, the Sysl parser currently parses parenthetical primitive constraints that have never been officially supported. Consider the following examples of types that parse correctly but have never been officially supported:

int(4)           # primitive: INT, constraint: { length: { max: 4 } }
int(4.8)         # primitive: INT, constraint: { length: { max: 4 } }
string(4.8)      # primitive: STRING, constraint: { length: { max: 4 } }

The following is the list of officially supported parenthetical primitive type constraints and their expected representation:

decimal(4.8)     # primitive: DECIMAL, constraint: { precision: 4, scale: 8 }
string(4)        # primitive: STRING, constraint: { length: { max: 4 } }
string(4..8)     # primitive: STRING, constraint: { length: { min: 4, max: 8 } }

All other representations should be considered invalid.

Suggested approaches

The corpus of Sysl files should first be searched to see if any of the unsupported representations are being used. The parser should then either fail or warn when an unsupported representation is discovered (depending on how widely the representation can be found in use).

@andrewemeryanz
Copy link
Contributor Author

@marcelocantos Could you comment on the correctness of this statement:

The following is the list of officially supported parenthetical primitive type constraints and their expected representation:

decimal(4.8)     # primitive: DECIMAL, constraint: { precision: 4, scale: 8 }
string(4)        # primitive: STRING, constraint: { length: { max: 4 } }
string(4..8)     # primitive: STRING, constraint: { length: { min: 4, max: 8 } }

Also, should we consider supporting the bitWidth constraint (from this issue) as the general approach to numeric types? For example, the representation of the following types would be (taking into considering their currently parsed values):

decimal(4)      # primitive: DECIMAL, constraint: { bitWidth: 4, length: { max: 4 } }
int(4)          # primitive: INT, constraint: { bitWidth: 4, length: { max: 4 } }
float(4)        # primitive: FLOAT, constraint: { bitWidth: 4 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant