parse-tree

Add eObject to the parse tree programaticaly

烂漫一生 提交于 2019-12-11 22:23:23
问题 Here is a snapshot of my grammar: Sort: name=ID ; Variable name=ID ':' type=[Sort] My requirement is to have a predefined Sort let's call it Loc . There is no need for the user to define this sort, thus when a Variable is defined with a Loc type, Xtext should automatically reference it to my predefined Sort. How can I initiate the program so that at the beginning a Sort instance is generated? I already used the Factory method 'CreateSort' in my validator class, but no use. any idea? 回答1: Your

Parse Tree Of Context Free Grammar

馋奶兔 提交于 2019-12-11 20:26:08
问题 I'm trying to figure out how to do parse trees correctly to show whether a grammar is ambiguous or not. my grammar is S -> xSy | ySx | SS | e any help would be great. thanks in advance below is my crack at it... S / \ / \ x y / \ / \ x x y y 回答1: As a hint, pretty much any grammar with a production of the form S → SS will be ambiguous, because if you want to produce three S nonterminals you can do so in two ways: S S / \ / \ S S S S / \ / \ S S S S Assuming those S's can actually produce

Compiler Construction: Explicit Parse trees

自作多情 提交于 2019-12-08 10:43:36
问题 How can a compiler do without constructing an explicit parse tree? What are the benefits and drawbacks of explicit parse tree construction? I know that compiler can do construction without explicit parse tree by using SDT and running the semantics associated with it during parsing. But i want to know the benefits and drawbacks of the explicit parse tree construction. 回答1: Im a bit of a noob so please be paitient with me...thx... But to answer your question, a recursive-decent compilation

Steps to generate parse tree from CYK Algorithm (Natural Language Processing)

痴心易碎 提交于 2019-12-07 23:18:51
问题 I am currently working on a project involving NLP. I have implemented a CKY identifier as given in Jurafsky and Martin (algorithm on page 450). The table so produced actually stores the nonterminals in the table (instead of the usual boolean values). However, the only issue I am getting is to retrieve the parse tree. Here is an illustration of what my CKY identifier does: This is my grammar S -> NP VP S -> VP NP -> MODAL PRON | DET NP | NOUN VF | NOUN | DET NOUN | DET FILENAME MODAL -> 'MD'

How to read constituency based parse tree

百般思念 提交于 2019-12-07 06:12:31
问题 I have a corpus of sentences that were preprocessed by Stanford's CoreNLP systems. One of the things it provides is the sentence's Parse Tree (Constituency-based). While I can understand a parse tree when it's drawn (like a tree), I'm not sure how to read it in this format: E.g.: (ROOT (FRAG (NP (NN sent28)) (: :) (S (NP (NNP Rome)) (VP (VBZ is) (PP (IN in) (NP (NP (NNP Lazio) (NN province)) (CC and) (NP (NP (NNP Naples)) (PP (IN in) (NP (NNP Campania)))))))) (. .))) The original sentence is:

Steps to generate parse tree from CYK Algorithm (Natural Language Processing)

夙愿已清 提交于 2019-12-06 07:12:23
I am currently working on a project involving NLP. I have implemented a CKY identifier as given in Jurafsky and Martin (algorithm on page 450). The table so produced actually stores the nonterminals in the table (instead of the usual boolean values). However, the only issue I am getting is to retrieve the parse tree. Here is an illustration of what my CKY identifier does: This is my grammar S -> NP VP S -> VP NP -> MODAL PRON | DET NP | NOUN VF | NOUN | DET NOUN | DET FILENAME MODAL -> 'MD' PRON -> 'PPSS' | 'PPO' VP -> VERB NP VP -> VERB VP VP -> ADVERB VP VP -> VF VERB -> 'VB' | 'VBN' NOUN ->

How to turn a token stream into a parse tree [closed]

a 夏天 提交于 2019-12-05 11:39:59
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have a lexer built that streams out tokens from in input but I'm not sure how to build the next step in the process - the parse tree. Does anybody have any good resources or examples on how to accomplish this? I would really recommend http://www.antlr.org/ and of course the classic Dragon Compilers book. For an easy language like JavaScript it's not hard to hand roll a recursive descent parser, but it's almost

HTML Parse tree using Python 2.7

随声附和 提交于 2019-12-05 04:36:00
问题 I was trying to get configure one parse tree for the below HTML table,but couldn't form it.I want to see how the tree structure looks like!can anyone help me here? # <html> # <head> # <title> # The Dormouse's story # </title> # </head> # <body> # <p class="title"> # <b> # The Dormouse's story # </b> # </p> # <p class="story"> # Once upon a time there were three little sisters; and their names were # <a class="sister" href="http://example.com/elsie" id="link1"> # Elsie # </a> # , # <a class=

Is it possible to use Recursive Descent Parser to both verify the grammar AND build the parse tree at the same time?

坚强是说给别人听的谎言 提交于 2019-12-04 11:00:25
问题 Is it possible to generate a parse tree at the same time as I use recursive descent parser to check if the data matches grammar? If so, what approach would I use to build a tree as I recursively descent? Thanks, Boda Cydo. Note: I am new to parsing. (Asked several questions on SO already, and I am getting better with it.) 回答1: Yes, it's possible. How to do so will depend on the implementation you want. Here's a sample that might work for you: First, define your node: class ParseTreeNode {

Python AST from ANTLR Parse Tree?

末鹿安然 提交于 2019-12-04 09:53:35
I found an ANTLRv4 Python3 grammer , but it generates a parse-tree, which generally has many useless nodes. I'm looking for a known package to get a Python AST from that parse tree. Does something like this exist? EDIT: Clarification regarding use of the Python ast package: my project is in Java and I need to parse Python files. EDIT 2: By 'AST' I mean http://docs.python.org/2/library/ast.html#abstract-grammar , while by 'parse tree' I mean http://docs.python.org/2/reference/grammar.html . The following could be a start: public class AST { private final Object payload; private final List<AST>