1 ////////////////////////////////////////////////////////////////////////////////
2 // MillScript: an Open Spice interpreter and batch website creation tool
3 // Copyright (C) 2001-2004 Open World Ltd
4 // Copyright (C) 2005 Kevin Rogers
5 //
6 // This file is part of MillScript.
7 //
8 // MillScript is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
11 // any later version.
12 //
13 // MillScript is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 // more details.
17 //
18 // You should have received a copy of the GNU General Public License along with
19 // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
20 // Place, Suite 330, Boston, MA 02111-1307 USA
21 ////////////////////////////////////////////////////////////////////////////////
22 package org.millscript.millscript.syntax;
23
24 import org.millscript.millscript.expr.Expr;
25 import org.millscript.millscript.expr.LambdaExpr;
26
27 /**
28 * This class implements <code>fun</code> syntax. This syntax creates a function
29 * object, but does not bind it to a variable.
30 *
31 * @see org.millscript.millscript.expr.LambdaExpr
32 */
33 public final class FunSyntax extends ProcedureSyntax {
34
35 /**
36 * Creates a fun syntax parser instance, with the default character closing
37 * sequence.
38 */
39 FunSyntax() {
40 // fun always terminates with endfun
41 super( "endfun", false );
42 }
43
44 /**
45 * @see org.millscript.millscript.syntax.ProcedureSyntax#procedure(org.millscript.millscript.syntax.FunctionHeader, org.millscript.millscript.expr.Expr, org.millscript.millscript.syntax.Parser)
46 */
47 @Override
48 public LambdaExpr procedure( final FunctionHeader header, final Expr body, final Parser parser ) {
49 return new LambdaExpr(
50 header.getSymbol(),
51 header.getArglist(),
52 null,
53 body
54 );
55 }
56
57 }