Identifiers are lexical tokens that provide a way to reference language entities. These can be variables, types, labels, functions, arguments etc. They are essential to any kind of symbolic processing.
In most programming languages identifiers have predefined structure (pattern). This allows the lexer to match them with no ambiguity. The same is true for other tokens of the language (keywords, literals, operators etc.) The pattern used for the identifiers should be flexible enough to ensure enough freedom when naming entities but in the same time it should enforce some restrictions that differentiate identifiers from other tokens.
In SCL we have two types of identifiers:
Standard identifiers - start with a letter and can contain letters, digits and underscore. These are the identifiers that we intuitively use for naming our variables and everything else in the code.
Then we reference the variables in the code with a '#' token like this:
2. Quoted identifiers - these allow for a custom naming convention to be applied on the names in SCL. In order to do so the names are surrounded with quotation marks. Between the quotation marks you may have pretty much any symbol you like but still there are some restrictions. White spaces, tabs and new lines are not allowed.
In the code we reference the variable like this:
There are cases when the language enforces the usage of quoted identifiers.
When calling a custom function (a function in the SCL Vault).
When using a custom UDT/FB (again in the SCL Vault)
When referencing global data blocks ( "DB".field ) . For now we don't have such a use case in Process Simulate.
Note: Quoted identifiers are often used when the user needs to automatically connect existing signals to the SCL block based on a custom naming convention.
The downside of them is that they tend to make the code rather unreadable.
Comentários