KB: Resolving "Unterminated String" and "Comma Expected" Errors in Altium Designer

Altium Designer Altium Designer
In Altium Designer, users may encounter the errors "Unterminated String" or "Comma Expected" during project compilation or rule validation. These issues are typically caused by incorrectly defined design rules, such as malformed expressions or unsupported characters in object names. Even projects that previously compiled successfully may begin showing these errors if rule definitions are modified or corrupted. This article outlines the causes and provides step-by-step instructions to resolve both errors.

Solution Details

Unterminated String Error

Why This Happens

This error occurs when one or more design rules contain incomplete or improperly formatted expressions. It often results from missing quotation marks or syntax errors in rule definitions.

What to Do

  • Review all design rules for incomplete or invalid expressions, and ensure they are corrected to comply with proper syntax. 

How to Do It

  1. Navigate to Design » Rules in Altium Designer.
  2. Identify any rules highlighted in red. These indicate invalid entries.
  3. Review the syntax of each highlighted rule.
  4. Correct any incomplete expressions or missing characters.
  5. Save and recompile the project.

Comma Expected Error

Why This Happens

This error can occur due to the following reasons:

  • Incorrect use of quotation marks in the design rule's formatted expression. If quotation marks are placed improperly within the rule syntax, Altium Designer may misinterpret the expression, leading to a parsing error.
  • When quotation marks are used in object names such as nets, footprints, pads, or other design elements targeted by design rules. Altium Designer does not support the use of quotation marks in these names, especially when they are referenced in design rules.

Note on Use of Single Quotation Marks in Altium Designer Query Language: In Altium Designer's query language, string values must be enclosed in single quotation marks ('). This syntax is essential for correctly identifying and filtering objects based on text-based properties such as names, comments, layers, or parameters.

Valid Example:

InNet('LCD_Light')
This query correctly uses single quotation marks to define the string literal.

Invalid Examples:
InNet('Paul's LCD_Light')
InNet('LCD_Light)
InNet(''LCD_Light'')
The first expression will result in a syntax error because the parser interprets 'Paul' as one string and s LCD_Light' as invalid syntax. The two other examples are invalid syntax as well.

What to Do

  • Review all design rules for incomplete or invalid expressions, and ensure they are corrected to comply with proper syntax. 
  • Check for and remove quotation marks from the affected object names and update the PCB document to reflect these changes. Then, redefine the design rule definitions for the affected objects to ensure they reference the corrected names.

How to Do It

If the error is caused by quotation marks used in object names, follow the steps outlined below to correct the issue.

  1. Review your design for object names (e.g., nets, ports) that contain quotation marks.
  2. Remove any quotation marks from these names.
  3. Open Design » Rules and inspect rule definitions for misplaced quotes.
  4. Correct the syntax to eliminate unnecessary quotation marks.
  5. Save and recompile the project to verify resolution.

Further Reading

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.