Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for simple import of other files #21

Merged
merged 5 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ checkstyle {
configFile = new File(rootDir, "checkstyle.xml")
ignoreFailures = false
showViolations = true
toolVersion = "5.9"
toolVersion = "6.18"
}

antlr4 {
Expand Down
24 changes: 18 additions & 6 deletions src/main/antlr4/Manifold.g4
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LINE_COMMENT: '//' ~[\r\n]* -> skip;
INTEGER_VALUE: [0-9]+;
BOOLEAN_VALUE: 'false' | 'true';
TYPE_KEYWORD: 'Type';
STRING_VALUE: '"' ( '\"' | ~["] )*? '"';

VISIBILITY_PUBLIC: 'public';

tupleTypeValueEntry: (IDENTIFIER ':')? typevalue ('=' expression)?;
tupleTypeValue: '(' tupleTypeValueEntry (',' tupleTypeValueEntry)* ')';
Expand All @@ -27,7 +30,7 @@ tupleValue:
'(' ')';

functionTypeValue: tupleTypeValue '->' tupleTypeValue;
functionValue: functionTypeValue '{' (expression EXPRESSION_TERMINATOR)* '}';
functionValue: functionTypeValue '{' (expression STATEMENT_TERMINATOR)* '}';

////////////////////////////////////////////////////////
// //
Expand Down Expand Up @@ -76,8 +79,8 @@ rvalue:
| INTEGER_VALUE # Integer
| functionValue # Function
| reference rvalue # FunctionInvocationExpression // TODO: function invocation needs to be 'reference arglist'
| reference # RValueExpression
| lvalue '=' rvalue # AssignmentExpression
| reference # ReferenceExpression
| VISIBILITY_PUBLIC? lvalue '=' rvalue # AssignmentExpression
| 'primitive' 'port' typevalue (':' tupleTypeValue)? # PrimitivePortDefinitionExpression
| 'primitive' 'node' functionTypeValue # PrimitiveNodeDefinitionExpression
;
Expand All @@ -89,14 +92,23 @@ lvalue:
;

// TODO: declarations as expressions
expression: /* declaration | */ rvalue;
expression:
rvalue
// | declaration
;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need expression when it is only doing unit productions? Right now the semantics of expression are questionable. In what situations should we be treating import expressions and rvalue expressions interchangeably? For instance what is the meaning of using an import expression in a tuple value entry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I thought expressions weren't nestable. I'll hoist it to a statement


statement:
expression #ExpressionStatment
| 'import' STRING_VALUE #ImportStatement
;

STATEMENT_TERMINATOR: ';';

EXPRESSION_TERMINATOR: ';';

////////////////////////////////////////////////////////
// //
// Schematic //
// //
////////////////////////////////////////////////////////

schematic: (expression EXPRESSION_TERMINATOR)*;
schematic: (statement STATEMENT_TERMINATOR)*;
Loading