NV1002Compiler

Syntax Error

The source code violates NextViper grammatical syntax rules and cannot be parsed into an Abstract Syntax Tree (AST).

EXPRSTMT

Why this error occurs

This occurs with unclosed parentheses or brackets, missing colons on statement headers, misplaced operators, unclosed string literals, or invalid indentation.

Incorrect Code
// incorrect: missing colon after if condition and unclosed string
if age >= 18
    print("Welcome!
else:
    print("Underage")
Corrected Code
// corrected: colon after condition and closed string literal
if age >= 18:
    print("Welcome!")
else:
    print("Underage")

Troubleshooting & Remediation

  • 1Check for matching quotes, parentheses, brackets, and braces.
  • 2Ensure all 'if', 'elif', 'else', 'for', 'while', 'fn', and 'struct' headers end with a colon (:).
  • 3Run 'nextviper fmt' to identify indentation and delimiter anomalies.
  • 4Inspect the exact line and column numbers reported in the error message.

Relevant CLI Commands

$ nextviper fmt$ nextviper check