Back to index

wims  3.65+svn20090927
Declaration.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007-2008 Mihai Preda.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 package org.javia.arity;
00018 
00019 class Declaration {
00020     private static final String NO_ARGS[] = {};
00021     String name;
00022     String args[];
00023     int arity;
00024     String expression;
00025 
00026     void parse(String source, Lexer lexer, DeclarationParser declParser) throws SyntaxException {
00027         int equalPos = source.indexOf('=');
00028         String decl;
00029 
00030         if (equalPos == -1) {
00031             decl       = null;
00032             expression = source;
00033             name  = null;
00034             args  = NO_ARGS;
00035             arity = DeclarationParser.UNKNOWN_ARITY;            
00036         } else {
00037             decl       = source.substring(0, equalPos);
00038             expression = source.substring(equalPos + 1);
00039             lexer.scan(decl, declParser);
00040             name  = declParser.name;
00041             args  = declParser.argNames();
00042             arity = declParser.arity;            
00043         }
00044         /*
00045         if (arity == DeclarationParser.UNKNOWN_ARITY) {
00046             args = IMPLICIT_ARGS;
00047         }
00048         */
00049     }
00050 }