Skip to content

Commit 9672f98

Browse files
committed
feat(ovsm): add Python-style (#) comment support
**Enhancement:** Added support for Python-style # comments in OVSM scripts, complementing the existing // C-style comments. **Problem Solved:** AI agents were generating OVSM code with # comments, which caused tokenization errors. This enhancement allows both comment styles, making OVSM more compatible with AI-generated code and more user-friendly. **Implementation:** - Modified scanner.rs to recognize '#' character - Comments extend from # to end of line - Works alongside existing // comment support **Test Results:** ✅ Both # and // comments work correctly ✅ Inline comments supported ✅ Multiple comment styles can coexist in same script ✅ 10 transactions counted successfully with commented code **Impact:** - Improves AI agent compatibility - Makes OVSM more familiar to Python developers - Enables better code documentation **Example:** ```ovsm # This is a Python-style comment CONST ADDRESS = "6EF8..." // C-style comment also works $result = getSignatures(address: ADDRESS, limit: 10) # Inline comment RETURN COUNT($result) ``` **Files Changed:** - crates/ovsm/src/lexer/scanner.rs (lines 97-102)
1 parent baedd32 commit 9672f98

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/ovsm/src/lexer/scanner.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ impl Scanner {
9494
self.add_token(TokenKind::Star);
9595
}
9696
}
97+
'#' => {
98+
// Python-style comment
99+
while self.peek() != '\n' && !self.is_at_end() {
100+
self.advance();
101+
}
102+
}
97103
'/' => {
98104
if self.match_char('/') {
99105
// Line comment

0 commit comments

Comments
 (0)