Permalink
Browse files

Work on syntax.

  • Loading branch information...
1 parent 64fdc1d commit 996ed8da4d79896b071703237988769a58ceacbb @rampelstinskin committed Apr 21, 2012
Showing with 23 additions and 23 deletions.
  1. +3 −3 Nemerle.Parser.Macro.Parser/GrammarParser2.n
  2. +20 −20 Test/CalcGrammar.n2
@@ -99,11 +99,11 @@ namespace Nemerle.Parser
[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 "rule"S Identifier ":"s NemerleType "="s Rule ";"s;
+ SimpleRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType "="s Rule ";"s;
[Ast(Attributes, RuleKW, Name, Colon, Type, Semicolon)]
- ExtentionPointRuleDecl is Declaration = RuleAttributes "rule"S Identifier ":"s NemerleType ";"s;
+ ExtentionPointRuleDecl is Declaration = RuleAttributes "syntax"S Identifier ":"s NemerleType ";"s;
[Ast(Attributes, RuleKW, Name, Is, BaseName, Assign, Rule, Semicolon)]
- ExtentionRuleDecl is Declaration = RuleAttributes "rule"S Identifier "is"S QIdentifier "="s Rule ";"s;
+ ExtentionRuleDecl is Declaration = RuleAttributes "syntax"S Identifier "is"S QIdentifier "="s Rule ";"s;
[Ast(Using, GrammarName, Semicolon)]
UsingDecl is Declaration = "using"S QIdentifier";"s;
View
@@ -8,41 +8,41 @@ syntax module CalcGrammar
using NumParser;
token any = ['\u0000'..'\uFFFF'];
- rule s : void = ' '*;
+ syntax s : void = ' '*;
[StartRule, Ast(expr)]
- rule start : Ast = s expr !any;
+ syntax start : Ast = s expr !any;
[StartRule, Ast()]
- rule expr : Ast;
+ syntax expr : Ast;
- [Ast(l, expr, r)] rule rounds is expr = '('s expr ')'s;
- [Ast(l, expr, r)] rule seq is expr = '{'s expr* '}'s;
+ [Ast(l, expr, r)] syntax rounds is expr = '('s expr ')'s;
+ [Ast(l, expr, r)] syntax seq is expr = '{'s expr* '}'s;
- [Ast(num)] rule num is expr = number s;
+ [Ast(num)] syntax num is expr = number s;
- [Ast(op, expr)] rule neg is expr = '-'s expr : 100;
+ [Ast(op, expr)] syntax neg is expr = '-'s expr : 100;
- [Ast(op, expr)] rule prefixDec is expr = "--"s expr : 200;
- [Ast(expr, op)] rule postfixDec is expr = expr : 200 "--"s;
+ [Ast(op, expr)] syntax prefixDec is expr = "--"s expr : 200;
+ [Ast(expr, op)] syntax postfixDec is expr = expr : 200 "--"s;
- [Ast(l, op, r)] rule add is expr = expr : 10 '+'s expr : 10;
- [Ast(l, op, r)] rule sub is expr = expr : 10 '-'s expr : 10;
- [Ast(l, op, r)] rule mul is expr = expr : 20 '*'s expr : 20;
- [Ast(l, op, r)] rule div is expr = expr : 20 '/'s expr : 20;
- [Ast(l, op, r)] rule mod is expr = expr : 20 '%'s expr : 20;
- [Ast(l, op, r)] rule pow is expr = expr : 31 '^'s expr : 30;
+ [Ast(l, op, r)] syntax add is expr = expr : 10 '+'s expr : 10;
+ [Ast(l, op, r)] syntax sub is expr = expr : 10 '-'s expr : 10;
+ [Ast(l, op, r)] syntax mul is expr = expr : 20 '*'s expr : 20;
+ [Ast(l, op, r)] syntax div is expr = expr : 20 '/'s expr : 20;
+ [Ast(l, op, r)] syntax mod is expr = expr : 20 '%'s expr : 20;
+ [Ast(l, op, r)] syntax pow is expr = expr : 31 '^'s expr : 30;
- [Ast(cond, q, l, colon, r)] rule cond is expr = expr : 301 '?'s expr ':'s expr;
+ [Ast(cond, q, l, colon, r)] syntax cond is expr = expr : 301 '?'s expr ':'s expr;
- [Ast(l, CoalescingOp, r)] rule coalescing is expr = expr : 401 "??"s expr : 400;
+ [Ast(l, CoalescingOp, r)] syntax coalescing is expr = expr : 401 "??"s expr : 400;
}
syntax module IncGrammar
{
using cp = CalcGrammar;
- [Ast(op, expr)] rule plus is cp.expr = '+'cp.s cp.expr : 100;
- [Ast(op, expr)] rule prefixInc is cp.expr = "++"cp.s cp.expr : 200;
- [Ast(expr, op)] rule postfixInc is cp.expr = cp.expr : 200 "++"cp.s;
+ [Ast(op, expr)] syntax plus is cp.expr = '+'cp.s cp.expr : 100;
+ [Ast(op, expr)] syntax prefixInc is cp.expr = "++"cp.s cp.expr : 200;
+ [Ast(expr, op)] syntax postfixInc is cp.expr = cp.expr : 200 "++"cp.s;
}

0 comments on commit 996ed8d

Please sign in to comment.