2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								! Copyright (C) 2008 Joe Groff.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								! See http://factorcode.org/license.txt for BSD license.  
						 
					
						
							
								
									
										
										
										
											2010-04-01 15:43:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								USING:  help.markup  help.syntax  kernel  multiline  sequences  ;
  
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  literals  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  $  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $syntax "$ word"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Executes "  { $snippet "word"  } " at parse time and adds the result(s) to the parser accumulator."  }
							 
						 
					
						
							
								
									
										
										
										
											2009-02-18 17:57:20 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $notes { $snippet "word"  } "'s definition is looked up and "  { $link call  } "ed at parse time, so words that reference words in the current compilation unit cannot be used with "  { $snippet "$"  } "."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "" "
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								USING:  kernel  literals  prettyprint  ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IN:  scratchpad  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-18 17:57:20 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								CONSTANT:  five  5
  
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $ five  } .
 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "" " " { 5  }" }
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "" "
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								USING:  kernel  literals  prettyprint  ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IN:  scratchpad  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-06 15:38:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								:  seven-eleven  (  --  a  b  )  7  11  ;
  
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $ seven-eleven  } .
 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "" " " { 7  11  }" }
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  $[  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $syntax "$[ code ]"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calls "  { $snippet "code"  } " at parse time and adds the result(s) to the parser accumulator."  }
							 
						 
					
						
							
								
									
										
										
										
											2009-02-18 17:57:20 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $notes "Since "  { $snippet "code"  } " is "  { $link call  } "ed at parse time, it cannot reference any words defined in the same compilation unit."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "" "
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								USING:  kernel  literals  math  prettyprint  ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IN:  scratchpad  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-23 18:12:41 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								<< CONSTANT:  five  5  >>
							 
						 
					
						
							
								
									
										
										
										
											2009-08-13 20:21:44 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $[ five dup  1  +  dup  2  +  ] } .
 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "" " " { 5  6  8  }" }
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-06 15:38:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  ${  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $syntax "${ code }"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Outputs an array containing the results of executing "  { $snippet "code"  } " at parse time."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes { $snippet "code"  } "'s definition is looked up and "  { $link call  } "ed at parse time, so words that reference words in the current compilation unit cannot be used with "  { $snippet "$"  } "."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "" "
							 
						 
					
						
							
								
									
										
										
										
											2009-05-06 15:38:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								USING:  kernel  literals  math  prettyprint  ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IN:  scratchpad  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CONSTANT:  five  5
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CONSTANT:  six  6
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								${ five six 7  } .
 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "" " " { 5  6  7  }"
							 
						 
					
						
							
								
									
										
										
										
											2009-05-06 15:38:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ POSTPONE:  $  POSTPONE:  $[  POSTPONE:  ${  } related-words
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-01 15:43:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  flags{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "values"  sequence  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: literals kernel prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "IN: scratchpad" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "CONSTANT: x HEX: 1" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "flags{ HEX: 20 x BIN: 100 } .h" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "25" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								ARTICLE: "literals"  "Interpolating code results into literal values" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"The "  { $vocab-link "literals"  } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."  
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $example "" "
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 01:29:21 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								USE:  literals  
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  scratchpad  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-06 15:38:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								CONSTANT:  five  5
  
						 
					
						
							
								
									
										
										
										
											2009-08-13 20:21:44 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $ five  $[ five dup  1  +  dup  2  +  ] } .
 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-20 23:42:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "" " " { 5  5  6  8  }" }
							 
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    POSTPONE:  $ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    POSTPONE:  $[ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    POSTPONE:  ${ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-12 02:00:23 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ABOUT: "literals"