diff options
author | kyessenov <unknown> | 2010-08-19 02:16:14 +0000 |
---|---|---|
committer | kyessenov <unknown> | 2010-08-19 02:16:14 +0000 |
commit | 4925268320fa8261e0394b2754e054404f047599 (patch) | |
tree | b5f45f3edce940c79b0cd6fdfdf59251db154840 /Util | |
parent | b2ec7fbf6652a44faf14ea86ab42eb74c86c8d16 (diff) |
Simplified grammar for Chalice VS 2010 integration. It should now work and be easily extensible.
Diffstat (limited to 'Util')
4 files changed, 48 insertions, 21 deletions
diff --git a/Util/VS2010/Chalice/ChaliceLanguageService/Configuration.cs b/Util/VS2010/Chalice/ChaliceLanguageService/Configuration.cs index 2eb57f11..e5b10f00 100644 --- a/Util/VS2010/Chalice/ChaliceLanguageService/Configuration.cs +++ b/Util/VS2010/Chalice/ChaliceLanguageService/Configuration.cs @@ -17,7 +17,7 @@ namespace Demo CreateColor("Comment", COLORINDEX.CI_DARKGREEN, COLORINDEX.CI_USERTEXT_BK);
CreateColor("Identifier", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
CreateColor("String", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK);
- CreateColor("Number", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK);
+ CreateColor("Number", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK);
CreateColor("Text", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
}
}
diff --git a/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs b/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs index fad5abf2..6bb276c2 100644 --- a/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs +++ b/Util/VS2010/Chalice/ChaliceLanguageService/Grammar.cs @@ -10,15 +10,11 @@ namespace Demo {
public Grammar() {
#region 1. Terminals
- NumberLiteral n = TerminalFactory.CreateCSharpNumber("number");
-
+ NumberLiteral n = TerminalFactory.CreateCSharpNumber("number");
IdentifierTerminal ident = new IdentifierTerminal("Identifier");
- /* v.AddReservedWords("true", "false", "null", "if", "else",
- "while", "for", "foreach", "in",
- "switch", "case", "default", "break",
- "continue", "return", "function", "is",
- "pre", "post", "invariant", "new"); */
- this.MarkReservedWords(
+
+ // Copy pasted directly from Parser.scala
+ string[] reserved = new string[] {
"class", "ghost", "var", "const", "method", "channel", "condition",
"assert", "assume", "new", "this", "reorder",
"between", "and", "above", "below", "share", "unshare", "acquire", "release", "downgrade",
@@ -31,11 +27,31 @@ namespace Demo "predicate", "function", "free", "send", "receive",
"ite", "fold", "unfold", "unfolding", "in", "forall", "exists",
"seq", "nil", "result", "eval", "token",
- "wait", "signal"
- );
+ "wait", "signal",
+ "refines", "transforms", "replaces", "by"
+ };
- StringLiteral s = new StringLiteral("String", "'", StringFlags.AllowsDoubledQuote);
+ string[] delimiters = new string[] {
+ "(", ")", "{", "}", "[[", "]]",
+ "<==>", "==>", "&&", "||",
+ "==", "!=", "<", "<=", ">=", ">", "<<", "in", "!in",
+ "+", "-", "*", "/", "%", "!", ".", "..",
+ ";", ":", ":=", ",", "?", "|", "[", "]", "++", "::",
+ "_"
+ };
+
+ this.MarkReservedWords(reserved);
+
+ Terminal Comment = new CommentTerminal("Comment", "/*", "*/");
+ NonGrammarTerminals.Add(Comment);
+ Terminal LineComment = new CommentTerminal("LineComment", "//", "\n");
+ NonGrammarTerminals.Add(LineComment);
+ #endregion
+
+ #region Disabled for a simpler grammar
+ /*
+ StringLiteral s = new StringLiteral("String", "'", StringFlags.AllowsDoubledQuote);
Terminal dot = ToTerm(".", "dot");
Terminal less = ToTerm("<");
Terminal greater = ToTerm(">");
@@ -52,8 +68,6 @@ namespace Demo Terminal semicolon = ToTerm(";");
Terminal colon = ToTerm(":");
- #endregion
-
#region 2. Non-terminals
#region 2.1 Expressions
NonTerminal expression = new NonTerminal("Expr");
@@ -335,11 +349,6 @@ namespace Demo declaration.Rule = classDecl | channelDecl
;
-
- Terminal Comment = new CommentTerminal("Comment", "/*", "*/");
- NonGrammarTerminals.Add(Comment);
- Terminal LineComment = new CommentTerminal("LineComment", "//", "\n");
- NonGrammarTerminals.Add(LineComment);
#endregion
#endregion
@@ -347,6 +356,7 @@ namespace Demo this.Root = Prog; // Set grammar root
#endregion
+
#region 5. Operators precedence
RegisterOperators(1, "=", "+=", "-=");
RegisterOperators(2, "+", "-");
@@ -367,6 +377,23 @@ namespace Demo #region 6. Punctuation symbols
RegisterPunctuation("(", ")", "[", "]", "{", "}", ",", ";");
#endregion
+ */
+ #endregion
+
+ #region Simple grammar
+ NonTerminal Simple = new NonTerminal("SimpleProg");
+ NonTerminal Anything = new NonTerminal("Token");
+ Simple.Rule = Anything.Star() + Eof;
+ Anything.Rule = n;
+ foreach (string keyword in reserved) Anything.Rule = Anything.Rule | ToTerm(keyword);
+ Anything.Rule = Anything.Rule | ident;
+ foreach (string delimiter in delimiters) Anything.Rule = Anything.Rule | ToTerm(delimiter);
+
+ RegisterBracePair("{", "}");
+ RegisterBracePair("(", ")");
+
+ this.Root = Simple;
+ #endregion
}
}
}
diff --git a/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs b/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs index fd5c4702..4791df00 100644 --- a/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs +++ b/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs @@ -173,7 +173,7 @@ namespace Demo //Console.Write(result);
for (string line = reader.ReadLine(); !String.IsNullOrEmpty(line); line = reader.ReadLine()) {
- // each line is of the form: "x,y,w,z:arbitrary text"
+ // each line is of the form: "x,y,w,z:arbitrary text"
string[] numbersAndText = line.Split(':');
if (numbersAndText.Length != 2) {
AddErrorBecauseOfToolProblems(req, "Couldn't find colon in '" + line + "'");
diff --git a/Util/VS2010/Chalice/StartChalice.bat b/Util/VS2010/Chalice/StartChalice.bat index d91322ba..0e7401e4 100644 --- a/Util/VS2010/Chalice/StartChalice.bat +++ b/Util/VS2010/Chalice/StartChalice.bat @@ -3,7 +3,7 @@ echo ---------- Starting ------------ < nul >> c:\tmp\coo.out time < nul >> c:\tmp\coo.out
echo. < nul >> c:\tmp\coo.out
-call "c:\Program Files\Scala\bin\scala" -cp c:\boogie\Chalice\bin Chalice -nologo -vs %* 2>> c:\tmp\coo.out
+call "c:\Program Files\Scala\bin\scala" -cp c:\boogie\Chalice\bin chalice.Chalice -nologo -vs %* 2>> c:\tmp\coo.out
time < nul >> c:\tmp\coo.out
echo. < nul >> c:\tmp\coo.out
|