76 research outputs found

    On the Relation between Context-Free Grammars and Parsing Expression Grammars

    Full text link
    Context-Free Grammars (CFGs) and Parsing Expression Grammars (PEGs) have several similarities and a few differences in both their syntax and semantics, but they are usually presented through formalisms that hinder a proper comparison. In this paper we present a new formalism for CFGs that highlights the similarities and differences between them. The new formalism borrows from PEGs the use of parsing expressions and the recognition-based semantics. We show how one way of removing non-determinism from this formalism yields a formalism with the semantics of PEGs. We also prove, based on these new formalisms, how LL(1) grammars define the same language whether interpreted as CFGs or as PEGs, and also show how strong-LL(k), right-linear, and LL-regular grammars have simple language-preserving translations from CFGs to PEGs

    Syntax Error Recovery in Parsing Expression Grammars

    Full text link
    Parsing Expression Grammars (PEGs) are a formalism used to describe top-down parsers with backtracking. As PEGs do not provide a good error recovery mechanism, PEG-based parsers usually do not recover from syntax errors in the input, or recover from syntax errors using ad-hoc, implementation-specific features. The lack of proper error recovery makes PEG parsers unsuitable for using with Integrated Development Environments (IDEs), which need to build syntactic trees even for incomplete, syntactically invalid programs. We propose a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for PEGs. This extension associates recovery expressions to labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point in the input and resume parsing. We give an operational semantics of PEGs with this recovery mechanism, and use an implementation based on such semantics to build a robust parser for the Lua language. We evaluate the effectiveness of this parser, alone and in comparison with a Lua parser with automatic error recovery generated by ANTLR, a popular parser generator.Comment: Published on ACM Symposium On Applied Computing 201

    Editorial

    Get PDF

    Left Recursion in Parsing Expression Grammars

    Full text link
    Parsing Expression Grammars (PEGs) are a formalism that can describe all deterministic context-free languages through a set of rules that specify a top-down parser for some language. PEGs are easy to use, and there are efficient implementations of PEG libraries in several programming languages. A frequently missed feature of PEGs is left recursion, which is commonly used in Context-Free Grammars (CFGs) to encode left-associative operations. We present a simple conservative extension to the semantics of PEGs that gives useful meaning to direct and indirect left-recursive rules, and show that our extensions make it easy to express left-recursive idioms from CFGs in PEGs, with similar results. We prove the conservativeness of these extensions, and also prove that they work with any left-recursive PEG. PEGs can also be compiled to programs in a low-level parsing machine. We present an extension to the semantics of the operations of this parsing machine that let it interpret left-recursive PEGs, and prove that this extension is correct with regards to our semantics for left-recursive PEGs.Comment: Extended version of the paper "Left Recursion in Parsing Expression Grammars", that was published on 2012 Brazilian Symposium on Programming Language

    Decoding Lua: formal semantics for the developer and the semanticist

    Get PDF
    We provide formal semantics for a large subset of the Lua programming language, in its version 5.2. We validate our model by mechanizing it and testing it against the test suite of the reference interpreter of Lua, con rming that our model accurately represents the language. In addition, we set us an ambitious goal: to target both a PL semanticist —not necessarily versed in Lua—, and a Lua developer —not necessarily versed in semantic frameworks. To the former, we present the peculiarities of the language, and how we model them in a traditional small-step operational semantics, embedded within Felleisen-Hieb’s reduction semantics with evaluation contexts. e mechanization is, naturally, performed in PLT Redex, the de facto tool for mechanizing reduction semantics. To the reader unfamiliar with such concepts, we provide, to our best possible within the space limitations, a gentle introduction of the model. It is our hope that developers of the di erent Lua implementations and dialects understand the model and consider it both for testing their work and for experimenting with new language features.Fil: Soldevila Raffa, Mallku Ernesto. Universidad Nacional de Córdoba. Facultad de Matemática, Astronomía y Física; Argentina. Consejo Nacional de Investigaciones Científicas y Técnicas. Centro Científico Tecnológico Conicet - Córdoba; ArgentinaFil: Ziliani, Beta. Consejo Nacional de Investigaciones Científicas y Técnicas. Centro Científico Tecnológico Conicet - Córdoba; Argentina. Universidad Nacional de Córdoba. Facultad de Matemática, Astronomía y Física; ArgentinaFil: Silvestre, Bruno. Universidade Federal de Goiás; BrasilFil: Fridlender, Daniel Edgardo. Consejo Nacional de Investigaciones Científicas y Técnicas. Centro Científico Tecnológico Conicet - Córdoba; Argentina. Universidad Nacional de Córdoba. Facultad de Matemática, Astronomía y Física; ArgentinaFil: Mascarenhas, Fabio. Universidade Federal do Rio de Janeiro; Brasi

    Outcomes of flexible ureteroscopic lithotripsy with holmium laser for upper urinary tract calculi

    Get PDF
    OBJECTIVE: To assess the perioperative and financial outcomes of flexible ureteroscopic lithotripsy with holmium laser for upper tract calculi in 44 patients. MATERIALS AND METHODS: Between February 2004 and September 2006, 44 patients treated for upper tract stone with flexible ureteroscopic lithotripsy were evaluated. Renal stones were associated with collecting system obstruction in 15 (34%) patients, failed extracorporeal shock-wave lithotripsy (SWL) occurred in 14 (32%) patients, unilateral multiple stones in 18 (41%) patients, and multiple bilateral stones in 3 (7%). In 29 (66%) patients, the stone was located in the inferior calyx. Perioperative and financial outcomes were also evaluated. RESULTS: 50 procedures were performed in 44 patients. The mean stone burden on preoperative CT scan was 11.5 ± 5.8 mm. The mean operative time was 61.3 ± 29.4 min. The stone free rate was 93.1% after one procedure and 97.7% after a second procedure, with overall complication rate of 8%. Therapeutic success occurred in 92% and 93% of patients with lower pole stones and SWL failure, respectively. Treatment failure of a single session was associated with presence of a stone size larger than 15 mm (p = 0.007), but not associated with inferior calyx location (p = 0.09). Surgical disposables were responsible for 78% of overall costs. CONCLUSION: Flexible ureteroscopy using holmium laser is a safe and effective option for the treatment of upper urinary tract calculi. In addition, it can be considered an attractive option as salvage therapy after SWL failure or kidney calculi associated with ureteral stones. Stone size larger than 15 mm is associated with single session treatment failure

    XRD, AFM, IR and TGA study of nanostructured hydroxyapatite

    Get PDF
    In this work, the synthetic hydroxyapatite (HAP) was studied using different preparation routes to decrease the crystal size and to study the temperature effect on the HAP nano-sized hydroxyapatite crystallization. X-ray diffraction (XRD) analysis indicated that all samples were composed by crystalline and amorphous phases . The sample with greater quantity of amorphous phase (40% of total mass) was studied. The nano-sized hydroxyapatite powder was heated and studied at 300, 500, 700, 900 and 1150 °C. All samples were characterized by XRD and their XRD patterns refined using the Rietveld method. The crystallites presented an anisotropic form, being larger in the [001] direction. It was observed that the crystallite size increased continuously with the heating temperature and the eccentricity of the ellipsoidal shape changed from 2.75 at 300 °C to 1.94, 1.43, 1.04 and 1.00 respectively at 500, 700, 900 and 1150 °C. In order to better characterize the morphology of the HAP the samples were also examined using atomic force microscopy (AFM), infrared spectrometry (IR) and thermogravimetric analysis (TGA)
    corecore