mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	* Support for Type Language * Update Type Language * Add one more sample for Type Language * Update Type Language grammar
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| // built-in types
 | |
| int#a8509bda ? = Int;
 | |
| long ? = Long;
 | |
| double ? = Double;
 | |
| string ? = String;
 | |
| null = Null;
 | |
| 
 | |
| vector {t:Type} # [ t ] = Vector t;
 | |
| coupleInt {alpha:Type} int alpha = CoupleInt<alpha>;
 | |
| coupleStr {gamma:Type} string gamma = CoupleStr gamma;
 | |
| 
 | |
| /* The name of the type variable is irrelevant: "gamma" could be replaced with "alpha"
 | |
|   However, the combinator number will depend on the specific choice. */
 | |
| 
 | |
| intHash {alpha:Type} vector<coupleInt<alpha>> = IntHash<alpha>;
 | |
| strHash {alpha:Type} (vector (coupleStr alpha)) = StrHash alpha;
 | |
| intSortedHash {alpha:Type} intHash<alpha> = IntSortedHash<alpha>;
 | |
| strSortedHash {alpha:Type} (strHash alpha) = StrSortedHash alpha;
 | |
| 
 | |
| // custom types
 | |
| pair x:Object y:Object = Pair;
 | |
| triple x:Object y:Object z:Object = Triple;
 | |
| 
 | |
| user#d23c81a3 id:int first_name:string last_name:string = User;
 | |
| no_user#c67599d1 id:int = User;
 | |
| group id:int title:string last_name:string = Group;
 | |
| no_group = Group;
 | |
| 
 | |
| ---functions---
 | |
| 
 | |
| // Maybe some built-in arithmetic functions; inverse quotes make "identifiers" out of arbitrary non-alphanumeric strings
 | |
| `+` Int Int = Int;
 | |
| `-` Int Int = Int;
 | |
| `+` Double Double = Double;
 | |
| // ...
 | |
| 
 | |
| // API functions (aka RPC functions)
 | |
| getUser#b0f732d5 int = User;
 | |
| getUsers#2d84d5f5 (Vector int) = Vector User; |