Skip to main content

preprocess_semicolons

Function preprocess_semicolons 

Source
pub fn preprocess_semicolons(source: &str) -> String
Expand description

Automatic semicolon insertion preprocessor.

Resolves newline ambiguities where [...] or (...) on a new line could be parsed as index access or function call (Pest’s greedy postfix matching).

Inserts ; at the end of lines where:

  1. The line ends with a statement-ending token (identifier char, ), ], }, ")
  2. The next non-empty line starts with [ or (

This mirrors Go’s automatic semicolon insertion strategy.