// (c) Copyright 2007 Hewlett-Packard Development Company, LP options { // Use \ u escapes in streams AND use a reader for the query // => get both raw and escaped unicode JAVA_UNICODE_ESCAPE = true ; UNICODE_INPUT = false ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(SSE_ParserCore) /* * (c) Copyright 2007 Hewlett-Packard Development Company, LP * All rights reserved. */ package com.hp.jena.sse.lang.parser ; import com.hp.jena.sse.lang.ParserSSEBase ; public class SSE_ParserCore extends ParserSSEBase { } PARSER_END(SSE_ParserCore) // Now has explicit WS control in the grammar. // Policy - eat trailing WS // ---- Entry points : check for EOF. void parse() : { } { { parseStart() ; } ()* TermOrList() { parseFinish() ; } } void term() : { } { { parseStart() ; } Term() { parseFinish() ; } } // ---- void TermOrList() : { } { ( Term() ()* | List() ) } void List() : { Token t ; } { // The OP token must exclude these ( t = ()* { listStart(t.beginLine, t.beginColumn) ; } BareList() t = ()* { listFinish(t.beginLine, t.beginColumn) ; } | t = ()* { listStart(t.beginLine, t.beginColumn) ; } BareList() t = ()* { listFinish(t.beginLine, t.beginColumn) ; } ) } void BareList() : { } { ( TermOrList() // White space swallowed )* } void Term() : { Token t ; } { Symbol() | IRIref() | PrefixedName() | Var() | Literal() | BlankNode() } void Symbol() : { Token t ; } { t = { emitSymbol(t.beginLine, t.beginColumn, t.image) ; } } void IRIref() : { Token t ; } { t = { emitIRI(t.beginLine, t.beginColumn, stripQuotes(t.image)) ; } } void PrefixedName() : { Token t ; } { t = { emitPName(t.beginLine, t.beginColumn, t.image) ; } } void Var() : { Token t ; } { // Includes "?" as a variable for anon variables. // Includes "??" as a variable for anon non-distinguished variables. // Includes non-distinguished variables as ??0 ( t = | t = ) { emitVar(t.beginLine, t.beginColumn, stripChars(t.image, 1)) ; } } void Literal() : { } { ( RDFLiteral() | NumericLiteral() // | BooleanLiteral() // Do as a symbol. ) } void BlankNode() : { Token t ; } { t = { emitBNode(t.beginLine, t.beginColumn, stripChars(t.image,2)) ; } //| // t = { return emitBNode(t.beginLine, t.beginColumn) ; } // t = { return emitBNode(t.beginLine, t.beginColumn) ; } } void RDFLiteral() : { Token t = null ; int currLine ; int currColumn ; String lex ; String lang = null ; String dt_iri = null ; String dt_pn = null ; } { ( t = { lex = stripQuotes(t.image) ; } | t = { lex = stripQuotes(t.image) ; } | t = { lex = stripQuotes3(t.image) ; } | t = { lex = stripQuotes3(t.image) ; } ) { currLine = t.beginLine ; currColumn = t.beginColumn ; } { token_source.SwitchTo(LITERAL) ; } // Optional lang tag and datatype. ( t = { lang = stripChars(t.image, 1) ; } { token_source.SwitchTo(DEFAULT) ; } | { token_source.SwitchTo(DEFAULT) ; } ( t = { dt_iri = stripQuotes(t.image) ; } | t = { dt_pn = t.image ; } ) )? { emitLiteral(currLine, currColumn, lex, lang, dt_iri, dt_pn) ; } } void NumericLiteral() : { Token t ; } { t = { emitLiteralInteger(t.beginLine, t.beginColumn, t.image) ; } | t = { emitLiteralDecimal(t.beginLine, t.beginColumn, t.image) ; } | t = { emitLiteralDouble(t.beginLine, t.beginColumn, t.image) ; } } // Symbol! // Node BooleanLiteral() : {} // { // { return XSD_TRUE ; } // | // { return XSD_FALSE ; } // } // No whitespace skipping. #undef SKIP #include "tokens.inc" #include "copyright.inc" /* # Local Variables: # tab-width: 4 # indent-tabs-mode: nil # comment-default-style: "//" # End: */