Skip to content

Commit

Permalink
Allow 1C-style comments
Browse files Browse the repository at this point in the history
  • Loading branch information
undeadcat committed Dec 14, 2016
1 parent 34c2ef3 commit 71b1d90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ packages/
*.nupkg
*.designer.cs
*.Designer.cs
.idea/
*.orig
*.rej
9 changes: 3 additions & 6 deletions Simple1C/Impl/Sql/SqlAccess/Parsing/QueryGrammar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ public QueryGrammar()
: base(false)
{
LanguageFlags = LanguageFlags.CreateAst;
var comment = new CommentTerminal("comment", "/*", "*/");
var lineComment = new CommentTerminal("line_comment", "--", "\n", "\r\n");
NonGrammarTerminals.Add(comment);
NonGrammarTerminals.Add(lineComment);
NonGrammarTerminals.Add(new CommentTerminal("sql_style_comment", "/*", "*/"));
NonGrammarTerminals.Add(new CommentTerminal("sql_style_line_comment", "--", "\n", "\r\n"));
NonGrammarTerminals.Add(new CommentTerminal("1c_commene", "//", "\n", "\r\n"));

not = Transient("not", ToTerm("NOT") | "НЕ");
by = NonTerminal("by", ToTerm("by") | "ПО", TermFlags.NoAstNode);
Expand Down Expand Up @@ -102,11 +101,9 @@ public QueryGrammar()
MarkPunctuation(asOpt);
AddOperatorReportGroup("operator");
AddToNoReportGroup("as", "КАК");

Root = root;
}


private static SelectFieldExpression ToSelectFieldExpression(ParseTreeNode n)
{
return new SelectFieldExpression
Expand Down
3 changes: 2 additions & 1 deletion Tests/Sql/ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public void CanSelectFieldWithAggregateFunctionName()
[Test]
public void IgnoreComments()
{
var selectClause = ParseSelect("select a/*,b*/ from testTable --where b > 10");
var selectClause = ParseSelect("select a/*,b*/ from testTable --where b > 10\r\n //group by a");
Assert.That(selectClause.WhereExpression, Is.Null);
Assert.That(selectClause.GroupBy, Is.Null);
Assert.That(selectClause.Fields.Count, Is.EqualTo(1));
var columnReference = selectClause.Fields[0].Expression as ColumnReferenceExpression;
Assert.IsNotNull(columnReference);
Expand Down

0 comments on commit 71b1d90

Please sign in to comment.