[r571]: cmajor++ / CmDevEnv / Parser / Debugger.soul Maximize Restore History

Download this file

Debugger.soul    161 lines (131 with data), 6.1 kB

/*========================================================================
    Copyright (c) 2012-2013 Seppo Laakko
    http://sourceforge.net/projects/cmajor/
 
    Distributed under the GNU General Public License, version 3 (GPLv3).
    (See accompanying LICENSE.txt or http://www.gnu.org/licenses/gpl.html)

 ========================================================================*/

using DevCore;

namespace Parsers
{
    grammar DebuggerOutputGrammar
    {
        using stdlib;
        extern newline;

        DebuggerOutput(DebuggerOutputCollector collector)
            ::=
            (   "<cmdb.info<[[" FieldContent:info{ collector.Info = info; }
            |   "<cmdb.error<[[" FieldContent:error{ collector.Error = error; }
            |   "<cmdb.reply<[[" FieldContent:reply{ collector.Reply = reply; }
            )
            ;

        FieldContent:string
            ::= ((anychar - "]]>")*){ value = match; } "]]>" newline
            ;
    }

    grammar DebuggerReplyGrammar
    {
        using stdlib;
        extern spaces;
        extern newline;
        skip spaces;
        extern int: int;
        extern identifier: string;
        extern qualified_id: string;
        extern bool: bool;

        DebuggerReply: DebuggerReply
            ::= StartReply{ value = StartReply; }
            |   BreakpointReply{ value = BreakpointReply; }
            |   ProcessExitReply{ value = ProcessExitReply; }
            |   SignalReceivedReply{ value = SignalReceivedReply; }
            |   SourcePosReply{ value = SourcePosReply; }
            |   SetBreakpointReply{ value = SetBreakpointReply; }
            |   ClearBreakpointReply{ value = ClearBreakpointReply; }
            |   FrameReply{ value = FrameReply; }
            |   DebugLibrariesReply{ value = DebugLibrariesReply; }
            |   DebugLibraryStatusReply{ value = DebugLibraryStatusReply; }
            |   BreakOnThrowStatusReply{ value = BreakOnThrowStatusReply; }
            |   CallStackReply{ value = CallStackReply; }
            ;

        StartReply: DebuggerReply
            ::= (keyword("debugging") keyword("started") SourcePos:pos){ value = new StartReply(pos); }
            ;

        BreakpointReply: DebuggerReply
            ::= (keyword("breakpoint") int:bp SourcePos:bpPos){ value = new BreakpointReply(bp, bpPos); }
            ;

        ProcessExitReply: ProcessExitReply
            ::= (keyword("process") keyword("exited") keyword("with") keyword("code") int:exitCode){ value = new ProcessExitReply(exitCode); }
            ;

        SignalReceivedReply: SignalReceivedReply
            ::= (keyword("process") keyword("received") keyword("signal") identifier:signalId keyword("at") SourcePos:pos){ value = new SignalReceivedReply(signalId, pos); }
            ;

        SourcePosReply: DebuggerReply
            ::= SourcePos:pos{ value = new SourcePosReply(pos); }
            ;

        SetBreakpointReply: DebuggerReply
            ::= (keyword("breakpoint") int:bp keyword("at") SourcePos:pos){ value = new SetBreakpointReply(bp, pos); }
            ;

        ClearBreakpointReply: DebuggerReply
            ::= (keyword("breakpoint") int:bp keyword("deleted")){ value = new ClearBreakpointReply(bp); }
            ;

        CallStackReply: CallStackReply
            ::= empty{ value = new CallStackReply(); }
                (CallStackFrame:frame{ value.AddFrame(frame); })*
            ;

        DebugLibrariesReply: DebugLibrariesReply
            ::= empty{ value = new DebugLibrariesReply(); }
                keyword("libraries") ':'
                (DebugLibrary:lib{ value.AddLibrary(lib); })*
            ;

        DebugLibrary: DebugLibrary
            ::= keyword("library") '=' qualified_id:libName keyword("enabled") '=' bool:enabled keyword("exists") '=' bool:exists keyword("filepath") '=' AngleFilePath
            { 
                value = new DebugLibrary(libName, enabled, exists, AngleFilePath);
            }
            ;

        DebugLibraryStatusReply: DebugLibraryStatusReply
            ::= keyword("library") qualified_id:libName 
            (   keyword("enabled"){ value = new DebugLibraryStatusReply(true); } 
            |   keyword("disabled"){ value = new DebugLibraryStatusReply(false); }
            )
            ;

        BreakOnThrowStatusReply: BreakOnThrowStatusReply
            ::= keyword("break") keyword("on") keyword("throw")
            (   keyword("enabled"){ value = new BreakOnThrowStatusReply(true); }
            |   keyword("disabled"){ value = new BreakOnThrowStatusReply(false); }
            )
            ;

        CallStackFrame: CallStackFrame
            ::= (int:frame FunctionName:fun keyword("at") SourceFileLine:srcFileLine){ value = new CallStackFrame(frame, fun, srcFileLine); }
            ;

        FrameReply: FrameReply
            ::= (keyword("frame") int:frame FunctionName:fun keyword("at") SourceFileLine:srcFileLine){ value = new FrameReply(frame, fun, srcFileLine); }
            ;

        FunctionName: string
            ::= token('"' ((anychar - '"')*){ value = match; } '"')
            ;

        SourcePos: SourcePos
            ::= (SourceFileLine:fileLine ':' keyword("s") '=' LineCol:s ':' keyword("e") '=' LineCol:e)
            {
                value = new SourcePos(fileLine, s, e); 
            }
            ;

        SourceFileLine: SourceFileLine
            ::= token(FilePath ':' Line){ value = new SourceFileLine(FilePath, Line); }
            ;

        LineCol: LineCol
            ::= ('(' int:line ':' int:col ')'){ value = new LineCol(line, col); }
            ;

        FilePath: string
            ::= token(Drive? (anychar - ':')+){ value = match; }
            ;

        AngleFilePath: string
            ::= token('<' ((anychar - '>')+){ value = match; } '>')
            ;

        Line: int
            ::= int:line{ value = line; }
            ;

        Drive
            ::= letter ':'
            ;
    }
}