Skip to content
Snippets Groups Projects
Commit df45bec6 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

StrSub to get substrings

parent 04e0b9fd
No related branches found
No related tags found
No related merge requests found
...@@ -408,6 +408,7 @@ StrChoice return tStrChoice; ...@@ -408,6 +408,7 @@ StrChoice return tStrChoice;
StrCmp return tStrCmp; StrCmp return tStrCmp;
StrFind return tStrFind; StrFind return tStrFind;
StrLen return tStrLen; StrLen return tStrLen;
StrSub return tStrSub;
StringToName return tStringToName; StringToName return tStringToName;
S2N return tStringToName; S2N return tStringToName;
SubFunction return tSubFunction; SubFunction return tSubFunction;
......
This diff is collapsed.
This diff is collapsed.
...@@ -200,7 +200,7 @@ struct doubleXstring{ ...@@ -200,7 +200,7 @@ struct doubleXstring{
%token tStr %token tStr
%token tStrCat tSprintf tPrintf tMPI_Printf tRead tPrintConstants %token tStrCat tSprintf tPrintf tMPI_Printf tRead tPrintConstants
%token tStrCmp tStrFind tStrLen %token tStrCmp tStrFind tStrLen
%token tStrChoice tUpperCase tLowerCase tLowerCaseIn %token tStrChoice tStrSub tUpperCase tLowerCase tLowerCaseIn
%token tNbrRegions tGetRegion tStringToName tNameToString %token tNbrRegions tGetRegion tStringToName tNameToString
%token tFor tEndFor tIf tElseIf tElse tEndIf tMacro tReturn tCall tCallTest %token tFor tEndFor tIf tElseIf tElse tEndIf tMacro tReturn tCall tCallTest
%token tTest tWhile tParse %token tTest tWhile tParse
...@@ -9362,6 +9362,24 @@ CharExprNoVar : ...@@ -9362,6 +9362,24 @@ CharExprNoVar :
} }
} }
| tStrSub LP CharExpr ',' FExpr ',' FExpr RP
{
std::string in = $3;
std::string out = in.substr((int)$5, (int)$7);
$$ = (char *)Malloc((out.size() + 1) * sizeof(char));
strcpy($$, out.c_str());
Free($3);
}
| tStrSub LP CharExpr ',' FExpr RP
{
std::string in = $3;
std::string out = in.substr((int)$5, std::string::npos);
$$ = (char *)Malloc((out.size() + 1) * sizeof(char));
strcpy($$, out.c_str());
Free($3);
}
| tSprintf LP CharExpr RP | tSprintf LP CharExpr RP
{ {
$$ = $3; $$ = $3;
......
This diff is collapsed.
...@@ -43,7 +43,7 @@ version, improved EigenSolve (quadratic EVP with SLEPC, EVP on real matrices), ...@@ -43,7 +43,7 @@ version, improved EigenSolve (quadratic EVP with SLEPC, EVP on real matrices),
new CosineTransform, MPI_Printf, SendMergeFileRequest parser commands, small new CosineTransform, MPI_Printf, SendMergeFileRequest parser commands, small
improvements and bug fixes. improvements and bug fixes.
2.4.3 (February 7, 2104): new mandatory 'Name' attribute to define onelab 2.4.3 (February 7, 2014): new mandatory 'Name' attribute to define onelab
variables in DefineConstant[] & co; minor bug fixes. variables in DefineConstant[] & co; minor bug fixes.
2.4.2 (Septembre 27, 2013): fixed function arguments in nested expressions; 2.4.2 (Septembre 27, 2013): fixed function arguments in nested expressions;
......
...@@ -1227,6 +1227,8 @@ Character expressions are defined as follows: ...@@ -1227,6 +1227,8 @@ Character expressions are defined as follows:
StrCat[ @var{expression-char} <,@dots{}> ] | StrCat[ @var{expression-char} <,@dots{}> ] |
Str[ @var{expression-char} <,@dots{}> ] Str[ @var{expression-char} <,@dots{}> ]
StrChoice[ @var{expression}, @var{expression-char}, @var{expression-char} ] | StrChoice[ @var{expression}, @var{expression-char}, @var{expression-char} ] |
StrSub[ @var{expression-char}, @var{expression}, @var{expression} ] |
StrSub[ @var{expression-char}, @var{expression} ] |
UpperCase [ @var{expression-char} ] | UpperCase [ @var{expression-char} ] |
Sprintf [ @var{expression-char} ] | Sprintf [ @var{expression-char} ] |
Sprintf[ @var{expression-char}, @var{expression-cst-list} ] | Sprintf[ @var{expression-char}, @var{expression-cst-list} ] |
...@@ -1243,18 +1245,22 @@ character expressions (@code{Str} adds a newline character after each ...@@ -1243,18 +1245,22 @@ character expressions (@code{Str} adds a newline character after each
string except the last) when creating a string. @code{Str} is also used string except the last) when creating a string. @code{Str} is also used
to create string lists (when @var{string-id} is followed by to create string lists (when @var{string-id} is followed by
@code{()}). @code{StrChoice} returns the first or second @code{()}). @code{StrChoice} returns the first or second
@var{expression-char} depending on the value of @var{expression-char} depending on the value of @var{expression}.
@var{expression}. @code{UpperCase} converts the @var{expression-char} to @code{StrSub} returns the portion of the string that starts at the
upper case. @code{Sprintf} is equivalent to the @code{sprintf} C character position given by the first @var{expression} and spans the
function (where @var{expression-char} is a format string that can number of characters given by the second @var{expression} or until the
contain floating point formatting characters: @code{%e}, @code{%g}, end of the string (whichever comes first; or always if the second
etc.). @code{NameToString} converts a variable name into a string. @var{expression} is not provided). @code{UpperCase} converts the
@code{GetString} allows to get the value of a ONELAB string variable @var{expression-char} to upper case. @code{Sprintf} is equivalent to the
(the optional second argument specifies the default value returned if @code{sprintf} C function (where @var{expression-char} is a format
the variable does not exist.) @code{Date} permits to access the current string that can contain floating point formatting characters: @code{%e},
date. @code{CurrentDirectory} and @code{CurrentDir} return the directory @code{%g}, etc.). @code{NameToString} converts a variable name into a
of the @code{.pro} file. @code{AbsolutePath} returns the absolute path string. @code{GetString} allows to get the value of a ONELAB string
of a file. @code{DirName} returns the directory of a variable (the optional second argument specifies the default value
returned if the variable does not exist.) @code{Date} permits to access
the current date. @code{CurrentDirectory} and @code{CurrentDir} return
the directory of the @code{.pro} file. @code{AbsolutePath} returns the
absolute path of a file. @code{DirName} returns the directory of a
file. @code{OnelabAction} returns the current ONELAB action file. @code{OnelabAction} returns the current ONELAB action
(e.g. @code{check} or @code{compute}). (e.g. @code{check} or @code{compute}).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment