executeIfExecutableFitsFunctionObject::executeIfExecutableFitsFunctionObject
(
    const word& name,
    const Time& t,
    const dictionary& dict
)
:
    conditionalFunctionObjectListProxy(
        name,
        t,
        dict
    )
{
    // do it here to avoid the superclass-read being read twice
    readRegexp(dict);

    fileName exePath;

#ifdef darwin
    {
        char path[1024];
        uint32_t size = sizeof(path);
        if (_NSGetExecutablePath(path, &size) == 0) {
            exePath=string(path);
        }
    }
#elif defined(__linux__)
    {
        const int bufSize=1024;
        char path[bufSize];
        label length=readlink("/proc/self/exe",path,bufSize-1);
        path[length]='\0';
        exePath=string(path);
    }
#else
    Not yet implemented;
#endif

    executable_=exePath.name();

    if(debug) {
        Info << "Executable: " << executable_ << " "<< exePath << endl;
    }

#ifdef FOAM_FUNCTIONOBJECT_HAS_SEPARATE_WRITE_METHOD_AND_NO_START
    start();
#endif
}
bool executeIfExecutableFitsFunctionObject::read(const dictionary& dict)
{
    readRegexp(dict);
    return conditionalFunctionObjectListProxy::read(dict);
}
Token Scanner::onDefaultState()
{
    QChar first = m_src.peek();
    m_src.move();

    // Ignore new lines
    bool hasNewLine = false;
    while (isLineFeed(first)) {
        hasNewLine = true;
        m_line++;
        m_lineStartOffset = m_src.position();
        first = m_src.peek();
        m_src.setAnchor();
        m_src.move();
    }
    if (hasNewLine)
        m_tokenSequence.clear();

    Token token;

    if (first.isDigit()) {
        token = readFloatNumber();
    } else if (first == '\'' || first == '\"' || first == '`') {
        token = readStringLiteral(first, State_String);
    } else if (m_methodPattern.match(m_tokenSequence).hasMatch()) {
        token = readMethodDefinition();
    } else if (first.isLetter() || first == '_' || first == '@'
               || first == '$' || (first == ':' && m_src.peek() != ':')) {
        token = readIdentifier();
    } else if (first.isDigit()) {
        token = readNumber();
    } else if (first == '#') {
        token = readComment();
    } else if (first == '/') {
        token = readRegexp();
    } else if (first.isSpace()) {
        token = readWhiteSpace();
    } else if (first == ',') {
        token = Token(Token::OperatorComma, m_src.anchor(), m_src.length());
    } else if (first == '.') {
        token = Token(Token::OperatorDot, m_src.anchor(), m_src.length());
    } else if (first == '=' && m_src.peek() != '=') {
        token = Token(Token::OperatorAssign, m_src.anchor(), m_src.length());
    } else if (first == ';') {
        token = Token(Token::OperatorSemiColon, m_src.anchor(), m_src.length());
    } else if (first == '%') {
        token = readPercentageNotation();
    } else if (first == '{') {
        token = Token(Token::OpenBraces, m_src.anchor(), m_src.length());
    } else if (first == '}') {
        token = Token(Token::CloseBraces, m_src.anchor(), m_src.length());
    } else if (first == '[') {
        token = Token(Token::OpenBrackets, m_src.anchor(), m_src.length());
    } else if (first == ']') {
        token = Token(Token::CloseBrackets, m_src.anchor(), m_src.length());
        // For historic reasons, ( and ) are the Operator token, this will
        // be changed soon.
    } else if (first == '(' || first == ')') {
        token = Token(Token::Operator, m_src.anchor(), m_src.length());
    } else {
        token = readOperator(first);
    }

    m_tokenSequence += QString::number(token.kind);
    m_tokenSequence += '_';

    return token;
}