Skip to content

Commit

Permalink
package => namespace; first asp.net examples
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.codehaus.org/boo/trunk@100 2c1201b4-01cd-e047-a400-b836ae1fbc61
  • Loading branch information
bamboo committed Jan 17, 2004
1 parent 39ccb21 commit 70e584f
Show file tree
Hide file tree
Showing 139 changed files with 426 additions and 224 deletions.
4 changes: 2 additions & 2 deletions ast.model
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ package Boo.Ast
class TypeDefinitionCollection
end

class Package(Node)
class NamespaceDeclaration(Node)
Name as string
end

Expand All @@ -65,7 +65,7 @@ package Boo.Ast
end

class Module(TypeDefinition)
Package as Package
Namespace as NamespaceDeclaration
Using as UsingCollection
[auto]
Globals as Block
Expand Down
10 changes: 10 additions & 0 deletions examples/asp.net/HelloAspNet.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%@Page Inherits="Boo.Examples.Web.HelloAspNet" %>
<html>
<body>
<form runat="server">
<center>
<asp:Label id="_message" runat="server" />
</center>
</form>
</body>
</html>
43 changes: 43 additions & 0 deletions examples/asp.net/HelloAspNet.aspx.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#region license
// boo - an extensible programming language for the CLI
// Copyright (C) 2004 Rodrigo B. de Oliveira
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, if you link this library with other files to
// produce an executable, this library does not by itself cause the
// resulting executable to be covered by the GNU General Public License.
// This exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
//
// Contact Information
//
// mailto:[email protected]
#endregion

namespace Boo.Examples.Web

using System
using System.Web
using System.Web.UI
using System.Web.UI.WebControls

class HelloAspNet(Page):

_message as Label

def Page_Load(sender, args as EventArgs):
_message.Text = "Hello, asp.net!"

14 changes: 14 additions & 0 deletions examples/asp.net/YourName.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%@Page Inherits="Boo.Examples.Web.YourName" %>
<html>
<body>
<form runat="server">
<center>
What's your name? <asp:TextBox id="_name" runat="server" />
<asp:Button runat="server" Text="Say it!" /><br />
<br />
<asp:Label id="_message" runat="server" /> <br />

</center>
</form>
</body>
</html>
44 changes: 44 additions & 0 deletions examples/asp.net/YourName.aspx.boo
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#region license
// boo - an extensible programming language for the CLI
// Copyright (C) 2004 Rodrigo B. de Oliveira
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, if you link this library with other files to
// produce an executable, this library does not by itself cause the
// resulting executable to be covered by the GNU General Public License.
// This exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
//
// Contact Information
//
// mailto:[email protected]
#endregion

namespace Boo.Examples.Web

using System
using System.Web.UI
using System.Web.UI.WebControls

class YourName(Page):

_name as TextBox
_message as Label

def Page_Load(sender, args as EventArgs):
_message.Text = "Hello, ${_name.Text}!" if Page.IsPostBack


45 changes: 45 additions & 0 deletions examples/asp.net/default.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<project name="Boo asp.net examples" default="build">

<property name="booc" value="../../build/booc.exe" />

<target name="rebuild" depends="clean, build" />

<target name="clean">
<delete dir="output" if="${directory::exists('output')}" />
</target>

<target name="build">
<mkdir dir="output" />
<mkdir dir="output/bin" />

<exec program="${booc}" useruntimeengine="true">
<arg value="/r:System.Web" />
<arg value="/out:output/bin/Boo.Examples.Web.dll" />
<arg value="/target:library" />
<arg file="HelloAspNet.aspx.boo" />
<arg file="YourName.aspx.boo" />
</exec>

<copy todir="output">
<fileset basedir=".">
<includes name="*.aspx" />
</fileset>
</copy>

<copy todir="output/bin">
<fileset basedir="../../build">
<includes name="Boo.dll" />
</fileset>
</copy>

</target>

<target name="run" depends="build">
<exec program="cassiniwebserver.exe">
<arg file="output" />
<arg value="80" />
</exec>
</target>

