Skip to content

Commit

Permalink
Some fixes for flags:
Browse files Browse the repository at this point in the history
- Consume -- so that it works as expected for the boostrapped compiler.
- Print error messages for unknown long flags.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10609 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Nov 30, 2011
1 parent e96b091 commit 363b450
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
26 changes: 19 additions & 7 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -3793,17 +3793,29 @@ algorithm
end match;
end crefFirstIdentNoSubs;

public function crefIsIdent "
Returns the base-name of the Absyn.componentReference"
public function crefIsIdent
"Returns true if the component reference is a simple identifier, otherwise false."
input ComponentRef inComponentRef;
output Boolean bol;
output Boolean outIsIdent;
algorithm
bol := matchcontinue(inComponentRef)
case(CREF_IDENT(_,_)) then true;
case(_) then false;
end matchcontinue;
outIsIdent := match(inComponentRef)
case CREF_IDENT(name = _) then true;
else false;
end match;
end crefIsIdent;

public function crefIsQual
"Returns true if the component reference is a qualified identifier, otherwise false."
input ComponentRef inComponentRef;
output Boolean outIsQual;
algorithm
outIsQual := match(inComponentRef)
case CREF_QUAL(name = _) then true;
case CREF_FULLYQUALIFIED(componentRef = _) then true;
else false;
end match;
end crefIsQual;

public function crefLastSubs "function: crefLastSubs
Return the last subscripts of an Absyn.ComponentRef"
input ComponentRef inComponentRef;
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -562,6 +562,8 @@ public constant Message CHANGED_STD_VERSION = MESSAGE(208, SCRIPTING(), NOTIFICA
"Modelica language version set to %s due to loading of MSL %s.");
public constant Message SIMPLIFY_FIXPOINT_MAXIMUM = MESSAGE(209, TRANSLATION(), WARNING(),
"Expression simplification iterated to the fixpoint maximum, which may be a performance bottleneck. The last two iterations were: %s, and %s");
public constant Message UNKNOWN_OPTION = MESSAGE(210, SCRIPTING(), ERROR(),
"Unknown option %s.");
public constant Message UNBOUND_PARAMETER_WARNING = MESSAGE(500, TRANSLATION(), WARNING(),
"Parameter %s has neither value nor start value, and is fixed during initialization (fixed=true)");
public constant Message BUILTIN_FUNCTION_SUM_HAS_SCALAR_PARAMETER = MESSAGE(501, TRANSLATION(), WARNING(),
Expand Down
36 changes: 32 additions & 4 deletions Compiler/Util/Flags.mo
Expand Up @@ -856,6 +856,11 @@ algorithm
then
false;

// Flags beginning with - are consumed by the RML runtime, until -- is
// encountered. The bootstrapped compiler gets all flags though, so this
// case is to make sure that -- is consumed and not treated as a flag.
case ("--", _) then false;

// Flags that start with +.
else
equation
Expand Down Expand Up @@ -890,8 +895,6 @@ algorithm
local
array<Boolean> debug_flags;
array<FlagData> config_flags;
ConfigFlag config_flag;
String help_str;
list<String> values;

// Special case for +d, set the given debug flags.
Expand All @@ -913,14 +916,39 @@ algorithm
// All other configuration flags.
case (_, _, FLAGS(configFlags = config_flags))
equation
config_flag = List.getMemberOnTrue(inFlag, allConfigFlags, matchConfigFlag);
setConfigFlag(config_flag, config_flags, inValues);
parseConfigFlag(inFlag, inValues, config_flags);
then
();

end match;
end parseFlag2;

protected function parseConfigFlag
"Tries to look up the flag with the given name, and set it to the given value."
input String inFlag;
input list<String> inValues;
input array<FlagData> inFlags;
algorithm
_ := matchcontinue(inFlag, inValues, inFlags)
local
ConfigFlag config_flag;

case (_, _, _)
equation
config_flag = List.getMemberOnTrue(inFlag, allConfigFlags, matchConfigFlag);
setConfigFlag(config_flag, inFlags, inValues);
then
();

else
equation
Error.addMessage(Error.UNKNOWN_OPTION, {inFlag});
then
fail();

end matchcontinue;
end parseConfigFlag;

protected function setDebugFlag
"Enables a debug flag given as a string, or disables it if it's prefixed with -."
input String inFlag;
Expand Down

0 comments on commit 363b450

Please sign in to comment.