coins.cfront
クラス Parser

java.lang.Object
  |
  +--coins.cfront.Parser
すべての実装インタフェース:
TokenId, TypeId

public class Parser
extends java.lang.Object
implements TokenId, TypeId

Parser for the C language.


フィールドの概要
static java.lang.String cppCommand
          The command string for invoking a preprocessor.
(パッケージプライベート)  Debug debug
           
(パッケージプライベート)  Evaluator evaluator
           
 int fDbgLevel
           
static java.lang.String invalidCChar
          Used to generate an identifier that never appears in a source program.
(パッケージプライベート)  Lex lex
           
(パッケージプライベート)  java.util.LinkedList pragmaList
           
 
インタフェース coins.ast.TokenId から継承したフィールド
AND_E, ANDAND, ARROW, ASM, AUTO, BAD_TOKEN, BREAK, CASE, CAST_OP, CHAR, CHAR_CONST, COND_OP, CONST, CONTINUE, DEFAULT, DIV_E, DO, DOUBLE, DOUBLE_CONST, ELLIPSIS, ELSE, ENUM, EOF, EQ, EXOR_E, EXTERN, FLOAT, FLOAT_CONST, FOR, FUNCALL, GE, GOTO, IDENTIFIER, IF, IGNORE, INDEX_OP, INLINE, INT, INT_CONST, LE, LONG, LONG_CONST, LONG_DOUBLE_CONST, LONGLONG_CONST, LSHIFT, LSHIFT_E, MINUS_E, MINUSMINUS, MOD_E, MUL_E, MUTABLE, NEQ, OR_E, OROR, PLUS_E, PLUSPLUS, PRAGMA, REGISTER, RESTRICT, RETURN, RSHIFT, RSHIFT_E, SHORT, SIGNED, SIZEOF, SKIP_GCC_ASM, SKIP_GCC_ATTRIBUTE, STATIC, STRING_L, STRING_WL, STRUCT, SWITCH, TYPEDEF, TYPEDEF_NAME, UINT_CONST, ULONG_CONST, ULONGLONG_CONST, UNION, UNSIGNED, VOID, VOLATILE, WHILE
 
インタフェース coins.ast.TypeId から継承したフィールド
ARRAY_T, CHAR_T, CONST_T, DOUBLE_T, ELLIPSIS_T, ENUM_BEGIN, ENUM_END, FLOAT_T, FUNCTION_T, INT_T, LONG_DOUBLE_T, LONG_LONG_T, LONG_T, NO_DIMENSION_T, OFFSET_T, POINTER_T, RESTRICT_T, RETURN_T, S_AUTO, S_EXTERN, S_INLINE, S_NONE, S_REGISTER, S_STATIC, SHORT_T, SIGNED_T, SIZE_T, STRUCT_BEGIN, STRUCT_END, UNION_BEGIN, UNION_END, UNSIGNED_T, VOID_T, VOLATILE_T
 
コンストラクタの概要
Parser(IoRoot ioroot, Lex lex, ToHirC tohirc)
          Constructs a parser.
 
メソッドの概要
protected  java.lang.String decodeTagName(java.lang.String tagName)
           
protected  void enterNewEnvironment()
           
protected  void exitEnvironment()
           
 SymbolTable getCurrentSymbolTable()
           
protected  java.lang.String getNewEncodedTag(java.lang.String name)
           
 boolean hasNext()
          Returns false if the parser reaches the end of file.
(パッケージプライベート)  boolean isTypedefedType(java.lang.String typename)
           
protected  Aggregate lookupEncodedTag(java.lang.String tagName)
           
protected  Declarator makeDeclarator(java.lang.String name, java.lang.String fname, int line)
          Creates a Declarator object.
protected  Function makeFunction(Declarator decl, Stmnt body)
          Creates a Function object.
protected  Struct makeStruct(java.lang.String name, DeclaratorList mems, java.lang.String fname, int line)
          Creates a Struct object.
protected  Union makeUnion(java.lang.String name, DeclaratorList mems, java.lang.String fname, int line)
          Creates a Union object.
 void parse(Backend backend, boolean verbose)
          Parses the whole source file.
 ASTList read()
          Reads a top-level declaration and returns a parse tree.
 void recordSymbol(java.lang.String name, Declarator d)
           
protected  java.lang.String recordTag(java.lang.String tagName)
          Declares that a struct/union will be declared later in the current name scope.
protected  void recordTag(java.lang.String tagName, Aggregate a)
           
static java.io.InputStream runCpp(java.lang.String source)
          Runs a preprocessor (gcc -E) and returns the input stream obtaining the output of the preprocessor.
 void showEpilogue()
           
