328 questions
0
votes
0
answers
32
views
Alternative productions with Parboiled: match whole alternatives, not partial
I'm using Parboiled (in Kotlin) to implement a grammar like DOT, where an identifier (ID) can be:
a letter or underscore followed by letters/digits/underscores (e.g. abc, _a1)
a number (e.g. 123)
I ...
1
vote
1
answer
158
views
Is it possible to convert a parser made with YACC to a Haskell parser combinator?
I am looking at updating an old project that contained a YACC parser generator for parsing a specific file type. I want to improve the performance of this tool and was considering updating the parser. ...
0
votes
0
answers
33
views
Grammar for access to properties and calls to embedded functions
I'm writing a grammar for a small interpreter in PLY. The part I am working on and where I am having problems is the one that refers to expressions, since this can contain both access to properties ...
1
vote
0
answers
107
views
C# Parser generator that runs as a source generator
There are many parser generators for C#, but all that I've found laud the fact that there is no build step. As someone building a redistributable, trimmable, AOT optimized library, that is a downside.
...
1
vote
1
answer
66
views
How to add implicit multiplication to PHP PEG basic calculator grammar?
I have a problem with my PEG grammar in PHP that use php-peg (the project have more recent fork that is publish to packagist). My project is a fork of an expression parser that I want to replace with ...
0
votes
1
answer
87
views
How to match *anything* until a delimiter is encountered in RE-flex lexer?
I was using RE/flex lexer for my project. In that, I want to match the syntax corresponding to ('*)".*?"\1. For eg, it should match "foo", ''"bar"'', but should not match ...
1
vote
1
answer
262
views
How to improve performance of Nearley-based parser
I'm trying to parse SQL INSERT statements like:
INSERT INTO `Album` (`Title`, `ArtistId`) VALUES ('Blue Moods', 89);
using the following grammar written for Nearley:
main -> statement:*
statement ...
1
vote
1
answer
129
views
Solving a parsing conflict in SQLite grammar
I'm trying to extent the SQL language of SQLite at one point (file parse.y). I have a parsing conflict, however the lemon parser does not show anything besides a random "1 parsing conflicts."...
0
votes
1
answer
153
views
Convert a dfa to rule for a asterisk case
Here is a simple but very common grammar rule case in EBNF format, the Statements is a none terminal symbol and Statement is none terminal symbol:
Statements ::= (Statement ';')*
After converting ...
-1
votes
1
answer
355
views
How to convert a grammar into a parsing algorithm using a table?
Say I have a grammar like this:
match start
match first
match rule a
match rule b
match a
match string, "a"
match b
match string, "b("
match optional
match ...
1
vote
1
answer
397
views
Is there a type of parser generator that handles all deterministic context-free grammars?
I need a way of generating parsers for all deterministic context-free grammars.
I know that every deterministic context-free grammar can be parsed by some LR(k) parser. The problem is that I need to ...
0
votes
1
answer
93
views
Jison not assuming correct grammar
I'm creating a grammar in jison
This is my jison file:
sgr.jison
/*
AUX VARIABLES
*/
%{
var contratos = "(E1:ENTIDADE)-[C:CONTRATO] -> (E2:ENTIDADE)";
var dataArray = {};
function
...
0
votes
1
answer
278
views
ANTLR4 grammar for SML choking on positive integer literals
I'm building a parser for SML using ANTLR 4.8, and for some reason the generated parser keeps choking on integer literals:
# CLASSPATH=bin ./scripts/grun SML expression -tree <<<'1'
line 1:0 ...
0
votes
1
answer
224
views
Beaver parser generator shift-reduce conflicts connected to dangling else
I am feeding a (generated) grammar to Beaver parser generator. Multiple shift-reduce conflicts are caused by it seems like the dangling else problem in this rules:
Condition
= IF LPAR Expression....
0
votes
0
answers
133
views
Use huge Numpy array without storing it all in the memory
I have pickled a numpy array which contains cosine similarity matrix i have 8 GB Ram in my pc but whenever i want to use that pickled matrix i have to load it completely into the memory and it takes ...
1
vote
1
answer
96
views
Repetitions Grammar parsing S -> ( E ';' )+
I know how to parse grammars like this:
E -> E '*' E
E -> E '+' E
E -> N
N -> '0'
N -> '1'
But what if I have the following example grammar (with a "regex repitition"):
E -> 'e'
S -...
2
votes
0
answers
514
views
Parsing Implicit Multiplication
I've been trying to set up a rather simple math parser, and it's been working fine. Only I can't figure out how to put in implied multiplication.
I've been using lark as an lalr(1) parser.
Here's ...
0
votes
1
answer
675
views
BYACCJ: How do I include line number in my error message?
This is my current error handling function:
public void yyerror(String error) {
System.err.println("Error: "+ error);
}
This is the default error function I found on the BYACC/J homepage. I can't ...
0
votes
1
answer
142
views
Jison parser generator shift reduce conflict with parenthesis, how to solve?
I'm trying to implement parenthesis in my parser but i got conflict in my grammar.
"Conflict in grammar: multiple actions possible when lookahead token is )"
Here is simplified version of it:
// ...
3
votes
3
answers
2k
views
How to parse C++ comments with lark?
How can I write a rule to parse C++ comments either on a line alone or after other code?
I've tried lots of combinations, the latest one being:
?comment: "//" /[^\n]*/ NEWLINE
0
votes
1
answer
864
views
Eliminate indirect First-First conflicts in LL 1 grammar
I am trying to write a LL(1) parser generator and I am running into a issue with grammars which I know to be LL(1) but I cannot factor them properly.
For example consider the grammar:
S -> As Ao
...
-4
votes
1
answer
828
views
How to distinguish between minus sign and negative number in nom?
Using the parser generator nom, how can I write a parser which extracts the difference of the minus sign in the terms 1-2 and 1*-2 ?
In the first example, I expect the tokens 1, - and 2. In the ...
1
vote
1
answer
970
views
Haskell source generated by happy has error "parse error on input 'data'"
I'm trying out the happy parser generator of Haskell. After generating the module in happy.hs (no problem while generating!), I run the command ghc happy.hs, and I get the error: Line 297: parse error ...
3
votes
1
answer
488
views
Add operators during parsing
I try a bit the parser generators with Haskell, using Happy here. I used to use parser combinators before, such as Parsec, and one thing I can't achieve now with that is the dynamic addition (during ...
0
votes
1
answer
411
views
Java Jacc, AST and recursive visitor
I am trying to make a simple calculator using Jacc (a parser generator). I first need to create an AST and visit its nodes to make a Graphviz graph of it and later evaluate it.
In my Jacc file I can'...
0
votes
2
answers
501
views
How to generate a parser generator using Xtext?
I am planning to implement a meta language on top of Xtext. In other words, I am using the Xtext grammar to define my own meta language. This meta language can then be used to define a language (using ...
0
votes
1
answer
384
views
reference to where the parser is at when calling a rule listener in ANTLR4
I'm generating listeners in Python, but any language is ok for answers or comments.
I need to know if there's some reference to where in the parsing tree, or even better, in the token stream or in ...
1
vote
1
answer
2k
views
Convert a form of BNF grammar to g4 grammar
I'm trying to covert this BNF grammar for validating boolean expression which is currently being used in Swift. Now want to implement similar parser in Java. I came across Antlr4 lib and want to use ...
0
votes
1
answer
446
views
javacc (ph-javacc-maven-plugin) generates java switch with case `\`
I'm a newly to javacc. I tried to parse an existing javacc grammar (its the JSR341, EL 3.0 Grammar). It generates (almost) correct java. However, the generated code contains an illegal switch ...
1
vote
2
answers
2k
views
How to match the empty case in CUP parser grammar
I am using CUP to generate a parser, and I want an empty file to be an acceptable program. I have tried add the empty case to my start symbol, based off the response to a similar question here.
start ...
0
votes
1
answer
293
views
Resolve conflict in bison grammar with space separated expression lists + if/then/else
I have the following yacc/bison/happy grammar:
%token
if TokenIf
then TokenThen
else TokenElse
true TokenTrue
false TokenFalse
%...
3
votes
1
answer
504
views
Why are static parser generators more prevalent than dynamic ones?
A parser is a something that takes an input string and spits out an AST.
A parser generator is something that takes a grammar and spits out a parser.
A static parser generator is something that ...
1
vote
1
answer
1k
views
Write production rules (grammar rules) for an input expression consisting of list/array and SET operators
I have to do Lexing and Parsing using PLY. I have gone through http://www.dabeaz.com/ply/ply.html this documentation to learn about PLY and looked at the calculator example. I'm new to all this. So, ...
1
vote
3
answers
1k
views
ANTLR "no viable alternative at input" Error for parsing SAS code If Then Else
I am new to ANTLR and working on a parser to parse SAS code which mainly comprises of if then else if statements. I have created the following grammar to parse the code but I am getting error in ...
1
vote
2
answers
621
views
Javacc parser generator not recognizing my language (input)
I'm working with Javacc to build a parser for a Pascal subset.
This is my code:
PARSER_BEGIN(Pascal)
import java.io.*;
public class Pascal {
public static void main(String args[]) throws ...
0
votes
1
answer
2k
views
Lin Descriptor File parser
I am trying to research on the possible parsers, as part of developing a PC application that can be used for parsing a Lin Descriptor File. The current parser application is based on flex-bison ...
1
vote
0
answers
303
views
Transforming Grammar for Tiny Parser Generator
For a personal project to get me ready for an internship, I have decided to try and learn more about grammars and parsers. I wanted to make a simple compiler, and settled on a grammar that looks like ...
2
votes
1
answer
842
views
Grammar to negate two like characters in a lexer rule inside a single quoted string
ANLTR 4:
I need to support a single quoted string literal with escaped characters AND the ability to use double curly braces as an 'escape sequence' that will need additional parsing. So both of ...
2
votes
1
answer
487
views
Shift/reduce conflict in Happy grammar
I've got the following (heavily stripped down) Happy grammar
%token
'{' { Langle }
'}' { Rangle }
'..' { DotDot }
'::' { ColonColon }
'@' { At }
mut { Mut }
ident { ...
6
votes
1
answer
822
views
Solving parsing conflicts in a tiny Lemon grammar
I'm trying to learn basics of the Lemon parser generator, but I stuck quickly.
Here's a tiny grammar:
%right PLUS_PLUS.
%left DOT.
program ::= expr.
member_expr ::= expr DOT IDENTIFIER.
lhs_expr :...
2
votes
1
answer
1k
views
Simple custom expression parser [closed]
I looked a little over the available parsers on the net but don't really understand what is the most suitable for my custom expression.
(Antlr seems a little to heavyweight for my needs, but it's ...
3
votes
1
answer
604
views
Parser generator for writing a disassembler for a proprietary VM format
I am trying to write a disassembler for Mindstorms EV3 VM binaries, preferably in Python, since I am very familiar with it. I have docs detailing the instructions set, opcodes, parameters, data types ...
0
votes
0
answers
119
views
Would it be possible to write a parser generator for the Zend/PHP engine?
Out of curiosity, having been studying a few parser generator libraries (Flex, Bison, ANTLR, some LLVM related stuff), would it be possible to write a new parser generator for a pre-existing scripting ...
1
vote
1
answer
276
views
How to test grammar changes in yacc/lalr(1) for backwards compatibilitiy?
We have our scripting language that is already in use and we are improving it by adding new features etc.
My question is; What is the best way to test our grammer (not end app) for backwards ...
0
votes
0
answers
187
views
JFlex. Help writing a simple parser to extract numbers
I have some samples data extracted from a PDF and I need to write a parser to extract the text and numbers in an array for further manipulation. I think I should use JFlex but have no idea how to ...
2
votes
1
answer
180
views
Is it possible to use a with grako generated parser without grako?
see the title. For a small tool I am writing I wanted to introduce a simple boolean filter language and decided to do that "properly" and use a parser-generator. After playing around with grako a bit ...
1
vote
1
answer
193
views
Having trouble getting Yecc and Leex to work
I'm trying to create a very simple DSL that takes a string formatted like
GET /endpoint controller.action1 |> controller.action2
And turn it to something along the lines of
{"GET", "/endpoint", ...
-6
votes
1
answer
222
views
how can I create a truth table in turbo c [closed]
I have a project where I will create a truth table, and the user will input propositions and its operator and my program will output the truth values providing with a truth table.
I have following ...
6
votes
1
answer
2k
views
How to create a parser in erlang [closed]
How to create a parser in erlang that will take in a properly formed propositional formula and converts it into some internal representation.
Listing the available tools for creating a parser in ...
4
votes
1
answer
992
views
How can I use a JFlex lexer with JavaCC parser?
I'm trying to learn how to use JavaCC to write a parser.
I have already generated a lexer using JFlex, and that returns a list of tokens. Each token is it's own class.
I'm writing the production ...