Permalink
Browse files

Finish bootstrapping. At present the Nemerle.Parser use .n2 format. A…

…lso improved updateboot.cmd.
  • Loading branch information...
1 parent 27630f6 commit 04c47300ff7ffb242a94c8bca89f3ed697eebdc4 @VladD2 VladD2 committed May 19, 2012
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -9,154 +9,5 @@ using System.Linq;
namespace Nemerle.Parser
{
- [ParserGrammar(
- Options = EmitDebugSources,
- parsergrammar
- {
- [StartRule, Ast(OpenNamespaces, Declarations)]
- Start : Ast = s OpenNamespace* SyntaxModule* !Any;
-
- [Ast(Using, Namespace, Semicolon)]
- OpenNamespace : Ast = "using"s QIdentifier ";"s;
-
- Any = ['\u0000'..'\uFFFF'];
- NewLineCharacter = '\n'
- | '\r'
- | '\u2028' /* line separator */
- | '\u2029'; /* paragraph separator */
- NewLine = "\r\n" | NewLineCharacter;
-
- Whitespace = [Zs]
- | '\t'
- | '\v' /* vertial tab */
- | '\f'; /* form feed */
-
- Space = Whitespace | NewLine;
-
- [Ast()]
- IgnoreToken : Ast;
- [Ast(Start, Body, NewLine)]
- SingleLineComment is IgnoreToken = "//" (!NewLine Any)* NewLine?;
- [Ast(Start, Body, End)]
- MultiLineComment is IgnoreToken = "/*" (!"*/" Any)* "*/";
- [Ast(Space)]
- SpaceToken is IgnoreToken = Space;
-
- s : void = IgnoreToken*; /* optional spacer */
- S : void = !IdentifierPartCharacters s; /* identifier break spacer */
-
- LetterCharacter = [Lu, Ll, Lt, Lm, Lo, Nl];
- CombiningCharacter = [Mn, Mc];
- DecimalDigitCharacter = [Nd];
- ConnectingCharacter = [Pc];
- FormattingCharacter = [Cf];
-
- IdentifierStartCharacter = LetterCharacter | "_";
- IdentifierPartCharacters = LetterCharacter | DecimalDigitCharacter | ConnectingCharacter | CombiningCharacter | FormattingCharacter;
- IdentifierBody = IdentifierStartCharacter IdentifierPartCharacters*;
-
- HexDigit = ['0'..'9', 'a'..'f', 'A'..'F'];
- ReservedStringChar = "\"" | "\\";
- ReservedCharChar = "\'" | "\\";
-
- [Ast(Syntax, Module, Name, Open, Declarations, Close)]
- SyntaxModule : Ast = "syntax"S "module"S Identifier "{"s Declaration* "}"s;
-
- [Ast(Open, Parts, Close)]
- StringLiteral : Ast = "\"" StringPart* "\"" s;
- [Ast()]
- StringPart : Ast;
- [Ast(Chars)]
- SimpleStringPart is StringPart = (!ReservedStringChar Any)+;
- [Ast(Prefix, Digit0, Digit1, Digit2, Digit3)]
- UnicodeEscapeSequenceStringPart is StringPart = "\\u" HexDigit HexDigit HexDigit HexDigit;
- [Ast(Backslash, Char)]
- EscapeSequenceStringPart is StringPart = "\\" Any;
-
- [Ast(Open, Char, Close)]
- CharLiteral : Ast = "\'" CharPart "\'" s;
- [Ast()]
- CharPart : Ast;
- [Ast(Char)]
- SimpleCharPart is CharPart = !ReservedCharChar Any;
- [Ast(Prefix, Digit0, Digit1, Digit2, Digit3)]
- UnicodeEscapeSequenceCharPart is CharPart = "\\u" HexDigit HexDigit HexDigit HexDigit;
- [Ast(Backslash, Char)]
- EscapeSequenceCharPart is CharPart = "\\" Any;
-
- Digits = ['0'..'9']+;
- [Ast(Digits)] Number : Ast = Digits s;
-
- [Ast(Name)] Identifier : Ast = IdentifierBody s;
- [Ast(Names)] QIdentifier : Ast = (Identifier, "."s)+;
-
- [Ast(TypeParts)] NemerleType : Ast = (NemerleTypePart, "."s)+;
- [Ast(Name, TypeArgs)] NemerleTypePart : Ast = IdentifierBody s (("."s)? "["s (NemerleType, ","s)* "]"s)?;
-
- [Ast()]
- RuleAttribute : Ast;
- [Ast(AttributeName)]
- StartAttribute is RuleAttribute = "StartRule"S;
- [Ast(AttributeName, Open, Names, Close)]
- AstAttribute is RuleAttribute = "Ast"S "("s (Identifier, ","s)* ")"s;
- [Ast(Open, Attributes, Close)]
- RuleAttributeList : Ast = "["s (RuleAttribute, ","s)+ "]"s;
- [Ast(AttributeLists)]
- RuleAttributes : Ast = RuleAttributeList*;
-
- [Ast()] Declaration : Ast;
- [Ast(Attributes, Token, Name, Assign, Rule, Semicolon)]
- TokenRuleDecl is Declaration = RuleAttributes "token"S Identifier "="s TokenRule ";"s;
- [Ast(Attributes, RuleKW, Name, Colon, Type, Assign, Rule, Semicolon)]
- SimpleRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType "="s Rule ";"s;
- [Ast(Attributes, RuleKW, Name, Colon, Type, Semicolon)]
- ExtentionPointRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType ";"s;
- [Ast(Attributes, RuleKW, Name, Is, BaseName, Assign, Rule, Semicolon)]
- ExtentionRuleDecl is Declaration = RuleAttributes "syntax"S Identifier "is"S QIdentifier "="s Rule ";"s;
-
- [Ast(Using, GrammarName, Semicolon)]
- UsingDecl is Declaration = "using"S QIdentifier";"s;
- [Ast(Using, Alias, Assign, GrammarName, Semicolon)]
- AliasDecl is Declaration = "using"S Identifier "="s QIdentifier";"s;
-
- [Ast(Option, EmitDebugSources, Assign, Value, Semicolon)]
- OptionEmitDebugSources is Declaration = "option"S "EmitDebugSources"S "="s Identifier ";"s;
-
- [Ast()] Range : Ast;
- [Ast(Char)] SingleCharRange is Range = CharLiteral;
- [Ast(StartChar, DotDot, EndChar)] CharRange is Range = CharLiteral ".."s CharLiteral;
- [Ast(Name)] UnicodeRange is Range = Identifier;
-
- [Ast()] TokenRule : Ast;
- [Ast(LeftRule, RightRules)] ChoiceTokenRule is TokenRule = TokenRule : 10 ("|"s TokenRule : 10)+;
- [Ast(LeftRule, RightRules)] SequenceTokenRule is TokenRule = TokenRule : 20 (TokenRule : 20)+;
- [Ast(Rule, Op)] OptionalTokenRule is TokenRule = TokenRule : 30 "?"s;
- [Ast(Rule, Op)] ZeroOrManyTokenRule is TokenRule = TokenRule : 30 "*"s;
- [Ast(Rule, Op)] OneOrManyTokenRule is TokenRule = TokenRule : 30 "+"s;
- [Ast(Open, Ranges, Close)] RangeTokenRule is TokenRule = "["s (Range, ","s)+ "]"s;
- [Ast(Char)] CharTokenRule is TokenRule = CharLiteral;
- [Ast(String)] StringTokenRule is TokenRule = StringLiteral;
- [Ast(Open, Rule, Close)] RoundsTokenRule is TokenRule = "("s TokenRule ")"s;
- [Ast(Name)] CallTokenRule is TokenRule = QIdentifier;
- [Ast(Open, Rule, Semicolon, Separator, Close, Op)] ZeroOrManyWithSeparatorTokenRule is TokenRule = "("s TokenRule ";"s TokenRule ")"s "*"s;
- [Ast(Open, Rule, Semicolon, Separator, Close, Op)] OneOrManyWithSeparatorTokenRule is TokenRule = "("s TokenRule ";"s TokenRule ")"s "+"s;
-
- [Ast()] Rule : Ast;
- [Ast(LeftRule, RightRules)] SequenceRule is Rule = Rule : 10 (Rule : 10)+;
- [Ast(Op, Rule)] NotRule is Rule = "!"s Rule : 20;
- [Ast(Op, Rule)] AndRule is Rule = "&"s Rule : 20;
- [Ast(Rule, Op)] OptionalRule is Rule = Rule : 30 "?"s;
- [Ast(Rule, Op)] ZeroOrManyRule is Rule = Rule : 30 "*"s;
- [Ast(Rule, Op)] OneOrManyRule is Rule = Rule : 30 "+"s;
- [Ast(Char)] CharRule is Rule = CharLiteral;
- [Ast(String)] StringRule is Rule = StringLiteral;
- [Ast(Open, Rule, Close)] RoundsRule is Rule = "("s Rule ")"s;
- [Ast(Name, BP)] CallRule is Rule = QIdentifier (":"s Number)?;
- [Ast(Open, Rule, Semicolon, Separator, Close, Op)] ZeroOrManyWithSeparatorRule is Rule = "("s Rule ";"s Rule ")"s "*"s;
- [Ast(Open, Rule, Semicolon, Separator, Close, Op)] OneOrManyWithSeparatorRule is Rule = "("s Rule ";"s Rule ")"s "+"s;
- [Ast(Name, Open, Rule, Close)] Scope is Rule = Identifier "{"s Rule "}"s;
- }
- )]
- public abstract class GrammarParser2
- {}
+ [assembly: Nemerle.Parser.N2Source("GrammarParser2.n2")]
}
@@ -0,0 +1,147 @@
+using Nemerle.Parser;
+
+syntax module GrammarParser2
+{
+ [StartRule, Ast(OpenNamespaces, Declarations)]
+ syntax Start : Ast = s OpenNamespace* SyntaxModule* !Any;
+
+ [Ast(Using, Namespace, Semicolon)]
+ syntax OpenNamespace : Ast = "using"s QIdentifier ";"s;
+
+ token Any = ['\u0000'..'\uFFFF'];
+ token NewLineCharacter = '\n'
+ | '\r'
+ | '\u2028' /* line separator */
+ | '\u2029'; /* paragraph separator */
+ token NewLine = "\r\n" | NewLineCharacter;
+
+ token Whitespace = [Zs]
+ | '\t'
+ | '\v' /* vertial tab */
+ | '\f'; /* form feed */
+
+ token Space = Whitespace | NewLine;
+
+ [Ast()]
+ syntax IgnoreToken : Ast;
+ [Ast(Start, Body, NewLine)]
+ syntax SingleLineComment is IgnoreToken = "//" (!NewLine Any)* NewLine?;
+ [Ast(Start, Body, End)]
+ syntax MultiLineComment is IgnoreToken = "/*" (!"*/" Any)* "*/";
+ [Ast(Space)]
+ syntax SpaceToken is IgnoreToken = Space;
+
+ syntax s : void = IgnoreToken*; /* optional spacer */
+ syntax S : void = !IdentifierPartCharacters s; /* identifier break spacer */
+
+ token LetterCharacter = [Lu, Ll, Lt, Lm, Lo, Nl];
+ token CombiningCharacter = [Mn, Mc];
+ token DecimalDigitCharacter = [Nd];
+ token ConnectingCharacter = [Pc];
+ token FormattingCharacter = [Cf];
+
+ token IdentifierStartCharacter = LetterCharacter | "_";
+ token IdentifierPartCharacters = LetterCharacter | DecimalDigitCharacter | ConnectingCharacter | CombiningCharacter | FormattingCharacter;
+ token IdentifierBody = IdentifierStartCharacter IdentifierPartCharacters*;
+
+ token HexDigit = ['0'..'9', 'a'..'f', 'A'..'F'];
+ token ReservedStringChar = "\"" | "\\";
+ token ReservedCharChar = "\'" | "\\";
+
+ [Ast(Syntax, Module, Name, Open, Declarations, Close)]
+ syntax SyntaxModule : Ast = "syntax"S "module"S Identifier "{"s Declaration* "}"s;
+
+ [Ast(Open, Parts, Close)]
+ syntax StringLiteral : Ast = "\"" StringPart* "\"" s;
+ [Ast()]
+ syntax StringPart : Ast;
+ [Ast(Chars)]
+ syntax SimpleStringPart is StringPart = (!ReservedStringChar Any)+;
+ [Ast(Prefix, Digit0, Digit1, Digit2, Digit3)]
+ syntax UnicodeEscapeSequenceStringPart is StringPart = "\\u" HexDigit HexDigit HexDigit HexDigit;
+ [Ast(Backslash, Char)]
+ syntax EscapeSequenceStringPart is StringPart = "\\" Any;
+
+ [Ast(Open, Char, Close)]
+ syntax CharLiteral : Ast = "\'" CharPart "\'" s;
+ [Ast()]
+ syntax CharPart : Ast;
+ [Ast(Char)]
+ syntax SimpleCharPart is CharPart = !ReservedCharChar Any;
+ [Ast(Prefix, Digit0, Digit1, Digit2, Digit3)]
+ syntax UnicodeEscapeSequenceCharPart is CharPart = "\\u" HexDigit HexDigit HexDigit HexDigit;
+ [Ast(Backslash, Char)]
+ syntax EscapeSequenceCharPart is CharPart = "\\" Any;
+
+ token Digits = ['0'..'9']+;
+ [Ast(Digits)] syntax Number : Ast = Digits s;
+
+ [Ast(Name)] syntax Identifier : Ast = IdentifierBody s;
+ [Ast(Names)] syntax QIdentifier : Ast = (Identifier; "."s)+;
+
+ [Ast(TypeParts)] syntax NemerleType : Ast = (NemerleTypePart; "."s)+;
+ [Ast(Name, TypeArgs)] syntax NemerleTypePart : Ast = IdentifierBody s (("."s)? "["s (NemerleType; ","s)* "]"s)?;
+
+ [Ast()]
+ syntax RuleAttribute : Ast;
+ [Ast(AttributeName)]
+ syntax StartAttribute is RuleAttribute = "StartRule"S;
+ [Ast(AttributeName, Open, Names, Close)]
+ syntax AstAttribute is RuleAttribute = "Ast"S "("s (Identifier; ","s)* ")"s;
+ [Ast(Open, Attributes, Close)]
+ syntax RuleAttributeList : Ast = "["s (RuleAttribute; ","s)+ "]"s;
+ [Ast(AttributeLists)]
+ syntax RuleAttributes : Ast = RuleAttributeList*;
+
+ [Ast()] syntax Declaration : Ast;
+ [Ast(Attributes, Token, Name, Assign, Rule, Semicolon)]
+ syntax TokenRuleDecl is Declaration = RuleAttributes "token"S Identifier "="s TokenRule ";"s;
+ [Ast(Attributes, RuleKW, Name, Colon, Type, Assign, Rule, Semicolon)]
+ syntax SimpleRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType "="s Rule ";"s;
+ [Ast(Attributes, RuleKW, Name, Colon, Type, Semicolon)]
+ syntax ExtentionPointRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType ";"s;
+ [Ast(Attributes, RuleKW, Name, Is, BaseName, Assign, Rule, Semicolon)]
+ syntax ExtentionRuleDecl is Declaration = RuleAttributes "syntax"S Identifier "is"S QIdentifier "="s Rule ";"s;
+
+ [Ast(Using, GrammarName, Semicolon)]
+ syntax UsingDecl is Declaration = "using"S QIdentifier";"s;
+ [Ast(Using, Alias, Assign, GrammarName, Semicolon)]
+ syntax AliasDecl is Declaration = "using"S Identifier "="s QIdentifier";"s;
+
+ [Ast(Option, EmitDebugSources, Assign, Value, Semicolon)]
+ syntax OptionEmitDebugSources is Declaration = "option"S "EmitDebugSources"S "="s Identifier ";"s;
+
+ [Ast()] syntax Range : Ast;
+ [Ast(Char)] syntax SingleCharRange is Range = CharLiteral;
+ [Ast(StartChar, DotDot, EndChar)] syntax CharRange is Range = CharLiteral ".."s CharLiteral;
+ [Ast(Name)] syntax UnicodeRange is Range = Identifier;
+
+ [Ast()] syntax TokenRule : Ast;
+ [Ast(LeftRule, RightRules)] syntax ChoiceTokenRule is TokenRule = TokenRule : 10 ("|"s TokenRule : 10)+;
+ [Ast(LeftRule, RightRules)] syntax SequenceTokenRule is TokenRule = TokenRule : 20 (TokenRule : 20)+;
+ [Ast(Rule, Op)] syntax OptionalTokenRule is TokenRule = TokenRule : 30 "?"s;
+ [Ast(Rule, Op)] syntax ZeroOrManyTokenRule is TokenRule = TokenRule : 30 "*"s;
+ [Ast(Rule, Op)] syntax OneOrManyTokenRule is TokenRule = TokenRule : 30 "+"s;
+ [Ast(Open, Ranges, Close)] syntax RangeTokenRule is TokenRule = "["s (Range; ","s)+ "]"s;
+ [Ast(Char)] syntax CharTokenRule is TokenRule = CharLiteral;
+ [Ast(String)] syntax StringTokenRule is TokenRule = StringLiteral;
+ [Ast(Open, Rule, Close)] syntax RoundsTokenRule is TokenRule = "("s TokenRule ")"s;
+ [Ast(Name)] syntax CallTokenRule is TokenRule = QIdentifier;
+ [Ast(Open, Rule, Semicolon, Separator, Close, Op)] syntax ZeroOrManyWithSeparatorTokenRule is TokenRule = "("s TokenRule ";"s TokenRule ")"s "*"s;
+ [Ast(Open, Rule, Semicolon, Separator, Close, Op)] syntax OneOrManyWithSeparatorTokenRule is TokenRule = "("s TokenRule ";"s TokenRule ")"s "+"s;
+
+ [Ast()] syntax Rule : Ast;
+ [Ast(LeftRule, RightRules)] syntax SequenceRule is Rule = Rule : 10 (Rule : 10)+;
+ [Ast(Op, Rule)] syntax NotRule is Rule = "!"s Rule : 20;
+ [Ast(Op, Rule)] syntax AndRule is Rule = "&"s Rule : 20;
+ [Ast(Rule, Op)] syntax OptionalRule is Rule = Rule : 30 "?"s;
+ [Ast(Rule, Op)] syntax ZeroOrManyRule is Rule = Rule : 30 "*"s;
+ [Ast(Rule, Op)] syntax OneOrManyRule is Rule = Rule : 30 "+"s;
+ [Ast(Char)] syntax CharRule is Rule = CharLiteral;
+ [Ast(String)] syntax StringRule is Rule = StringLiteral;
+ [Ast(Open, Rule, Close)] syntax RoundsRule is Rule = "("s Rule ")"s;
+ [Ast(Name, BP)] syntax CallRule is Rule = QIdentifier (":"s Number)?;
+ [Ast(Open, Rule, Semicolon, Separator, Close, Op)] syntax ZeroOrManyWithSeparatorRule is Rule = "("s Rule ";"s Rule ")"s "*"s;
+ [Ast(Open, Rule, Semicolon, Separator, Close, Op)] syntax OneOrManyWithSeparatorRule is Rule = "("s Rule ";"s Rule ")"s "+"s;
+ [Ast(Name, Open, Rule, Close)] syntax Scope is Rule = Identifier "{"s Rule "}"s;
+}
@@ -17,6 +17,7 @@
<NemerleBinPathRoot Condition=" '$(NemerleBinPathRoot)' == '' ">$(ProgramFiles)\Nemerle</NemerleBinPathRoot>
<Nemerle>$(MSBuildProjectDirectory)\..\Boot\$(NemerleVersion)</Nemerle>
<Name>Nemerle.Parser.Macro.Parser</Name>
+ <!--CustomArguments>-debugger</CustomArguments-->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -66,6 +67,11 @@
<Private>True</Private>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="GrammarParser2.n2">
+ <SubType>Content</SubType>
+ </Resource>
+ </ItemGroup>
<Import Project="$(Nemerle)\Nemerle.MSBuild.targets" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Oops, something went wrong.

0 comments on commit 04c4730

Please sign in to comment.