S
S
syxme2021-11-03 13:07:38
Parsing
syxme, 2021-11-03 13:07:38

How to correctly describe the cs grammar to my syntax?

Here is an example of my syntax:

@style default {
    colors{
        baseColor:#00FF00;
        exColor:#00AA00;
    }
    dims{
        blockPadding:5dp
    }
}
@style dark:default {
    colors{
        baseColor:#0000FF;
    }

}

block {
    color:@colors.baseColor;
    padding:@dims.blockPadding;
}

newblock:block{
    width:100%;
    height:100%;
    padding:@colors.exColor;
}

Here is what I was able to put together (EBNF):
<style>  ::= "@style" " " <word> <block>
<extend> ::= <word> ":" <word> 
<class>  ::= (<word> | <extend>) <block>
<block>  ::= "{" <assign>* "}"
<number> ::= <digit> | <number> <digit>

<assign> ::= <word> ":" <word> ";"
<word>	 ::= <symb> | <word> <symb>
<symb>   ::= ([0-9] | [a-z])+ 
<digit>  ::=  [0-9]

Have I described everything correctly? Do you need to fix something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-11-03
@syxme

Not right. If you go through your grammar according to the example, then almost all lines will have errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question