3,305 questions
-7 votes
0 answers
27 views
Finding First and Follow set [closed]
I am trying to solve past year exam papers for Compilers and i am stuck with this question please help me Z → d | XY Z Y → c | ϵ X → Y | a like I am getting confused , its. a loop there and i cant ...
-1 votes
1 answer
55 views
Syntactically required and semantically relevant tokens in Python grammars
I am trying to parse code into AST. I want to keep minimum keywords and delimiters in the AST while keeping the semantics. In Python function definition def foo():, the last : is syntactically ...
5 votes
1 answer
136 views
An ambiguity in rust
Since we have no parentheses () in rust if and while conditions, there may be some ambiguous situations, e.g. while 0 > n {} {} is either parsed to be while (0 > n) {} and {} (2 statements), or ...
0 votes
0 answers
78 views
Antlr4 Grammar ambiguity
Having trouble understanding the ambiguity reported by Antlr4 (4.7.1): grammar Temp; start: expr; expr: IDENTIFIER '(' expr (',' expr)* ')' // function call | expr '.' slice2 ...
0 votes
0 answers
80 views
Parsing first-order logic formulas using parsing expression grammar
I am trying to implement a parser for first-order logic formulas in Rust using pest (which seems to be the reference in Rust). Apparently, this library is not based on context-free grammars but on ...
0 votes
0 answers
329 views
How to change a verb to its noun form (gerund) using the Stanford-NLP library?
I have individual verbs in a collection of String objects (thanks to How to find whether a word is a noun or a verb using Stanford parser?). Now for each, I would like to obtain the appropriate noun ...
1 vote
0 answers
67 views
Compiler Design - Question on third-order recursion in relation to expression grammar
In the "Compiler Design in C" book, below is a table on a simple expression grammar. According to the below excerpts: Note that the grammar is recursive. For example, Production 2 has ...
3 votes
1 answer
98 views
Python text tokenize code to output results from horizontal to vertical with grammar recognition
Below code tokenises the text and identifies the grammar of each tokenised word. import nltk from nltk.tokenize import sent_tokenize, word_tokenize from nltk.corpus import wordnet as wn #nltk....
2 votes
1 answer
78 views
Why does this grammar work using the Earley parser but not LALR(1)
I wrote this grammar to describe a simple patch procedure we use at work, operating on source code files. Engineers check in files of the form: {ignored space} //find_start {possible comment or ...
0 votes
1 answer
81 views
chars a-z used multiple times in set [A-Za-z_]
how to remove this warning : warning(180): AlgoGrammar.g4:54:13: chars a-z used multiple times in set [A-Za-z_] warning(180): AlgoGrammar.g4:54:23: chars a-z used multiple times in set [A-Za-z0-9_] ...
1 vote
1 answer
109 views
Dart multiple generic type evaluation
I saw an article about the Result pattern on the official flutter site(https://docs.flutter.dev/app-architecture/design-patterns/result), and I thought it was a good structure, so I tried to apply it ...
3 votes
1 answer
103 views
Is it possible to understand, when do semantic predicates work and when they don't?
Below are two grammars. In this grammar, semantic predicates do "work". I.e. if they are false, rules don't match and if they are true, rules do match: expr : term | expr asterisk ...
0 votes
0 answers
31 views
Is this correct grammar for Nearley?
Is the following good grammar for Nearley.js? It describes logical expressions with variables, negation, conjunction and parentheses. It's a bit convoluted (?), but I didn't know other way how to make ...
1 vote
1 answer
56 views
S/R conflict in Bison
I have a problem with a [relatively simple] grammar, a distilled version of a much bigger grammar. Bison reports one shift/reduce conflict, which is resolved incorrectly: the resulting parser fails to ...
5 votes
3 answers
152 views
I need a Raku grammar to change itself based on a different match
I want to write a Raku grammar to check a monthly report about work contribution factors, written in Racket/Scribble. The report is divided, at the highest level, into monthly sections, and beneath ...