Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to find COM port for a specific USB devices connected. Pin
Gerry Schmitz19-May-15 17:56
mveGerry Schmitz19-May-15 17:56 
AnswerRe: How to find COM port for a specific USB devices connected. Pin
Member 24584672-Jun-15 20:57
Member 24584672-Jun-15 20:57 
QuestionGrammar in GOLD for generic constructs Pin
Sascha Lefèvre17-May-15 10:08
professionalSascha Lefèvre17-May-15 10:08 
AnswerRe: Grammar in GOLD for generic constructs Pin
Kenneth Haugland18-May-15 23:27
mvaKenneth Haugland18-May-15 23:27 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre19-May-15 1:55
professionalSascha Lefèvre19-May-15 1:55 
AnswerRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 0:27
professionalManfred Rudolf Bihy19-May-15 0:27 
AnswerRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 0:36
professionalManfred Rudolf Bihy19-May-15 0:36 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre19-May-15 1:51
professionalSascha Lefèvre19-May-15 1:51 
Quote:
Does this GOLD CC allow for multiple token lookahead or is it strictly LALR(1)?
It's strictly LALR(1).

Without knowing too much about parsers I had a gut feeling this might be the issue here. But I'm hoping that it's somehow possible to write the grammar in a way that one lookahead will suffice without butchering the syntax Big Grin | :-D

The reason why I don't want to use another parser generator is that there's a framework/execution engine for GOLD which simplifies and beautifies the code you have to write for your interpreter - take a look at this:
C#
public class If : Statement
{
    private readonly Expression _test;
    private readonly Statement _falseStatement;
    private readonly Statement _trueStatement;

    [Rule(@"<Stm> ::= ~if ~'(' <Expr> ~')' <Stm>")]
    public If(Expression _test, Statement trueStatement)
        : this(_test, trueStatement, null)
    {
    }

    [Rule(@"<Stm> ::= ~if ~'(' <Expr> ~')' <Then Stm> ~else <Stm>")]
    [Rule(@"<Then Stm> ::= ~if ~'(' <Expr> ~')' <Then Stm> ~else <Then Stm>")]
    public If(Expression test, Statement trueStatement, Statement falseStatement)
    {
        _test = test;
        _trueStatement = trueStatement;
        _falseStatement = falseStatement;
    }

    protected override void DoExecute(IExecutionContext ctx)
    {
        if (Convert.ToBoolean(_test.GetValue(ctx)))
            _trueStatement.Execute(ctx);
        else if (_falseStatement != null)
            _falseStatement.Execute(ctx);
    }
}

You basically have nothing to do than write classes "like that" for your productions, put a Rule-attribute on the constructor(s), feed a source code into a "SematicProcessor"-class of that framework and it'll instantiate all those classes for you representing the fed program and you can call DoExecute(..) on the top node Big Grin | :-D

It's for "yet another embeddable scripting engine" I wrote mainly for self-education. It doesn't bring a whole lot of new features to the table but it has a (IMO) very interesting twist which is why I intend to write an article about it. It's 90% finished (ignoring generics) so I wouldn't want to switch to another parser generator just for being able to replicate the C# syntax for generics - but it would be nice to have because you could just "drop in" existing C# code.

cheers, Sascha
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 4:54
professionalManfred Rudolf Bihy19-May-15 4:54 
GeneralRe: Grammar in GOLD for generic constructs Pin
Brisingr Aerowing19-May-15 6:12
professionalBrisingr Aerowing19-May-15 6:12 
GeneralRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 9:28
professionalManfred Rudolf Bihy19-May-15 9:28 
GeneralRe: Grammar in GOLD for generic constructs Pin
Brisingr Aerowing19-May-15 17:28
professionalBrisingr Aerowing19-May-15 17:28 
GeneralRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 5:34
professionalManfred Rudolf Bihy19-May-15 5:34 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre19-May-15 7:01
professionalSascha Lefèvre19-May-15 7:01 
GeneralRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy19-May-15 8:27
professionalManfred Rudolf Bihy19-May-15 8:27 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre19-May-15 8:37
professionalSascha Lefèvre19-May-15 8:37 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre20-May-15 2:46
professionalSascha Lefèvre20-May-15 2:46 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre23-May-15 8:04
professionalSascha Lefèvre23-May-15 8:04 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre8-Jun-15 20:20
professionalSascha Lefèvre8-Jun-15 20:20 
GeneralRe: Grammar in GOLD for generic constructs Pin
Manfred Rudolf Bihy8-Jun-15 20:28
professionalManfred Rudolf Bihy8-Jun-15 20:28 
GeneralRe: Grammar in GOLD for generic constructs Pin
Sascha Lefèvre8-Jun-15 20:33
professionalSascha Lefèvre8-Jun-15 20:33 
Questionhelppppp Pin
Member 1169697217-May-15 2:38
Member 1169697217-May-15 2:38 
AnswerRe: helppppp Pin
Kornfeld Eliyahu Peter17-May-15 3:33
professionalKornfeld Eliyahu Peter17-May-15 3:33 
AnswerRe: helppppp Pin
OriginalGriff17-May-15 3:59
mveOriginalGriff17-May-15 3:59 
GeneralRe: helppppp Pin
Member 1169697217-May-15 6:39
Member 1169697217-May-15 6:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.