Skip to content

Commit

Permalink
Fix Rel single expression handling (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaSBCrea authored Jul 3, 2023
1 parent 2949d93 commit 237e7f3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 22 deletions.
10 changes: 5 additions & 5 deletions dist/index.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@relationalai/codemirror-lang-rel",
"version": "0.2.11",
"version": "0.2.12",
"description": "CodeMirror 6 language support for Rel",
"scripts": {
"test": "mocha test/test.js",
Expand Down
10 changes: 5 additions & 5 deletions src/parser.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/syntax.grammar
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@top Rel { declaration+ }
@top Rel { declaration+ | Annotation* Expression }

@skip { spaces | newLine | LineComment | BlockComment }

Expand All @@ -24,7 +24,8 @@
xor @right,
relname @left,
abstract @left,
parenOp
parenOp,
annot
}

declaration[@isGroup=Declaration] {
Expand Down Expand Up @@ -69,7 +70,7 @@ AnnotationKeyword {

AnnotationParams { commaSep1<BaseLiteral> }

Annotation { AnnotationKeyword ( "(" AnnotationParams ")" )? }
Annotation { AnnotationKeyword ( !annot "(" AnnotationParams ")" )? }

/*
* Declaration Statements
Expand Down
52 changes: 51 additions & 1 deletion test/cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Rel(
LogicalExpression(
BasicExpression(Literal(BaseLiteral(RelnameStringLiteral)))))))))))

# Attribute Statement
# Annotations

@inline
@function
Expand Down Expand Up @@ -515,3 +515,53 @@ Rel(
LogicalExpression(
BasicExpression(Literal(BaseLiteral(IntLiteral)))))))))))))))

# Expression

@inline
@static(1, :rel)
{
1 + 2;
2023-07-01;
2023-07-01T00:00:00Z
}

==>

Rel(
Annotation(AnnotationKeyword),
Annotation(
AnnotationKeyword,
AnnotationParams(BaseLiteral(IntLiteral), BaseLiteral(RelnameLiteral))
),
Expression(
UnionExpression(
JoinExpression(
OverrideExpression(
RestrictExpression(
LogicalExpression(
BasicExpression(
BoundedExpression(
Expression(
UnionExpression(
UnionExpression(
UnionExpression(
JoinExpression(
OverrideExpression(
RestrictExpression(
LogicalExpression(
BasicExpression(
BasicExpression(Literal(BaseLiteral(IntLiteral))),
OperatorKeyword,
BasicExpression(Literal(BaseLiteral(IntLiteral))))))))),
JoinExpression(
OverrideExpression(
RestrictExpression(
LogicalExpression(
BasicExpression(Literal(BaseLiteral(DateLiteral)))))))),
JoinExpression(
OverrideExpression(
RestrictExpression(
LogicalExpression(
BasicExpression(Literal(BaseLiteral(DateTimeLiteral))))))))))))))))))


0 comments on commit 237e7f3

Please sign in to comment.