</project>
4 changes: 2 additions & 2 deletions extras/boo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ JEdit Catalog Entry: <MODE NAME="boo" FILE="boo.xml" FILE_NAME_GLOB="*.boo" />
<KEYWORD1>is</KEYWORD1>
<KEYWORD1>kindof</KEYWORD1>
<KEYWORD1>mixin</KEYWORD1>
<KEYWORD1>namespace</KEYWORD1>
<KEYWORD1>not</KEYWORD1>
<KEYWORD1>or</KEYWORD1>
<KEYWORD1>otherwise</KEYWORD1>
<KEYWORD1>package</KEYWORD1>
<KEYWORD1>otherwise</KEYWORD1>
<KEYWORD1>pass</KEYWORD1>
<KEYWORD1>raise</KEYWORD1>
<KEYWORD1>retry</KEYWORD1>
Expand Down
4 changes: 2 additions & 2 deletions src/Boo.Antlr/BooExpressionLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal class BooExpressionLexer : antlr.CharScanner , TokenStream
public const int OR = 49;
public const int OTHERWISE = 50;
public const int PASS = 51;
public const int PACKAGE = 52;
public const int NAMESPACE = 52;
public const int PROPERTY = 53;
public const int PUBLIC = 54;
public const int PROTECTED = 55;
Expand Down Expand Up @@ -186,7 +186,6 @@ private void initialize()
literals.Add("success", 64);
literals.Add("in", 45);
literals.Add("enum", 32);
literals.Add("package", 52);
literals.Add("continue", 26);
literals.Add("from", 36);
literals.Add("given", 40);
Expand All @@ -195,6 +194,7 @@ private void initialize()
literals.Add("not", 47);
literals.Add("using", 69);
literals.Add("false", 38);
literals.Add("namespace", 52);
literals.Add("super", 62);
literals.Add("protected", 55);
literals.Add("null", 48);
Expand Down
2 changes: 1 addition & 1 deletion src/Boo.Antlr/BooExpressionLexerTokenTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class BooExpressionLexerTokenTypes
public const int OR = 49;
public const int OTHERWISE = 50;
public const int PASS = 51;
public const int PACKAGE = 52;
public const int NAMESPACE = 52;
public const int PROPERTY = 53;
public const int PUBLIC = 54;
public const int PROTECTED = 55;
Expand Down
2 changes: 1 addition & 1 deletion src/Boo.Antlr/BooExpressionLexerTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NULL="null"=48
OR="or"=49
OTHERWISE="otherwise"=50
PASS="pass"=51
PACKAGE="package"=52
NAMESPACE="namespace"=52
PROPERTY="property"=53
PUBLIC="public"=54
PROTECTED="protected"=55
Expand Down
4 changes: 2 additions & 2 deletions src/Boo.Antlr/BooLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class BooLexer : antlr.CharScanner , TokenStream
public const int OR = 49;
public const int OTHERWISE = 50;
public const int PASS = 51;
public const int PACKAGE = 52;
public const int NAMESPACE = 52;
public const int PROPERTY = 53;
public const int PUBLIC = 54;
public const int PROTECTED = 55;
Expand Down Expand Up @@ -221,7 +221,6 @@ private void initialize()
literals.Add("success", 64);
literals.Add("in", 45);
literals.Add("enum", 32);
literals.Add("package", 52);
literals.Add("continue", 26);
literals.Add("from", 36);
literals.Add("given", 40);
Expand All @@ -230,6 +229,7 @@ private void initialize()
literals.Add("not", 47);
literals.Add("using", 69);
literals.Add("false", 38);
literals.Add("namespace", 52);
literals.Add("super", 62);
literals.Add("protected", 55);
literals.Add("null", 48);
Expand Down
18 changes: 9 additions & 9 deletions src/Boo.Antlr/BooParserBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class BooParserBase : antlr.LLkParser
public const int OR = 49;
public const int OTHERWISE = 50;
public const int PASS = 51;
public const int PACKAGE = 52;
public const int NAMESPACE = 52;
public const int PROPERTY = 53;
public const int PUBLIC = 54;
public const int PROTECTED = 55;
Expand Down Expand Up @@ -298,9 +298,9 @@ protected Module start() //throws RecognitionException, TokenStreamException
{
switch ( LA(1) )
{
case PACKAGE:
case NAMESPACE:
{
package_directive(module);
namespace_directive(module);
break;
}
case EOF:
Expand Down Expand Up @@ -462,27 +462,27 @@ Node node
}
}

protected void package_directive(
protected void namespace_directive(
Module container
) //throws RecognitionException, TokenStreamException
{

Token t = null;

Token id;
Package p = null;
NamespaceDeclaration p = null;


try { // for error handling
t = LT(1);
match(PACKAGE);
match(NAMESPACE);
id=identifier();
if (0==inputState.guessing)
{

p = new Package(ToLexicalInfo(t));
p = new NamespaceDeclaration(ToLexicalInfo(t));
p.Name = id.getText();
container.Package = p;
container.Namespace = p;

}
eos();
Expand Down Expand Up @@ -6225,7 +6225,7 @@ private void initializeFactory()
@"""or""",
@"""otherwise""",
@"""pass""",
@"""package""",
@"""namespace""",
@"""property""",
@"""public""",
@"""protected""",
Expand Down
2 changes: 1 addition & 1 deletion src/Boo.Antlr/BooTokenTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class BooTokenTypes
public const int OR = 49;
public const int OTHERWISE = 50;
public const int PASS = 51;
public const int PACKAGE = 52;
public const int NAMESPACE = 52;
public const int PROPERTY = 53;
public const int PUBLIC = 54;
public const int PROTECTED = 55;
Expand Down
2 changes: 1 addition & 1 deletion src/Boo.Antlr/BooTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NULL="null"=48
OR="or"=49
OTHERWISE="otherwise"=50
PASS="pass"=51
PACKAGE="package"=52
NAMESPACE="namespace"=52
PROPERTY="property"=53
PUBLIC="public"=54
PROTECTED="protected"=55
Expand Down
14 changes: 7 additions & 7 deletions src/Boo.Antlr/boo.g
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tokens
OR="or";
OTHERWISE="otherwise";
PASS="pass";
PACKAGE="package";
NAMESPACE="namespace";
PROPERTY="property";
PUBLIC="public";
PROTECTED="protected";
Expand Down Expand Up @@ -209,7 +209,7 @@ start returns [Module module]
}:
docstring[module]
(options { greedy=true;}: EOS)*
(package_directive[module])?
(namespace_directive[module])?
(using_directive[module])*
(type_member[module.Members])*
globals[module]
Expand Down Expand Up @@ -256,16 +256,16 @@ using_directive[Module container]
;

protected
package_directive[Module container]
namespace_directive[Module container]
{
Token id;
Package p = null;
NamespaceDeclaration p = null;
}:
t:PACKAGE! id=identifier
t:NAMESPACE! id=identifier
{
p = new Package(ToLexicalInfo(t));
p = new NamespaceDeclaration(ToLexicalInfo(t));
p.Name = id.getText();
container.Package = p;
container.Namespace = p;
}
eos
docstring[p]
Expand Down
Loading

0 comments on commit 70e584f

Please sign in to comment.