Re: Formatter for Bison Input Files

2023-10-02 Thread Simon Richter
Hi, On 9/29/23 15:37, Julian Hapke wrote: having gotten used to using clang-format in C and C++ as well as black in Python, I would like to try and write a file formatter for a different language. There will be a lot of personal preferences involved in this, plus you will need to contend

Re: Matching opening and closing bracket question

2023-04-12 Thread Simon Richter
Hi Maury, On Wed, Apr 12, 2023 at 06:38:35PM -0400, Maury Markowitz wrote: > I am parsing a grammar that allows bracketing using (), [] and <>. It would > simplify my code if I could do… > open_bracket: ‘(‘ | ‘[‘ | ‘<‘ ; > close_bracket: ‘)‘ | ‘]‘ | ‘>’ ; > bracketed_expression :

Re: unknown type in %union{}

2022-10-10 Thread Simon Richter
Hi, On 10/10/22 13:37, andreas graeper via Users list for the GNU Bison parser generator wrote: i try to use an object ast.h/c/o and want a member of %union{ .. ast*a; .. } to be a pointer to a type defined inthere. The header 'ast.h' is included inside %{ .. %} These are inserted too late

Re: my bison didn't get correct value from flex

2022-07-05 Thread Simon Richter
Hi, On 7/5/22 09:55, 徐研辉 wrote: I encountered some troubles when attempting to recognize identifiers of C language via flex. As for program shown below, what identifier returned by flex was "main", whereas bison got"main(){ return3; }". This is a rather common mistake: yytext is a pointer

Re: How to set friendly name for "$end"?

2022-05-06 Thread Simon Richter
Hi, On 5/6/22 11:12 AM, Szabolcs Horvát wrote: This does indeed work in all versions, including 2.3. But it is unclear to me if it is safe. Is it guaranteed that $end corresponds to 0? To my knowledge, that is documented behaviour, yes. Simon OpenPGP_signature Description: OpenPGP

Re: Typescript grammar in Bison

2022-03-23 Thread Simon Richter
Hi, On 3/22/22 9:24 PM, Ricard Gascons wrote: I've been a Bison user for some time now, I've been writing some toy projects here and there. I was wondering if there are online resources I could find existing grammar from well-known programming languages? Just the definitions, not the

Re: Debug mode without using "-d"

2019-12-08 Thread Simon Richter
Hi Ervin, On 08.12.19 19:46, Ervin Hegedüs wrote: > I'ld like to control this feature through my code. I realized > that this option set a variable in generated source file: > 1577 extern int yy_flex_debug; > 1578 int yy_flex_debug = 1; > if (argc > 1) { > if (strcmp(argv[1],

Re: Very basic question about Flex

2019-02-22 Thread Simon Richter
Hi, On 22.02.19 15:00, workbe...@gmx.at wrote: > [a-zA-Z]+ { printf("%s is not a verb", yytext); } > > .|\n { ECHO; /* normal default anyway */ } > Now my question is when i enter one of the verbs it's working normaly > like expected, but when i enter for example 234someword i also get the >

Re: How to decide what to put in the lexer and the grammar respectively?

2019-02-17 Thread Simon Richter
Hi, On 17.02.19 14:08, Peng Yu wrote: > [[:alpha:]_][[:alnum:]_]=[[:digit:]+] { /* parse yytext to get the > name and value, then do the assignment */ } The main reason you are using a lexer is to avoid writing code for manual parsing. The lexer can already tell you where the equals sign is

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-08 Thread Simon Richter
Hi, On 08.02.19 02:01, Peng Yu wrote: > It seems to me that the parsing code could be made simpler by making > the parser reentrant. So there can be a parser parses anything not > heredoc and another parser just parse heredoc. And there should > different lexers for non-heredoc and heredoc. Is

Re: RFC: creating a bison-announce list

2019-01-06 Thread Simon Richter
Hi Akim, On 06.01.19 09:10, Akim Demaille wrote: > It has been asked to explicitly mark releases on git, so that CIs can trigger > builds automatically with these releases. This is already the case: tags > mark releases (betas and stable). Will it be sufficient to test betas with existing

Best Practice: lexer error to silent parser abort

2019-01-01 Thread Simon Richter
Hi, I'm wondering what would be the best way to communicate from the lexer to the parser that the lexer detected something it could not tokenize (in my case, characters outside the allowed character set). In this case, it is fairly obvious that we want to abort, without a call to yyerror, but

Re: RFC: creating a bison-announce list

2018-12-26 Thread Simon Richter
Hi, On 24.12.18 18:00, Akim Demaille wrote: > Recent history has shown that bugs are discovered too late, in a rather > incremental fashion (I'm about to release 3.2.4), mostly revealed when Bison > is finally updated in the main distros. I believe that much of this could > have been avoided

Re: issue related to bison

2017-11-09 Thread Simon Richter
Hi, On 09.11.2017 14:20, Bharath Gattu wrote: > Previously we are using Bison and Flex in our project to generate some parser > files automatically. > But now we don't want those files to be generated automatically. > We would like to keep the Bison accessible. But we want to remove the >

Re: Is C++ Variant Considered Stable?

2017-06-28 Thread Simon Richter
Hi, On 28.06.2017 21:33, David McCallum wrote: > Are there changes pending for variant that might break my parser somewhere > down the road? Or is it considered safe to use? Presumably, neither, as I haven't seen any feedback on its usefulness. One problem is that you cannot use

Re: yyscan_t was not declared in this scope

2017-02-28 Thread Simon Richter
Hi, On 28.02.2017 21:54, Jack Bates wrote: > TsConfigGrammar.h:125:20: error: ‘yyscan_t’ was not declared in this > scope > I can think of a couple ways around this -- what's the recommended > solution? I've found that none of these ways really work, so I just use %parse-param { void

Re: ECMAScript: Automatic Semicolon Insertion

2016-12-07 Thread Simon Richter
Hi, On Tue, Dec 06, 2016 at 10:52:06PM -0500, Ricky wrote: > Your syntax implies that [\n] should be treated as [;]. So why not use [\n] > as alternative? Unfortunately, it's not that easy. var foo = 4 + 5 is also allowed. This can lead to interesting hidden bugs[1], but is

ECMAScript: Automatic Semicolon Insertion

2016-12-06 Thread Simon Richter
Hi, I'm still building an ECMAScript parser, it's mostly running, except for the Automatic Semicolon Insertion rule in the language: if a token stream is invalid, but can be made valid by inserting a semicolon in front of the current token, pretend that a semicolon is there. For example inside a

Re: Using %prec to resolve shift-reduce

2016-11-30 Thread Simon Richter
Hi, On 30.11.2016 22:36, Hans Åberg wrote: >> %token IF "if" >> %token ELSE "else" > This can be resolved by adding > %nonassoc "then" > %nonassoc "else" Yes, that is what I'm doing, except that I need to give a precedence to the closing parenthesis because there is no explicit "then"

Using %prec to resolve shift-reduce

2016-11-30 Thread Simon Richter
Hi, I have a grammar for ECMAScript, which has both brace delimited statement blocks and brace delimited object literals, and allows expressions to be used as statements, which creates conflicting interpretations for "{ }" as either an empty block or an empty object. The specification clarifies