summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2005-06-01 11:57:10 +0000
committerburaq <buraq@epfl.ch>2005-06-01 11:57:10 +0000
commit23e00d0a922e507b9ae6cefdf8a0345f7197774a (patch)
treec3b800cf8015109eea1f5f1235ca44c0720e0685 /sources
parent4e274a823295d16b4d2961e3b9eb38e191ccd9f0 (diff)
downloadscala-23e00d0a922e507b9ae6cefdf8a0345f7197774a.tar.gz
scala-23e00d0a922e507b9ae6cefdf8a0345f7197774a.tar.bz2
scala-23e00d0a922e507b9ae6cefdf8a0345f7197774a.zip
better name: ContentModelParser
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/dtd/Parser.scala144
1 files changed, 0 insertions, 144 deletions
diff --git a/sources/scala/xml/dtd/Parser.scala b/sources/scala/xml/dtd/Parser.scala
deleted file mode 100644
index 55cf18635f..0000000000
--- a/sources/scala/xml/dtd/Parser.scala
+++ /dev/null
@@ -1,144 +0,0 @@
-package scala.xml.dtd ;
-
-/** Parser for regexps (content models in DTD element declarations) */
-
-object Parser extends Scanner { // a bit too permissive concerning #PCDATA
- import ContentModel._ ;
-
- /** parses the argument to a regexp */
- def parse(s:String): ContentModel = { initScanner( s ); contentspec }
-
- // zzz parser methods zzz
- def accept( tok:int ) = {
- if( token != tok ) {
- if(( tok == STAR )&&( token == END )) // common mistake
- error("in DTDs, \n"+
- "mixed content models must be like (#PCDATA|Name|Name|...)*");
- else
- error("expected "+token2string(tok)+
- ", got unexpected token:"+token2string(token));
- }
- nextToken
- }
-
- // s [ '+' | '*' | '?' ]
- def maybeSuffix(s:RegExp) = token match {
- case STAR => nextToken; Star( s )
- case PLUS => nextToken; Sequ( s, Star( s ))
- case OPT => nextToken; Alt( Eps, s )
- case _ => s
- }
-
-
- // contentspec ::= EMPTY | ANY | (#PCDATA) | "(#PCDATA|"regexp)
-
- def contentspec: ContentModel = token match {
-
- case NAME => value match {
- case "ANY" => ANY
- case "EMPTY" => EMPTY
- case _ => error("expected ANY, EMPTY or '(' instead of " + value );
- }
- case LPAREN =>
-
- nextToken;
- sOpt;
- if( token != TOKEN_PCDATA )
- ELEMENTS(regexp);
- else {
- nextToken;
- token match {
- case RPAREN =>
- PCDATA
- case CHOICE =>
- val res = MIXED(choiceRest(Eps));
- sOpt;
- accept( RPAREN );
- accept( STAR );
- res
- case _ =>
- error("unexpected token:" + token2string(token) );
- }
- }
-
- case _ =>
- error("unexpected token:" + token2string(token) );
- }
- // sopt ::= S?
- def sOpt = if( token == S ) nextToken;
-
- // (' S? mixed ::= '#PCDATA' S? ')'
- // | '#PCDATA' (S? '|' S? atom)* S? ')*'
- /*
- def mixed = {
- accept( TOKEN_PCDATA );
- sOpt;
- if( token == RPAREN )
- PCDATA_
- else {
- val t = choiceRest( PCDATA_ );
- if( !isMixed( t ) )
- error("mixed content models must be like (#PCDATA.|.|.|.)*");
- accept( RPAREN );
- // lax: (workaround for buggy Java XML parser in JDK1.4.2)
- if( token == STAR ) accept( STAR );
- // strict:
- // accept( STAR );
- Star( t )
- }
- }
-*/
- // '(' S? regexp ::= cp S? [seqRest|choiceRest] ')' [ '+' | '*' | '?' ]
- def regexp:RegExp = {
- //Console.println("regexp, token = "+token2string(token));
- val p = particle;
- sOpt;
- maybeSuffix( token match {
- case RPAREN => nextToken; p
- case CHOICE => val q = choiceRest( p );accept( RPAREN ); q
- case COMMA => val q = seqRest( p ); accept( RPAREN ); q
- })
- }
-
-
- // seqRest ::= (',' S? cp S?)+
- def seqRest( p:RegExp ) = {
- var k = List( p );
- while( token == COMMA ) {
- nextToken;
- sOpt;
- k = particle::k;
- sOpt;
- }
- Sequ( k.reverse:_* )
- }
-
- // choiceRest ::= ('|' S? cp S?)+
- def choiceRest( p:RegExp ) = {
- var k = List( p );
- while( token == CHOICE ) {
- nextToken;
- sOpt;
- k = particle::k;
- sOpt;
- }
- Alt( k.reverse:_* )
- }
-
- // particle ::= '(' S? regexp
- // | name [ '+' | '*' | '?' ]
- def particle = {
- //Console.println("particle, token="+token2string(token));
- token match {
- case LPAREN => nextToken; sOpt; regexp;
- case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix( a )
- case _ => error("expected '(' or Name, got:"+token2string( token ));
- }
- }
-
- // atom ::= name
- def atom = token match {
- case NAME => val a = Letter(ElemName(value)); nextToken; a
- case _ => error("expected Name, got:"+token2string( token ));
- }
-}