Implemented regex validation for variables
This commit is contained in:
@@ -137,7 +137,7 @@ func (l *Lexer) NextToken() Token {
|
||||
return l.emit(TokenLBracket)
|
||||
case ']':
|
||||
return l.emit(TokenRBracket)
|
||||
case '&', '?', '!', '<', '>', '*', '(', ')':
|
||||
case '&', '?', '!', '<', '>', '*', '(', ')', '~', '%', '^':
|
||||
return l.emit(TokenSymbol)
|
||||
case '"':
|
||||
return l.lexString()
|
||||
|
||||
@@ -296,6 +296,12 @@ func (p *Parser) parseVariableDefinition(startTok Token) (Definition, bool) {
|
||||
break
|
||||
}
|
||||
if t.Type == TokenEqual {
|
||||
if p.peekN(1).Type == TokenSymbol && p.peekN(1).Value == "~" {
|
||||
p.next()
|
||||
p.next()
|
||||
typeTokens = append(typeTokens, Token{Type: TokenSymbol, Value: "=~", Position: t.Position})
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
typeTokens = append(typeTokens, p.next())
|
||||
|
||||
Reference in New Issue
Block a user