parser-generator

Language parser library written in PHP

不打扰是莪最后的温柔 提交于 2019-11-29 09:25:31
问题 I am looking for a language parser written in PHP . The goal is to read a custom language , not read PHP code. Basically, I want to specify a language syntax, give a code snippet and get back a structure representing it. Then I can traverse that structure to execute the code snippet. I believe the structure will be an AST , but I don't know if this is the only option (I am not intimate with parsers and their vocabulary). I had a look at the Doctrine DQL parser but it doesn't seem like a

How to create a parser(lex/yacc)?

好久不见. 提交于 2019-11-29 04:13:48
问题 I'm having the following file and which need to be parsed --TestFile Start ASDF123 Name "John" Address "#6,US" end ASDF123 The lines start with -- will be treated as comment lines. and the file starts 'Start' and ends with end . The string after Start is the UserID and then the name and address will be inside the double quots. I need to parse the file and write the parsed data into an xml file. So the resulting file will be like <ASDF123> <Name Value="John" /> <Address Value="#6,US" /> <

How can I build a Truth Table Generator?

喜夏-厌秋 提交于 2019-11-29 01:10:51
问题 I'm looking to write a Truth Table Generator as a personal project. There are several web-based online ones here and here. (Example screenshot of an existing Truth Table Generator ) I have the following questions: How should I go about parsing expressions like: ((P => Q) & (Q => R)) => (P => R) Should I use a parser generator like ANTLr or YACC, or use straight regular expressions? Once I have the expression parsed, how should I go about generating the truth table? Each section of the

ANTLR Parser with manual lexer

江枫思渺然 提交于 2019-11-29 01:02:49
问题 I'm migrating a C#-based programming language compiler from a manual lexer/parser to Antlr. Antlr has been giving me severe headaches because it usually mostly works, but then there are the small parts that do not and are incredibly painful to solve. I discovered that most of my headaches are caused by the lexer parts of Antlr, rather than the parser. Then I noticed parser grammar X; and realized that perhaps I could have my manually written lexer and then an Antlr generated parser. So I'm

Can parser combinators be made efficient?

拈花ヽ惹草 提交于 2019-11-28 14:30:38
问题 Around 6 years ago, I benchmarked my own parser combinators in OCaml and found that they were ~5× slower than the parser generators on offer at the time. I recently revisited this subject and benchmarked Haskell's Parsec vs a simple hand-rolled precedence climbing parser written in F# and was surprised to find the F# to be 25× faster than the Haskell. Here's the Haskell code I used to read a large mathematical expression from file, parse and evaluate it: import Control.Applicative import Text

Processing repeatedly structured text file with python

馋奶兔 提交于 2019-11-28 10:33:33
I have a big text file structured in blocks like: Student = { PInfo = { ID = 0001; Name.First = "Joe"; Name.Last = "Burger"; DOB = "01/01/2000"; }; School = "West High"; Address = { Str1 = "001 Main St."; Zip = 12345; }; }; Student = { PInfo = { ID = 0002; Name.First = "John"; Name.Last = "Smith"; DOB = "02/02/2002"; }; School = "East High"; Address = { Str1 = "001 40nd St."; Zip = 12346; }; Club = "Football"; }; .... The Student blocks share the same entries like "PInfo", "School" and "Address", but some of them may have additional entries, such as the "Club" information for "John Smith"

PHP Lexer and Parser Generator? [closed]

你离开我真会死。 提交于 2019-11-28 06:33:51
I know question Lex and Yacc in PHP was asked before but 1 year ago. Is there any new mature PHP parser generator now? My searches drove me to the following ones, what do you think about them, any others? code.google.com/p/antlrphpruntime/ : The ANTLR PHP version but it seems to be very beta version and I think there is a lot of work to do. The advantage is that I can write the grammar in the ANTLR Works tool. pear.php.net/package/PHP_ParserGenerator/docs/0.1.7/ : I tried but it seems very complicated, to be used with the PHP_LexerGenerator. sourceforge.net/projects/lime-php/ : I didn't try

How do I get an Antlr Parser rule to read from both default AND hidden channel

眉间皱痕 提交于 2019-11-27 23:13:08
I use the normal whitespace separation into the hidden channel but I have one rule where I would like to include any whitespace for later processing but any example I have found requires some very strange manual coding. Is there no easy option to read from multiple channels like the option to put the whitespace there from the beginning. Ex. this is the WhiteSpace lexer rule WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;} ; And this is my rule where I would like to include whitespace raw : '{'? (~('{'))*; Basically it's a catch all rule to capture any content that does not match other

Lex and Yacc in PHP [closed]

泪湿孤枕 提交于 2019-11-27 19:01:51
Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I am sick of using regex to parse things that really shouldn't be parsed with regex... There's JLexPHP: https://github.com/wez/JLexPHP/blob/master/jlex.php I've not used it, but there's this: http://pear.php.net/package/PHP_ParserGenerator , which creates a PHP Parser from a Lemon grammar. The project seems to be inactive though. I also found this

Extracting text data from PDF files

大城市里の小女人 提交于 2019-11-27 11:13:00
Is it possible to parse text data from PDF files in R? There does not appear to be a relevant package for such extraction , but has anyone attempted or seen this done in R? In Python there is PDFMiner , but I would like to keep this analysis all in R if possible. Any suggestions? Linux systems have pdftotext which I had reasonable success with. By default, it creates foo.txt from a give foo.pdf . That said, the text mining packages may have converters. A quick rseek.org search seems to concur with your crantastic search. This is a very old thread, but for future reference: the pdftools R