Add modulo operators to lexer
Tokens MODULO and SLASH_MODULO are going to represent the modulo and fmod operations on integers and floats, or return a pair with the divisor and the modulo, respectively.
This commit is contained in:
		
							parent
							
								
									4178bfefea
								
							
						
					
					
						commit
						9e1ef93990
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		|  | @ -37,6 +37,8 @@ const ( | |||
| 	SLASH | ||||
| 	SLASH_DOT | ||||
| 	SLASH_UNDERSCORE | ||||
| 	SLASH_MODULO | ||||
| 	MODULO | ||||
| 
 | ||||
| 	// Literals | ||||
| 	IDENTIFIER | ||||
|  | @ -179,6 +181,8 @@ func (l *Lexer) scanToken() { | |||
| 		} else { | ||||
| 			l.addSimpleToken(GREATER) | ||||
| 		} | ||||
| 	case '%': | ||||
| 		l.addSimpleToken(MODULO) | ||||
| 	case '/': | ||||
| 		if l.match('/') { | ||||
| 			// A comment goes until the end of the line | ||||
|  | @ -211,6 +215,8 @@ func (l *Lexer) scanToken() { | |||
| 			l.addSimpleToken(SLASH_DOT) | ||||
| 		} else if l.match('_') { | ||||
| 			l.addSimpleToken(SLASH_UNDERSCORE) | ||||
| 		} else if l.match('%') { | ||||
| 			l.addSimpleToken(SLASH_MODULO) | ||||
| 		} else { | ||||
| 			l.addSimpleToken(SLASH) | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Petar Kapriš
						Petar Kapriš