Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bool production #231

Open
dmjio opened this issue Jun 24, 2018 · 5 comments
Open

Bool production #231

dmjio opened this issue Jun 24, 2018 · 5 comments
Milestone

Comments

@dmjio
Copy link

dmjio commented Jun 24, 2018

This might be a huge oversight on my part. I noticed there are terminals for String, Integer, Double, etc. I was wondering if there was one for Bool. My current LBNF has rules in this form (see below), but since Bool wasn't present I had to define my own. Would it be hard to add Bool ?

StringValue . Value ::= String;                                                                                                                                                                                                                                                             
IntValue . Value ::= Integer;                                                                                                                                                                                                                                                               
BoolValue . Value ::= GBool;                                                                                                                                                                                                                                                                
FloatValue . Value ::= Double;
@andreasabel
Copy link
Member

I think it would not be hard. However, it is quite easy to roll your own Bool, thus it is not so urgent. In contrast, the other literals are very common across languages and not all trivial to define yourself.

@TheMaverickProgrammer
Copy link

TheMaverickProgrammer commented Aug 28, 2018

@dmjio I've written a scripting language with bnfc and booleans are just a string literal e.g.

DefVarBool. EVarType ::= EBool;
DefVarString. EVarType ::= String;
DefVarInt. EVarType ::= Integer;
DefVarId. EVarType ::= Ident;

...

DefBoolT. EBool ::= "true";
DefBoolF. EBool ::= "false";

@dmjio
Copy link
Author

dmjio commented Aug 28, 2018

@TheMaverickProgrammer, thanks, I ended up just going with alex and happy since I can lex directly into a Bool.

@andreasabel
Copy link
Member

andreasabel commented Oct 24, 2019

I think we could make Bool a predefined category and use True and False for the rule names. The user then writes:

True. Bool := "true";
False. Bool := "false";

or whatever concrete syntax they want for the truth values.

This is similar to how lists are treated (using Haskell's names for the list constructors).

@andreasabel
Copy link
Member

A more general solution is #267.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants