github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/expressions/parse_comment.go (about)

     1  package expressions
     2  
     3  func (tree *ParserT) parseComment() {
     4  	for tree.charPos++; tree.charPos < len(tree.expression); tree.charPos++ {
     5  		r := tree.expression[tree.charPos]
     6  		switch r {
     7  
     8  		case '\n':
     9  			goto endComment
    10  
    11  		case '\\':
    12  			next := tree.nextChar()
    13  			if next == '\r' || next == '\n' {
    14  				tree.statement.ignoreCrLf = true
    15  			}
    16  
    17  		}
    18  	}
    19  
    20  endComment:
    21  	tree.charPos--
    22  }
    23  
    24  func (tree *ParserT) parseCommentMultiLine() error {
    25  	for tree.charPos += 2; tree.charPos < len(tree.expression); tree.charPos++ {
    26  		r := tree.expression[tree.charPos]
    27  
    28  		switch r {
    29  		case '\n':
    30  			tree.crLf()
    31  
    32  		case '#':
    33  			if tree.nextChar() == '/' {
    34  				goto endCommentMultiLine
    35  			}
    36  
    37  		}
    38  	}
    39  
    40  	return raiseError(tree.expression, nil, tree.charPos, "comment opened with '/#' but no closing token '#/' could be found")
    41  
    42  endCommentMultiLine:
    43  	tree.charPos++
    44  
    45  	return nil
    46  }