mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			19 lines
		
	
	
		
			344 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			344 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
module Compile
 | 
						|
 | 
						|
import Syntax;
 | 
						|
 | 
						|
str compile(Machine m) =
 | 
						|
  "while (true) {
 | 
						|
  '  event = input.next();
 | 
						|
  '  switch (current) { 
 | 
						|
  '    <for (q <- m.states) {>
 | 
						|
  '    case \"<q.name>\":
 | 
						|
  '      <for (t <- q.out) {>
 | 
						|
  '      if (event.equals(\"<t.event>\"))
 | 
						|
  '        current = \"<t.to>\";
 | 
						|
  '      <}>
 | 
						|
  '      break;
 | 
						|
  '    <}>
 | 
						|
  '  }
 | 
						|
  '}"; 
 |