summaryrefslogtreecommitdiff
path: root/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2010-07-19 20:46:55 +0000
committerGravatar rustanleino <unknown>2010-07-19 20:46:55 +0000
commit28e03877a9c41dc0556d17115ccd1647f9eddcf6 (patch)
tree0a4c8f27752ea637fcf1609cdea1fe498fed1596 /Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs
parent4a0723a7c122f78f7e6808a4ed9a48d2d58b210f (diff)
Chalice: Introduced '[[ S ]]' as a shorthand syntax for 'lock (this) { S }'. Think of the new brackets as atomicity brackets (see PetersonsAlgorithm.chalice)
Chalice: Added Peterson's algorithm to test suite (safety properties only) VS 2010 integration: Updated Chalice and Dafny modes, added keyword highlighting for a new Boogie mode
Diffstat (limited to 'Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs')
-rw-r--r--Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs b/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs
index 56f53c28..7a856d36 100644
--- a/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs
+++ b/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs
@@ -5,7 +5,7 @@ using Irony.Parsing;
namespace Demo
{
- [Language("My C", "1.0", "My C Programming Language")]
+ [Language("Chalice", "1.0", "Chalice Programming Language")]
public class Grammar : Irony.Parsing.Grammar
{
public Grammar() {
@@ -74,10 +74,12 @@ namespace Demo
NonTerminal NewStmt = new NonTerminal("NewStmt");
NonTerminal NewArrStmt = new NonTerminal("NewArrStmt");
NonTerminal QualifiedName = new NonTerminal("QualifiedName");
+ NonTerminal AccessQualName = new NonTerminal("AccessQualName");
NonTerminal GenericsPostfix = new NonTerminal("GenericsPostfix");
NonTerminal ArrayExpression = new NonTerminal("ArrayExpression");
NonTerminal FunctionExpression = new NonTerminal("FunctionExpression");
NonTerminal selectExpr = new NonTerminal("selectExpr");
+ NonTerminal accessExpr = new NonTerminal("accessExpr");
#endregion
#region 2.3 Statement
@@ -125,6 +127,7 @@ namespace Demo
#region 3.1 Expressions
selectExpr.Rule = (ToTerm("this") + ".").Q() + QualifiedName;
+ accessExpr.Rule = (ToTerm("this") + ".").Q() + AccessQualName;
evalstate.Rule =
ident + ToTerm(".") +
(ToTerm("acquire")
@@ -159,7 +162,7 @@ namespace Demo
| LMb + declaration.Star() + RMb
| LParen + expression + RParen
| ToTerm("unfolding") + expression + "in" + expression
- | ToTerm("acc") + "(" + selectExpr + (("," + expression) | Empty) + ")"
+ | ToTerm("acc") + "(" + accessExpr + (("," + expression) | Empty) + ")"
| ToTerm("old") + "(" + expression + ")"
| ToTerm("eval") + "(" + evalstate + "," + expression + ")"
| ToTerm("credit") + "(" + expression + "," + expression + ")"
@@ -167,7 +170,7 @@ namespace Demo
| expression + PreferShiftHere() + "?" + expression + ":" + expression
| ToTerm("rd") +
(ToTerm("holds") + "(" + expression + ")"
- | "(" + selectExpr + rdPermArg.Q() + ")"
+ | "(" + accessExpr + rdPermArg.Q() + ")"
)
;
@@ -196,6 +199,7 @@ namespace Demo
FunctionExpression.Rule = QualifiedName + LParen + expressionList.Q() + RParen;
QualifiedName.Rule = ident | QualifiedName + dot + ident;
+ AccessQualName.Rule = ident | "*" | QualifiedName + dot + (ident | "*");
GenericsPostfix.Rule = less + QualifiedName + greater;
@@ -256,6 +260,8 @@ namespace Demo
| "assert" + expression + Semi
| "assume" + expression + Semi
| "unshare" + expression + Semi
+ | "lock" + Condition + Statement
+ | "[[" + Statements + "]]"
| "acquire" + expression + Semi
| "release" + expression + Semi
| "downgrade" + expression + Semi