Skip to content

Commit

Permalink
refactor: indent on external function call args
Browse files Browse the repository at this point in the history
  • Loading branch information
macintoshpie committed Jan 28, 2021
1 parent 0722bdd commit f87d07e
Show file tree
Hide file tree
Showing 9 changed files with 1,656 additions and 1,324 deletions.
23 changes: 23 additions & 0 deletions examples/functions-out.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
within Somewhere;
class MyClass
"Class to demo function definitions"
extends Modelica.Icons.BasesPackage;
function constructor
"Construct to connect to a schedule in EnergyPlus"
extends Modelica.Icons.Function;
input Integer input1
"input 1 comment";
output MyClass adapter;
external "C" adapter=ExternalFunctionCall(
param1,
param2,
param3);
end constructor;
function destructor
"Some comment"
extends Modelica.Icons.Function;
input Integer input2;
external "C" EnergyPlusInputVariableFree(
input2);
end destructor;
end MyClass;
21 changes: 21 additions & 0 deletions examples/functions.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
within Somewhere;
class MyClass
"Class to demo function definitions"
extends Modelica.Icons.BasesPackage;

function constructor
"Construct to connect to a schedule in EnergyPlus"
extends Modelica.Icons.Function;

input Integer input1 "input 1 comment";
output MyClass adapter;
external "C" adapter = ExternalFunctionCall(param1, param2, param3);
end constructor;

function destructor "Some comment"
extends Modelica.Icons.Function;

input Integer input2;
external "C" EnergyPlusInputVariableFree(input2);
end destructor;
end MyClass;
3 changes: 2 additions & 1 deletion modelicafmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func (l *modelicaListener) insertIndentBefore(rule antlr.ParserRuleContext) bool
parser.IExpression_listContext,
parser.IConstraining_clauseContext,
parser.IIf_expressionContext,
parser.IIf_expression_bodyContext:
parser.IIf_expression_bodyContext,
parser.IExternal_function_call_argumentContext:
return true
case parser.IString_commentContext:
return 0 == l.inAnnotation
Expand Down
1 change: 1 addition & 0 deletions modelicafmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var exampleFileTests = []struct {
}{
{"gmt-building.mo", "gmt-building-out.mo"},
{"gmt-coolingtower.mo", "gmt-coolingtower-out.mo"},
{"functions.mo", "functions-out.mo"},
}

func TestFormattingExamples(t *testing.T) {
Expand Down
11 changes: 10 additions & 1 deletion thirdparty/Modelica.g4
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@ language_specification
: STRING
;

// changed from original file
external_function_call
: (component_reference '=')? IDENT '(' (expression_list)? ')'
: (component_reference '=')? IDENT '(' (external_function_call_args)? ')'
;

external_function_call_args
: external_function_call_argument (',' external_function_call_argument)*
;

external_function_call_argument
: expression
;

element_list
Expand Down
4 changes: 3 additions & 1 deletion thirdparty/parser/Modelica.interp

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions thirdparty/parser/modelica_base_listener.go

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

12 changes: 12 additions & 0 deletions thirdparty/parser/modelica_listener.go

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

Loading

0 comments on commit f87d07e

Please sign in to comment.