protected  void showErrorMessage(ParseError e)
           
 void showErrorMessage(Stmnt pos, java.lang.String message)
           
 void showWarningMessage(java.lang.String message)
           
 long sizeofStruct(java.lang.String tagName)
           
 long sizeofUnion(java.lang.String tagName)
           
protected  java.lang.String toEncodedTag(java.lang.String tagName)
          Returns a new unique tag name if the given tag name overrides another one declared in an outer scope.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

invalidCChar

public static final java.lang.String invalidCChar
Used to generate an identifier that never appears in a source program.

関連項目:
定数フィールド値

debug

final Debug debug

lex

final Lex lex

evaluator

Evaluator evaluator

pragmaList

java.util.LinkedList pragmaList

fDbgLevel

public final int fDbgLevel

cppCommand

public static java.lang.String cppCommand
The command string for invoking a preprocessor.

コンストラクタの詳細

Parser

public Parser(IoRoot ioroot,
              Lex lex,
              ToHirC tohirc)
Constructs a parser.

パラメータ:
lex - a lexical analyzer
メソッドの詳細

runCpp

public static java.io.InputStream runCpp(java.lang.String source)
                                  throws java.io.IOException
Runs a preprocessor (gcc -E) and returns the input stream obtaining the output of the preprocessor.

java.io.IOException

isTypedefedType

boolean isTypedefedType(java.lang.String typename)

parse

public void parse(Backend backend,
                  boolean verbose)
           throws java.io.IOException
Parses the whole source file. This method repeatedly reads a top-level declaration and invokes Backend.compile(). See cfront.Backend#compile(ast.ASTList)

パラメータ:
verbose - true if an epilogue message is printed out.
java.io.IOException

hasNext

public boolean hasNext()
                throws java.io.IOException
Returns false if the parser reaches the end of file.

java.io.IOException

makeDeclarator

protected Declarator makeDeclarator(java.lang.String name,
                                    java.lang.String fname,
                                    int line)
Creates a Declarator object. This method should be overwritten if the client provides a subclass of Declarator and the parser must instantiate that subclass. The implementation in this class is as follows:


makeFunction

protected Function makeFunction(Declarator decl,
                                Stmnt body)
Creates a Function object. This method should be overwritten if the client provides a subclass of Function and the parser must instantiate that subclass. The implementation in this class is as follows:


makeStruct

protected Struct makeStruct(java.lang.String name,
                            DeclaratorList mems,
                            java.lang.String fname,
                            int line)
Creates a Struct object. This method should be overwritten if the client provides a subclass of Struct and the parser must instantiate that subclass. The implementation in this class is as follows:


makeUnion

protected Union makeUnion(java.lang.String name,
                          DeclaratorList mems,
                          java.lang.String fname,
                          int line)
Creates a Union object. This method should be overwritten if the client provides a subclass of Union and the parser must instantiate that subclass. The implementation in this class is as follows:


showErrorMessage

protected void showErrorMessage(ParseError e)

showErrorMessage

public void showErrorMessage(Stmnt pos,
                             java.lang.String message)

showWarningMessage

public void showWarningMessage(java.lang.String message)

showEpilogue

public void showEpilogue()

recordSymbol

public void recordSymbol(java.lang.String name,
                         Declarator d)

enterNewEnvironment

protected void enterNewEnvironment()

exitEnvironment

protected void exitEnvironment()

lookupEncodedTag

protected Aggregate lookupEncodedTag(java.lang.String tagName)

toEncodedTag

protected java.lang.String toEncodedTag(java.lang.String tagName)
Returns a new unique tag name if the given tag name overrides another one declared in an outer scope.


decodeTagName

protected java.lang.String decodeTagName(java.lang.String tagName)

getNewEncodedTag

protected java.lang.String getNewEncodedTag(java.lang.String name)

recordTag

protected java.lang.String recordTag(java.lang.String tagName)
                              throws ParseError
Declares that a struct/union will be declared later in the current name scope.

ParseError

recordTag

protected void recordTag(java.lang.String tagName,
                         Aggregate a)
                  throws ParseError
ParseError

sizeofStruct

public long sizeofStruct(java.lang.String tagName)
                  throws ParseError
ParseError

sizeofUnion

public long sizeofUnion(java.lang.String tagName)
                 throws ParseError
ParseError

read

public ASTList read()
             throws java.io.IOException
Reads a top-level declaration and returns a parse tree. This method returns a LIST of parse tree because it may divide the given declaration into a few simple declaration although the number of elements of the returned list is usually one. For example, is divided into the following two simple declarations:

Note that this method may return null.

java.io.IOException

getCurrentSymbolTable

public SymbolTable getCurrentSymbolTable()