summaryrefslogtreecommitdiff
path: root/misc/pascal/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-05 13:56:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-05 13:56:40 +0000
commite28c2fe16466f245edd80d0f95ff9a5e16f1ca1d (patch)
tree5f89f71780880ab0b0e331ae7adc6d0aeecd57c7 /misc/pascal/include
parent5a1b9567757d690d771fe673ef68b636377b2e4d (diff)
downloadnuttx-e28c2fe16466f245edd80d0f95ff9a5e16f1ca1d.tar.gz
nuttx-e28c2fe16466f245edd80d0f95ff9a5e16f1ca1d.tar.bz2
nuttx-e28c2fe16466f245edd80d0f95ff9a5e16f1ca1d.zip
Add header files
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@492 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/pascal/include')
-rw-r--r--misc/pascal/include/pas.h114
-rw-r--r--misc/pascal/include/paslib.h67
-rw-r--r--misc/pascal/include/pblck.h51
-rw-r--r--misc/pascal/include/pdefs.h334
-rw-r--r--misc/pascal/include/pedefs.h270
-rw-r--r--misc/pascal/include/perr.h40
-rw-r--r--misc/pascal/include/pexpr.h92
-rw-r--r--misc/pascal/include/pfdefs.h93
-rw-r--r--misc/pascal/include/pfunc.h57
-rw-r--r--misc/pascal/include/pgen.h92
-rw-r--r--misc/pascal/include/pinsn.h80
-rw-r--r--misc/pascal/include/plink.h52
-rw-r--r--misc/pascal/include/plreloc.h59
-rw-r--r--misc/pascal/include/plsym.h61
-rw-r--r--misc/pascal/include/podefs.h204
-rw-r--r--misc/pascal/include/pprgm.h47
-rw-r--r--misc/pascal/include/pproc.h49
-rw-r--r--misc/pascal/include/pstm.h47
-rw-r--r--misc/pascal/include/ptbl.h78
-rw-r--r--misc/pascal/include/ptdefs.h209
-rw-r--r--misc/pascal/include/ptkn.h58
-rw-r--r--misc/pascal/include/punit.h51
-rw-r--r--misc/pascal/include/pxdefs.h232
23 files changed, 2437 insertions, 0 deletions
diff --git a/misc/pascal/include/pas.h b/misc/pascal/include/pas.h
new file mode 100644
index 000000000..5a4829948
--- /dev/null
+++ b/misc/pascal/include/pas.h
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * pas.h
+ * External Declarations associated with pas.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PAS_H
+#define __PAS_H
+
+/***************************************************************************
+ * Compilation Switches
+ ***************************************************************************/
+
+#define LSTTOFILE 1
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "pdefs.h"
+#include "pofflib.h"
+
+/***************************************************************************
+ * Definitions
+ ***************************************************************************/
+
+/* This is a helper macro just to make things pretty in the source code */
+
+#define FP0 (&fileState[0]) /* Main file description */
+#define FP (&fileState[includeIndex]) /* Current file description */
+#define FPP (&fileState[includeIndex-1]) /* Previous file description */
+#define IS_NESTED_UNIT ((includeIndex > 0) && (FP->kind == eIsUnit))
+
+/***************************************************************************
+ * Global Types
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Variable
+ ***************************************************************************/
+
+extern uint16 token; /* Current token */
+extern uint16 tknSubType; /* Extended token type */
+extern sint32 tknInt; /* Integer token value */
+extern float64 tknReal; /* Real token value */
+extern STYPE *tknPtr; /* Pointer to symbol token */
+extern FTYPE files[MAX_FILES+1]; /* File Table */
+extern fileState_t fileState[MAX_INCL]; /* State of all open files */
+
+/* sourceFileName : Source file name from command line
+ * includePath[] : Pathes to search when including file
+ */
+
+extern char *sourceFileName;
+extern char *includePath[MAX_INCPATHES];
+
+extern poffHandle_t poffHandle; /* Handle for POFF object */
+
+extern FILE *poffFile; /* POFF output file */
+extern FILE *errFile; /* Error file pointer */
+extern FILE *lstFile; /* List file pointer */
+
+extern WTYPE withRecord; /* RECORD of WITH statement */
+extern sint16 level; /* Static nesting level */
+extern sint16 includeIndex; /* Include file index */
+extern sint16 nIncPathes; /* Number pathes in includePath[] */
+extern uint16 label; /* Last label number */
+extern sint16 nsym; /* Number symbol table entries */
+extern sint16 nconst; /* Number constant table entries */
+extern sint16 sym_strt; /* Symbol search start index */
+extern sint16 const_strt; /* Constant search start index */
+extern sint16 err_count; /* Error counter */
+extern sint16 nfiles; /* Program file counter */
+extern sint32 warn_count; /* Warning counter */
+extern sint32 dstack; /* data stack size */
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void openNestedFile (const char *fileName);
+extern void closeNestedFile (void);
+
+#endif /* __PAS_H */
diff --git a/misc/pascal/include/paslib.h b/misc/pascal/include/paslib.h
new file mode 100644
index 000000000..6137cc68e
--- /dev/null
+++ b/misc/pascal/include/paslib.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * paslib.h
+ * External Declarations associated with paslib
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PASLIB_H
+#define __PASLIB_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "keywords.h"
+#include "pdefs.h"
+#include "pofflib.h"
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+/* File name extension helper */
+
+extern boolean extension(const char *inName, const char *ext, char *outName,
+ boolean force_default);
+
+/* Math helpers */
+
+extern sint32 signExtend16(uint16 arg16);
+extern sint32 signExtend25(uint32 arg25);
+
+/***************************************************************************
+ * Global Variables
+ ***************************************************************************/
+
+#endif /* __PASLIB_H */
+
diff --git a/misc/pascal/include/pblck.h b/misc/pascal/include/pblck.h
new file mode 100644
index 000000000..22b6b75b4
--- /dev/null
+++ b/misc/pascal/include/pblck.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * pblck.h
+ * External Declarations associated with pblck.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PBLCK_H
+#define __PBLCK_H
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void block(void);
+extern void declarationGroup(sint32 beginLabel);
+extern void constantDefinitionGroup(void);
+extern void typeDefinitionGroup(void);
+extern void variableDeclarationGroup(void);
+extern sint16 formalParameterList(STYPE *procPtr);
+
+#endif /* __PBLCK_H */
diff --git a/misc/pascal/include/pdefs.h b/misc/pascal/include/pdefs.h
new file mode 100644
index 000000000..daa73736b
--- /dev/null
+++ b/misc/pascal/include/pdefs.h
@@ -0,0 +1,334 @@
+/***********************************************************************
+ * pdefs.h
+ * General definitions for the Pascal Compiler/Optimizer
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PDEFS_H
+#define __PDEFS_H
+
+/***********************************************************************
+ * Included Files
+ ***********************************************************************/
+
+#include <stdio.h> /* for FILE */
+#include <config.h>
+
+/***********************************************************************
+ * Definitions
+ ***********************************************************************/
+
+/* Size Parameters -- some of these can be overridden from the
+ * command line.
+ */
+
+#define MAX_SYM (4096)
+#define MAX_STRINGS (65536)
+#define MAX_INCL 3
+#define MAX_FILES 8 /* max number of opened files */
+#define FNAME_SIZE 40 /* max size file name */
+#define LINE_SIZE 256 /* max size of input line buffer */
+#define FNAME_SIZE 40 /* max size of file name */
+#define MAX_INCPATHES 8 /* max number of include pathes */
+
+/* Data Storage Sizes */
+
+#ifdef CONFIG_INSN16
+# define sINT_SIZE 2
+# define MAXINT 32767
+# define MININT -32768
+# define BITS_IN_INTEGER 16
+# define MAXUINT 0xffff
+# define MINUINT 0
+#endif
+
+#ifdef CONFIG_INSN32
+# define sINT_SIZE 4
+# define MAXINT 2147483647
+# define MININT -2147483648
+# define BITS_IN_INTEGER 32
+# define MAXUINT 0xffffffff
+# define MINUINT 0
+#endif
+
+#define sCHAR_SIZE 1
+#define sBOOLEAN_SIZE sINT_SIZE
+#define sREAL_SIZE 8
+#define sPTR_SIZE sINT_SIZE
+#define sRETURN_SIZE (3*sPTR_SIZE)
+
+#define sSTRING_HDR_SIZE 2
+#define sSTRING_SIZE 256 /* size(2) + string(255) */
+#define sSTRING_MAX_SIZE (sSTRING_SIZE - 2) /* string storage size(254) */
+#define sRSTRING_SIZE (sPTR_SIZE + sINT_SIZE) /* ptr + size */
+#define sCSTRING_SIZE (sizeof(void*)) /* absolute C pointer */
+
+#define MAXCHAR 255
+#define MINCHAR 0
+
+/* Bit values for the 'flags' field of the symType_t, symProc_t, and
+ * symVar_t (see below)
+ */
+
+#define STYPE_VARSIZE 0x01 /* Type has variable size */
+#define SPROC_EXTERNAL 0x01 /* Proc/func. is defined externally */
+#define SVAR_EXTERNAL 0x01 /* Variable is defined externally */
+
+/***********************************************************************
+ * Public Enumeration Types
+ ***********************************************************************/
+
+/* This enumeration identies what kind of binary object we are creating
+ * with the compilation. At present, we may be generating either a
+ * program binary or a unit binary.
+ */
+
+enum fileKind_e
+{
+ eIsProgram = 0,
+ eIsUnit
+};
+typedef enum fileKind_e fileKind_t;
+
+/* This enumeration determines what part of a file that we are
+ * processing now.
+ */
+
+enum fileSection_e
+{
+ eIsOtherSection = 0, /* Unspecified part of the file */
+ eIsProgramSection, /* Any part of a program file */
+ eIsInterfaceSection, /* INTERFACE section of a unit file */
+ eIsImplementationSection, /* IMPLEMENTATION section of a unit file */
+ eIsInitializationSection, /* INITIALIZATION section of a unit file */
+};
+typedef enum fileSection_e fileSection_t;
+
+/***********************************************************************
+ * Public Structure Types
+ ***********************************************************************/
+
+/* Reserved word table entry */
+
+struct R
+{
+ char *rname; /* pointer to name in string stack */
+ ubyte rtype; /* reserved word type */
+ ubyte subtype; /* reserved word extended type */
+};
+typedef struct R RTYPE;
+
+/* Symbol table entry */
+
+struct symType_s /* for sKind = sTYPE */
+{
+ ubyte type; /* specific type */
+ ubyte rtype; /* reference to type */
+ ubyte subType; /* constant type for subrange types */
+ ubyte flags; /* flags to customize a type (see above) */
+ uint32 asize; /* size of allocated instances of this type */
+ uint32 rsize; /* size of reference to an instances of this type */
+ sint32 minValue; /* minimum value taken subrange */
+ sint32 maxValue; /* maximum value taken by subrange or scalar */
+ struct S *parent; /* pointer to parent type */
+};
+typedef struct symType_s symType_t;
+
+struct symConst_s /* for sKind == constant type */
+{
+ union
+ {
+ float64 f; /* real value */
+ sint32 i; /* integer value */
+ } val;
+ struct S *parent; /* pointer to parent type */
+};
+typedef struct symConst_s symConst_t;
+
+struct symStringConst_s /* for sKind == sSTRING_CONST */
+{
+ uint32 offset; /* RO data section offset of string */
+ uint32 size; /* length of string in bytes */
+};
+typedef struct symStringConst_s symStringConst_t;
+
+struct symVarString_s /* for sKind == sSTRING */
+{
+ uint16 label; /* label at string declaration */
+ uint16 size; /* valid length of string in bytes */
+ uint16 alloc; /* max length of string in bytes */
+};
+typedef struct symVarString_s symVarString_t;
+
+struct symLabel_s /* for sKind == sLABEL */
+{
+ uint16 label; /* label number */
+ boolean unDefined; /* set false when defined */
+};
+typedef struct symLabel_s symLabel_t;
+
+struct symVar_s /* for sKind == type identifier */
+{
+ sint32 offset; /* Data stack offset */
+ uint32 size; /* Size of variable */
+ ubyte flags; /* flags to customize a variable (see above) */
+ uint32 symIndex; /* POFF symbol table index (if undefined) */
+ struct S *parent; /* pointer to parent type */
+};
+typedef struct symVar_s symVar_t;
+
+struct symProc_s /* for sKind == sPROC or sFUNC */
+{
+ uint16 label; /* entry point label */
+ uint16 nParms; /* number of parameters that follow */
+ ubyte flags; /* flags to customize a proc/func (see above) */
+ uint32 symIndex; /* POFF symbol table index (if undefined) */
+ struct S *parent; /* pointer to parent type (sFUNC only) */
+};
+typedef struct symProc_s symProc_t;
+
+struct symRecord_s /* for sKind == sRECORD_OBJECT */
+{
+ uint32 size; /* size of this field */
+ uint32 offset; /* offset into the RECORD */
+ struct S *record; /* pointer to parent sRECORD type */
+ struct S *parent; /* pointer to parent field type */
+};
+typedef struct symRecord_s symRecord_t;
+
+struct S
+{
+ char *sName; /* pointer to name in string stack */
+ ubyte sKind; /* kind of symbol */
+ ubyte sLevel; /* static nesting level */
+ union
+ {
+ symType_t t; /* for type definitions */
+ symConst_t c; /* for constants */
+ symStringConst_t s; /* for strings of constant size*/
+ symVarString_t vs; /* for strings of variable size*/
+ uint16 fileNumber; /* for files */
+ symLabel_t l; /* for labels */
+ symVar_t v; /* for variables */
+ symProc_t p; /* for functions & procedures */
+ symRecord_t r; /* for files of RECORDS */
+ } sParm;
+};
+typedef struct S STYPE;
+
+/* WITH structure */
+
+struct W
+{
+ ubyte level; /* static nesting level */
+ boolean pointer; /* TRUE if offset is to pointer to RECORD */
+ boolean varParm; /* TRUE if VAR param (+pointer) */
+ sint32 offset; /* Data stack offset */
+ uint16 index; /* RECORD offset (if pointer) */
+ STYPE *parent; /* pointer to parent RECORD type */
+};
+typedef struct W WTYPE;
+
+/* File table record */
+
+struct F
+{
+ sint16 defined;
+ sint16 flevel;
+ sint16 ftype;
+ sint32 faddr;
+ sint16 fsize;
+};
+typedef struct F FTYPE;
+
+#ifdef CONFIG_INSN16
+typedef struct P
+{
+ ubyte op;
+ ubyte arg1;
+ uint16 arg2;
+} OPTYPE;
+#endif
+
+#ifdef CONFIG_INSN32
+typedef struct P
+{
+ ubyte op;
+ uint32 arg;
+} OPTYPE;
+#endif
+
+/* This structure captures the parsing state of the compiler for a particular
+ * file. Since multiple, nested files can be processed, this represents
+ * only level in the "stack" of nested files.
+ */
+
+struct fileState_s
+{
+ /* These fields are managed by the higher level parsing logic
+ *
+ * stream - Stream pointer the input stream associated with this
+ * file.
+ * kind - Kind of file we are processing. If include > 0,
+ * this should be eIsUnit.
+ * section - This is the part of the program that we are parsing
+ * now.
+ * dstack - Level zero dstack offset at the time the unit was
+ * included. This is used to convert absolute program
+ * stack offsets into relative unit stack offsets.
+ * include - Is a unique number that identifies the file. In
+ * POFF ouput file, this would be the index to the
+ * entry in the .files section.
+ */
+
+ FILE *stream;
+ fileKind_t kind;
+ fileSection_t section;
+ sint32 dstack;
+ sint16 include;
+
+ /* These fields are managed by the tokenizer. These are all
+ * initialized by primeTokenizer().
+ *
+ * buffer[] - Holds the current input line
+ * line - Is the line number in this file for the current line
+ * cp - Is the current pointer into buffer[]
+ */
+
+ uint32 line;
+ unsigned char *cp;
+ unsigned char buffer[LINE_SIZE + 1];
+};
+typedef struct fileState_s fileState_t;
+
+#endif /* __PDEFS_H */
diff --git a/misc/pascal/include/pedefs.h b/misc/pascal/include/pedefs.h
new file mode 100644
index 000000000..8f342bdd0
--- /dev/null
+++ b/misc/pascal/include/pedefs.h
@@ -0,0 +1,270 @@
+/***********************************************************************
+ * pedefs.h
+ * Definitions of error codes
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PEDEFS_H
+#define __PEDEFS_H
+
+/***********************************************************************
+ * COMPILATION TIME ERRORS
+ * eASSIGN Expected ':='
+ * eBEGIN Expected 'BEGIN'
+ * eCOLON Expected ':'
+ * eCOMMA Expected ','
+ * eCOUNT Error count exceeded (FATAL)
+ * eDO Expected 'DO'
+ * eDUPFILE Attempt to re-define file
+ * eDUPSYM Attempt to declare duplicate symbol
+ * eEND Expected 'END'
+ * eEQ Expected '='
+ * eEXPONENT Error in exponent of real constant
+ * eFILE Expected file identifier declared in PROGRAM
+ * eHUH Internal error (FATAL)
+ * eIDENT Expected identifier
+ * eIMPLEMENTATION Expected implementation section in unit file
+ * eINCLUDE Include file OPEN error (FATAL)
+ * eINTCONST Expected integer constant
+ * eINTERFACE Expected interface section in unit file
+ * eINTOVF Integer overflow (or underflow)
+ * eINTVAR Integer variable name expected
+ * eINVALIDFUNC Unrecognized built-in function
+ * eINVALIDPROC Unrecognized built-in procedure
+ * eINVARG Invalid procedure/function argument type
+ * eINVCONST Invalid constant in declaration
+ * eINVSIGNEDCONST Invalid constant after sign
+ * eINVFACTOR Invalid factor
+ * eINVFILE Invalid file identifier (as declared in PROGRAM)
+ * eINVLABEL Invalid label
+ * eINVPTR Invalid pointer type
+ * eINVTYPE Invalid type identifier
+ * eINVVARPARM Invalid/unsupported VAR parameter type
+ * eLBRACKET Expected '['
+ * eLPAREN Expected '('
+ * eMULTLABEL Attempt to multiply define label
+ * eNOSQUOTE EOL encounter in a string, probable missing "'"
+ * eNOTYET Not implemented yet
+ * eNPARMS Number of parameters in function or procedure
+ * call does not match number in declaration
+ * eOF Expected 'OF'
+ * eOVF Internal table overflow (FATAL)
+ * ePERIOD Expected '.'
+ * ePOFFCONFUSION Internal logic error in POFF file generation
+ * ePOFFWRITEERROR Error writing to POFF file
+ * ePROGRAM Expected 'PROGRAM'
+ * ePTRADR Expected pointer address (probably got value) form
+ * ePTRVAL Expected pointer value form, got value form
+ * eRBRACKET Expected ']'
+ * eRPAREN Expected ')'
+ * eRPARENorCOMMA Expected ')' or ','
+ * eSEEKFAIL Seek to file position failed
+ * eSEMICOLON Expected ';'
+ * eSTRING Expected a string
+ * eTHEN Expected 'THEN'
+ * eTOorDOWNTO Expected 'TO' or 'DOWNTO' in for statement
+ * eTRUNC String truncated
+ * eUNDECLABEL Attempt to define an undeclared label.
+ * eUNDEFILE Undefined file buffer
+ * eUNDEFLABEL A declared label was not defined.
+ * eUNDEFSYM Undefined symbol
+ * eUNTIL Expected 'UNTIL'
+ * eEXPRTYPE Illegal expression type for this operation
+ * eTERMTYPE Illegal term type for this operation
+ * eFACTORTYPE Illegal factor type for this operation
+ * eREADPARM Illegal parameter in READ statement
+ * eWRITEPARM Illegal parameter in WRITE statement
+ * eARRAYTYPE Illegal type for ARRAY OF
+ * ePOINTERTYPE Illegal pointer type
+ * eVARPARMTYPE Illegal VAR parameter type
+ * eSUBRANGE Expected ".."
+ * eSUBRANGETYPE Illegal subrange type
+ * eSET Expected valid/consistent type for SET OF
+ * sSETRANGE Value out of range for SET OF
+ * eSCALARTYPE Illegal scalar type
+ * eBADSHORTINT Short integer is out of range
+ * eSYMTABINTERNAL Internal error in symbol table
+ * eRECORDDECLARE Error in RECORD declaration
+ * eRECORDOBJECT Expected a field of RECORD
+ * eRECORDVAR Expected a RECORD variable in WITH
+ * eUNIT Expected UNIT at beginning of unit file
+ * eUNITNAME File does not contain the expected UNIT
+ * eARGIGNORED An argument was provided, but ignored
+ *
+ * LINK TIME ERRORS
+ * eUNDEFINEDSYMBOL A necessary symbol was not defined
+ * eMULTIDEFSYMBOL A symbol was defined multiple times
+ *
+ * ERRORS WHICH MAY OCCUR AT EITHER COMPILATION, LINK OR RUNTIME
+ * eNOMEMORY Memory allocation failed
+ * ePOFFREADERROR Error reading a POFF file
+ * ePOFFBADFORMAT The file format does not like valid POFF
+ * eRCVDSIGNAL Received SIGSEGV (or other) signal.
+ *
+ * RUN TIME ERRORS
+ * eBADPC Program Counter is out-of-range
+ * eBADSP Stack reference is out-of-range
+ * eSTRSTKOVERFLOW String stack overflow
+ * eILLEGALOPCODE Non-executable instruction found
+ * eEXIT oEND P-Code encountered
+ * eBADSYSIOFUNC Illegal SYSIO sub-function
+ * eBADSYSLIBCALL Illegal runtime library call
+ * eBADFPOPCODE Illegal FLOAT POINT op-code
+ * eFAILEDLIBCALL Runtime library call returned failure
+ * eINTEGEROVERFLOW Integer overflow
+ **********************************************************************/
+
+/* This is the error code that indicates that no error has occurred */
+
+#define eNOERROR ((uint16) 0x00)
+
+/* This is the maximum number of errors that will be reported before
+ * compilation is terminated.
+ */
+
+#define MAX_ERRORS 100
+
+/* COMPILATION TIME ERRORS */
+
+#define eASSIGN ((uint16) 0x01)
+#define eBEGIN ((uint16) 0x02)
+#define eCOLON ((uint16) 0x03)
+#define eCOMMA ((uint16) 0x04)
+#define eCOUNT ((uint16) 0x05)
+#define eDO ((uint16) 0x06)
+#define eDUPFILE ((uint16) 0x07)
+#define eDUPSYM ((uint16) 0x08)
+#define eEND ((uint16) 0x09)
+#define eEQ ((uint16) 0x0a)
+#define eEXPONENT ((uint16) 0x0b)
+#define eFILE ((uint16) 0x0c)
+#define eHUH ((uint16) 0x0d)
+#define eIDENT ((uint16) 0x0e)
+#define eIMPLEMENTATION ((uint16) 0x0f)
+
+#define eINCLUDE ((uint16) 0x10)
+#define eINTCONST ((uint16) 0x11)
+#define eINTERFACE ((uint16) 0x12)
+#define eINTOVF ((uint16) 0x13)
+#define eINTVAR ((uint16) 0x14)
+#define eINVALIDFUNC ((uint16) 0x15)
+#define eINVALIDPROC ((uint16) 0x16)
+#define eINVARG ((uint16) 0x17)
+#define eINVCONST ((uint16) 0x18)
+#define eINVSIGNEDCONST ((uint16) 0x19)
+#define eINVFACTOR ((uint16) 0x1a)
+#define eINVFILE ((uint16) 0x1b)
+#define eINVLABEL ((uint16) 0x1c)
+#define eINVPTR ((uint16) 0x1d)
+#define eINVTYPE ((uint16) 0x1e)
+#define eINVVARPARM ((uint16) 0x1f)
+
+#define eLBRACKET ((uint16) 0x20)
+#define eLPAREN ((uint16) 0x21)
+#define eMULTLABEL ((uint16) 0x22)
+#define eNOSQUOTE ((uint16) 0x23)
+#define eNOTYET ((uint16) 0x24)
+#define eNPARMS ((uint16) 0x25)
+#define eOF ((uint16) 0x26)
+#define eOVF ((uint16) 0x27)
+#define ePERIOD ((uint16) 0x28)
+#define ePOFFCONFUSION ((uint16) 0x29)
+#define ePOFFWRITEERROR ((uint16) 0x2a)
+#define ePROGRAM ((uint16) 0x2b)
+#define ePTRADR ((uint16) 0x2c)
+#define ePTRVAL ((uint16) 0x2d)
+#define eRBRACKET ((uint16) 0x2e)
+#define eRPAREN ((uint16) 0x2f)
+
+#define eRPARENorCOMMA ((uint16) 0x30)
+#define eSEEKFAIL ((uint16) 0x31)
+#define eSEMICOLON ((uint16) 0x32)
+#define eSTRING ((uint16) 0x33)
+#define eTHEN ((uint16) 0x34)
+#define eTOorDOWNTO ((uint16) 0x35)
+#define eTRUNC ((uint16) 0x36)
+#define eUNDECLABEL ((uint16) 0x37)
+#define eUNDEFILE ((uint16) 0x38)
+#define eUNDEFLABEL ((uint16) 0x39)
+#define eUNDEFSYM ((uint16) 0x3a)
+#define eUNTIL ((uint16) 0x3b)
+#define eEXPRTYPE ((uint16) 0x3c)
+#define eTERMTYPE ((uint16) 0x3d)
+#define eFACTORTYPE ((uint16) 0x3e)
+#define eREADPARM ((uint16) 0x3f)
+
+#define eWRITEPARM ((uint16) 0x40)
+#define eARRAYTYPE ((uint16) 0x41)
+#define ePOINTERTYPE ((uint16) 0x42)
+#define eVARPARMTYPE ((uint16) 0x43)
+#define eSUBRANGE ((uint16) 0x44)
+#define eSUBRANGETYPE ((uint16) 0x45)
+#define eSET ((uint16) 0x46)
+#define eSETRANGE ((uint16) 0x47)
+#define eSCALARTYPE ((uint16) 0x48)
+#define eBADSHORTINT ((uint16) 0x49)
+#define eSYMTABINTERNAL ((uint16) 0x4a)
+#define eRECORDDECLARE ((uint16) 0x4b)
+#define eRECORDOBJECT ((uint16) 0x4c)
+#define eRECORDVAR ((uint16) 0x4d)
+#define eUNIT ((uint16) 0x4e)
+#define eUNITNAME ((uint16) 0x4f)
+
+#define eARGIGNORED ((uint16) 0x50)
+
+/* LINK TIME ERRORS */
+
+#define eUNDEFINEDSYMBOL ((uint16) 0x60)
+#define eMULTIDEFSYMBOL ((uint16) 0x61)
+
+/* ERRORS WHICH MAY OCCUR AT EITHER COMPILATION OR RUNTIME */
+
+#define eNOMEMORY ((uint16) 0x70)
+#define ePOFFREADERROR ((uint16) 0x71)
+#define ePOFFBADFORMAT ((uint16) 0x72)
+#define eRCVDSIGNAL ((uint16) 0x73)
+
+/* RUN TIME ERRORS */
+
+#define eBADPC ((uint16) 0x80)
+#define eBADSP ((uint16) 0x81)
+#define eSTRSTKOVERFLOW ((uint16) 0x82)
+#define eILLEGALOPCODE ((uint16) 0x83)
+#define eEXIT ((uint16) 0x84)
+#define eBADSYSIOFUNC ((uint16) 0x85)
+#define eBADSYSLIBCALL ((uint16) 0x86)
+#define eBADFPOPCODE ((uint16) 0x87)
+#define eINTEGEROVERFLOW ((uint16) 0x89)
+#define eFAILEDLIBCALL ((uint16) 0x90)
+
+#endif /* __PEDEFS_H */
diff --git a/misc/pascal/include/perr.h b/misc/pascal/include/perr.h
new file mode 100644
index 000000000..cfaa40fd7
--- /dev/null
+++ b/misc/pascal/include/perr.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * perr.h
+ * External Declarations associated with perr.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+extern void errmsg(char *fmt, ...);
+extern void warn(uint16 errcode);
+extern void error(uint16 errcode);
+extern void fatal(uint16 errcode);
diff --git a/misc/pascal/include/pexpr.h b/misc/pascal/include/pexpr.h
new file mode 100644
index 000000000..dba1f1ee7
--- /dev/null
+++ b/misc/pascal/include/pexpr.h
@@ -0,0 +1,92 @@
+/***********************************************************************
+ * pexpr.h
+ * External Declarations associated with pexpr.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PEXPR_H
+#define __PEXPR_H
+
+/***********************************************************************
+ * Type Definitions
+ ***********************************************************************/
+
+typedef enum exprEnum
+{
+ exprUnknown = 0, /* TOS value unknown */
+ exprAnyOrdinal, /* TOS = any ordinal type */
+ exprAnyString, /* TOS = any string type */
+
+ exprInteger, /* TOS = integer value */
+ exprReal, /* TOS = real value */
+ exprChar, /* TOS = character value */
+ exprBoolean, /* TOS = boolean(integer) value */
+ exprScalar, /* TOS = scalar(integer) value */
+ exprString, /* TOS = variable length string reference */
+ exprStkString, /* TOS = reference to string on string stack */
+ exprCString, /* TOS = pointer to C string */
+ exprSet, /* TOS = set(integer) value */
+ exprArray, /* TOS = array */
+ exprRecord, /* TOS = record */
+
+ exprIntegerPtr, /* TOS = pointer to integer value */
+ exprRealPtr, /* TOS = pointer to a real value */
+ exprCharPtr, /* TOS = pointer to a character value */
+ exprBooleanPtr, /* TOS = pointer to a boolean value */
+ exprScalarPtr, /* TOS = pointer to a scalar value */
+ exprSetPtr, /* TOS = pointer to a set value */
+ exprArrayPtr, /* TOS = pointer to an array */
+ exprRecordPtr /* TOS = pointer to a record */
+} exprType;
+
+/***********************************************************************
+ * Global Variables
+ ***********************************************************************/
+
+extern int constantToken;
+extern sint32 constantInt;
+extern float64 constantReal;
+extern char *constantStart;
+
+/***********************************************************************
+ * Global Function Protypes
+ ***********************************************************************/
+
+extern exprType expression ( exprType findExprType, STYPE *typePtr );
+extern exprType varParm ( exprType varExprType, STYPE *typePtr );
+extern void arrayIndex ( sint32 size );
+extern exprType getExprType( STYPE *sType );
+
+extern void constantExpression(void);
+
+#endif /* __PEXPR_H */
diff --git a/misc/pascal/include/pfdefs.h b/misc/pascal/include/pfdefs.h
new file mode 100644
index 000000000..e58ca4ed7
--- /dev/null
+++ b/misc/pascal/include/pfdefs.h
@@ -0,0 +1,93 @@
+/***********************************************************************
+ * pfdefs.h
+ * Floating point operation codes
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PFDEFS_H
+#define __PFDEFS_H
+
+/**---------------------------------------------------------------------
+ FLOATING POINT SUB-OPCODES
+ ---------------------------------------------------------------------**/
+
+/* This bit may be set in the opcode to indicate that the arguments
+ * is(are) type integer and require(s) conversion. */
+
+#define fpARG1 (0x40)
+#define fpARG2 (0x80)
+#define fpMASK (0x3f)
+#define fpSHIFT 6
+
+/* The "INVALID" floating point operation */
+
+#define fpINVLD (0x00)
+
+/* Floating Pointer Conversions (On 16-bit stack argument: FP or Integer) */
+
+#define fpFLOAT (0x01)
+#define fpTRUNC (0x02)
+#define fpROUND (0x03)
+
+/* Floating Point arithmetic instructions (Two FP 16-bit stack arguments) */
+
+#define fpADD (0x04)
+#define fpSUB (0x05)
+#define fpMUL (0x06)
+#define fpDIV (0x07)
+#define fpMOD (0x08)
+
+/* Floating Point Comparisons (Two FP 16-bit stack arguments) */
+
+#define fpEQU (0x0a)
+#define fpNEQ (0x0b)
+#define fpLT (0x0c)
+#define fpGTE (0x0d)
+#define fpGT (0x0e)
+#define fpLTE (0x0f)
+
+/* Floating Point arithmetic instructions (One FP 16-bit stack arguments) */
+
+#define fpNEG (0x10)
+#define fpABS (0x11)
+#define fpSQR (0x12)
+#define fpSQRT (0x13)
+#define fpSIN (0x14)
+#define fpCOS (0x15)
+#define fpATAN (0x16)
+#define fpLN (0x17)
+#define fpEXP (0x18)
+
+#define MAX_FOP (0x19) /* Number of floating point operations */
+
+#endif /* __PFDEFS_H */
diff --git a/misc/pascal/include/pfunc.h b/misc/pascal/include/pfunc.h
new file mode 100644
index 000000000..e6d3303e4
--- /dev/null
+++ b/misc/pascal/include/pfunc.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * pfunc.h
+ * External Declarations associated with pfunc.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PFUNC_H
+#define __PFUNC_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "pexpr.h" /* For exprType */
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void primeBuiltInFunctions(void);
+extern exprType builtInFunction(void);
+extern void builtInFunctionOfConstant(void);
+
+extern void checkLParen(void);
+extern void checkRParen(void);
+
+#endif /* __PFUNC_H */
diff --git a/misc/pascal/include/pgen.h b/misc/pascal/include/pgen.h
new file mode 100644
index 000000000..055e14eb3
--- /dev/null
+++ b/misc/pascal/include/pgen.h
@@ -0,0 +1,92 @@
+/***************************************************************************
+ * pgen.h
+ * External Declarations associated with pgen.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PGEN_H
+#define __PGEN_H
+
+/***************************************************************************
+ * Compilation Switches
+ ***************************************************************************/
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "podefs.h"
+
+/***************************************************************************
+ * Definitions
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Types
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Variable Prototypes
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern sint32 pas_GetCurrentStackLevel(void);
+extern void pas_InvalidateCurrentStackLevel(void);
+extern void pas_SetCurrentStackLevel(sint32 dwLsp);
+extern uint32 pas_GetNStackLevelChanges(void);
+
+extern void pas_GenerateSimple(enum pcode_e eOpCode);
+extern void pas_GenerateDataOperation(enum pcode_e eOpCode, sint32 dwData);
+extern void pas_GenerateDataSize(sint32 dwDataSize);
+extern void pas_GenerateFpOperation(ubyte fpOpcode);
+extern void pas_GenerateIoOperation(uint16 ioOpcode, uint16 fileNumber);
+extern void pas_BuiltInFunctionCall(uint16 libOpcode);
+extern void pas_GenerateLevelReference(enum pcode_e eOpCode, uint16 wLevel,
+ sint32 dwOffset);
+extern void pas_GenerateStackReference(enum pcode_e eOpCode, STYPE *pVarPtr);
+extern void pas_GenerateProcedureCall(STYPE *pProcPtr);
+extern void pas_GenerateLineNumber(uint16 wIncludeNumber,
+ uint32 dwLineNumber);
+extern void pas_GenerateStackExport(STYPE *pVarPtr);
+extern void pas_GenerateStackImport(STYPE *pVarPtr);
+extern void pas_GenerateProcedureCall(STYPE *pProcPtr);
+extern void pas_GenerateDebugInfo(STYPE *pProcPtr, uint32 dwReturnSize);
+extern void pas_GenerateProcExport(STYPE *pProcPtr);
+extern void pas_GenerateProcImport(STYPE *pProcPtr);
+extern void pas_GeneratePoffOutput(void);
+
+#endif /* __PGEN_H */
+
diff --git a/misc/pascal/include/pinsn.h b/misc/pascal/include/pinsn.h
new file mode 100644
index 000000000..3d736cdc2
--- /dev/null
+++ b/misc/pascal/include/pinsn.h
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * pinsn.h
+ * External Declarations associated libinsn.a
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PINSN_H
+#define __PINSN_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+/* Opcode generators */
+
+extern void insn_GenerateSimple(enum pcode_e opcode);
+extern void insn_GenerateDataOperation(enum pcode_e opcode, sint32 data);
+extern void insn_GenerateDataSize(uint32 dwDataSize);
+extern void insn_GenerateFpOperation(ubyte fpOpcode);
+extern void insn_GenerateIoOperation(uint16 ioOpcode, uint16 fileNumber);
+extern void insn_BuiltInFunctionCall(uint16 libOpcode);
+extern void insn_GenerateLevelReference(enum pcode_e opcode, uint16 level,
+ sint32 offset);
+extern void insn_GenerateProcedureCall(uint16 level, sint32 offset);
+extern void insn_GenerateLineNumber(uint16 includeNumber, uint32 lineNumber);
+extern void insn_SetStackLevel(uint32 level);
+
+/* Opcode relocation */
+
+extern int insn_Relocate(OPTYPE *op, uint32 pcOffset, uint32 roOffset);
+extern void insn_FixupProcedureCall(ubyte *progData, uint32 symValue);
+
+/* POFF-wrapped INSNS access helpers */
+
+extern uint32 insn_GetOpCode(poffHandle_t handle, OPTYPE *ptr);
+extern void insn_ResetOpCodeRead(poffHandle_t handle);
+extern void insn_AddOpCode(poffHandle_t handle, OPTYPE *ptr);
+extern void insn_ResetOpCodeWrite(poffHandle_t handle);
+extern void insn_AddTmpOpCode(poffProgHandle_t progHandle, OPTYPE *ptr);
+extern void insn_ResetTmpOpCodeWrite(poffProgHandle_t progHandle);
+
+/* INSN-specific disassembler */
+
+extern void insn_DisassemblePCode(FILE* lfile, OPTYPE *pop);
+
+#endif /* __PINSN_H */
diff --git a/misc/pascal/include/plink.h b/misc/pascal/include/plink.h
new file mode 100644
index 000000000..350bce461
--- /dev/null
+++ b/misc/pascal/include/plink.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * plink.h
+ * External Declarations associated with plink.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PLINK_H
+#define __PLINK_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Variables
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+#endif /* __PLINK_H */
diff --git a/misc/pascal/include/plreloc.h b/misc/pascal/include/plreloc.h
new file mode 100644
index 000000000..1998361b9
--- /dev/null
+++ b/misc/pascal/include/plreloc.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * plreloc.h
+ * External Declarations associated with plreloc.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PLRELOC_H
+#define __PLRELOC_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "pofflib.h"
+
+/***************************************************************************
+ * Global Variables
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void mergeRelocations(poffHandle_t inHandle,
+ uint32 pcOffset, uint32 symOffset);
+extern void applyRelocations(poffHandle_t outHandle);
+extern void releaseRelocations(void);
+
+#endif /* __PLRELOC_H */
diff --git a/misc/pascal/include/plsym.h b/misc/pascal/include/plsym.h
new file mode 100644
index 000000000..96f520148
--- /dev/null
+++ b/misc/pascal/include/plsym.h
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * plsym.h
+ * External Declarations associated with plsym.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PLSYM_H
+#define __PLSYM_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "pofflib.h"
+
+/***************************************************************************
+ * Global Variables
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern uint32 mergeSymbols(poffHandle_t inHandle,
+ uint32 pcOffset, uint32 symOffset);
+extern void verifySymbols(void);
+extern void writeSymbols(poffHandle_t outHandle);
+extern poffLibSymbol_t *getSymbolByIndex(uint32 symIndex);
+extern void releaseSymbols(void);
+
+#endif /* __PLSYM_H */
diff --git a/misc/pascal/include/podefs.h b/misc/pascal/include/podefs.h
new file mode 100644
index 000000000..ba95b0d14
--- /dev/null
+++ b/misc/pascal/include/podefs.h
@@ -0,0 +1,204 @@
+/***********************************************************************
+ * podefs.h
+ * Logical P-code operation code definitions
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PODEFS_H
+#define __PODEFS_H
+
+/* These definitions represent logical operations as needed by the
+ * the compiler. The specific INSN generation layer must interpret
+ * these requests as is appropriate to the supported INSNS.
+ */
+
+enum pcode_e
+{
+
+ /**-------------------------------------------------------------------
+ * OPCODES WITH NO ARGUMENTS
+ **-------------------------------------------------------------------**/
+
+ /* Program control (No stack arguments) */
+
+ opNOP = 0,
+
+ /* Arithmetic & logical & and integer conversions (One stack argument) */
+
+ opNEG, opABS, opINC, opDEC, opNOT,
+
+ /* Arithmetic & logical (Two stack arguments) */
+
+ opADD, opSUB, opMUL, opDIV, opMOD, opSLL, opSRL, opSRA, opOR, opAND,
+
+ /* Comparisons (One stack argument) */
+
+ opEQUZ, opNEQZ, opLTZ, opGTEZ, opGTZ, opLTEZ,
+
+ /* Comparisons (Two stack arguments) */
+
+ opEQU, opNEQ, opLT, opGTE, opGT, opLTE,
+ opBIT,
+
+ /* Load Immediate */
+
+ opLDI, opLDIB, opLDIM,
+
+ /* Store Immediate */
+
+ opSTI, opSTIB, opSTIM,
+
+ /* Data stack */
+
+ opDUP, opPUSHS, opPOPS,
+
+ /* Program control (No stack arguments)
+ * Behavior:
+ * Pop return address
+ * Pop saved base register (BR)
+ * Discard saved base address
+ * Set program counter (PC) to return address
+ */
+
+ opRET,
+
+ /* System Functions (No stack arguments) */
+
+ opEND,
+
+ /**-------------------------------------------------------------------
+ ** OPCODES WITH ONE ARGUMENT
+ **-------------------------------------------------------------------**/
+
+ /* Floating point operations: arg = FP op-code */
+
+ opFLOAT,
+
+ /* Program control: arg = unsigned label (One stack argument) */
+
+ opJEQUZ, opJNEQZ,
+
+ /* Program control: arg = unsigned label (no stack arguments) */
+
+ opJMP,
+
+ /* Program control: arg = unsigned label (One stack argument) */
+
+ opJEQU, opJNEQ, opJLT, opJGTE, opJGT, opJLTE,
+
+ /* Load: arg = unsigned base offset */
+
+ opLD, opLDH, opLDB, opLDM,
+
+ /* Store: arg = unsigned base offset */
+
+ opST, opSTB, opSTM,
+
+ /* Load Indexed: arg = unsigned base offset */
+
+ opLDX, opLDXB, opLDXM,
+
+ /* Store Indexed: arg16 = unsigned base offset */
+
+ opSTX, opSTXB, opSTXM,
+
+ /* Load address relative to stack base: arg = unsigned offset */
+
+ opLA,
+
+ /* Load absolute stack address: arg = RODATA offset (No stack arguments) */
+
+ opLAC,
+
+ /* Data stack: arg = 16 bit signed data (no stack arguments) */
+
+ opPUSH, opINDS,
+
+ /* Load address relative to stack base: arg1 = unsigned offset, TOS=index */
+
+ opLAX,
+
+ /* System functions: arg = 16-bit library call identifier */
+
+ opLIB,
+
+ /* Program control: arg = unsigned label (no stack arguments) */
+
+ opLABEL,
+
+ /**-------------------------------------------------------------------
+ ** OPCODES WITH TWO ARGUMENTS
+ **-------------------------------------------------------------------**/
+
+ /* Program Control: arg1 = level; arg2 = unsigned label */
+
+ opPCAL,
+
+ /* Load: arg1 = level; arg2 = signed frame offset */
+
+ opLDS, opLDSH, opLDSB, opLDSM,
+
+ /* Store: arg1 = level; arg2 = signed frame offset */
+
+ opSTS, opSTSB, opSTSM,
+
+ /* Load Indexed: arg1 = level; arg2 = signed frame offset */
+
+ opLDSX, opLDSXB, opLDSXM,
+
+ /* Store Indexed: arg1 = level; arg2 = signed frame offset */
+
+ opSTSX, opSTSXB, opSTSXM,
+
+ /* FOR LAS/LASX arg1 = level; arg2 = signed frame offset
+ * (no stack arguments)
+ */
+
+ opLAS, opLASX,
+
+ /* System calls:
+ * For SYSIO: arg1 = file number; arg2 = sub-function code
+ */
+
+ opSYSIO,
+
+ /* Psuedo-operations:
+ * For LINE: arg1 = file number; arg2 = line number
+ */
+
+ opLINE,
+
+ NUM_OPCODES
+};
+
+#endif /* __PODEFS_H */
diff --git a/misc/pascal/include/pprgm.h b/misc/pascal/include/pprgm.h
new file mode 100644
index 000000000..7c4ef2ca0
--- /dev/null
+++ b/misc/pascal/include/pprgm.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * pprgm.h
+ * External Declarations associated with pprgm.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PPRGM_H
+#define __PPRGM_H
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void program(void);
+extern void usesSection(void);
+
+#endif /* __PPRGM_H */
diff --git a/misc/pascal/include/pproc.h b/misc/pascal/include/pproc.h
new file mode 100644
index 000000000..5ede20a57
--- /dev/null
+++ b/misc/pascal/include/pproc.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * pproc.h
+ * External Declarations associated with PPROC.C
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PPROC_H
+#define __PPROC_H
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void primeBuiltInProcedures(void);
+extern void builtInProcedure(void);
+extern int actualParameterSize(STYPE *procPtr, int parmNo);
+extern int actualParameterList(STYPE *procPtr);
+
+#endif /* __PPROC_H */
diff --git a/misc/pascal/include/pstm.h b/misc/pascal/include/pstm.h
new file mode 100644
index 000000000..6508db68a
--- /dev/null
+++ b/misc/pascal/include/pstm.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * pstm.h
+ * External Declarations associated with pstm.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PSTM_H
+#define __PSTM_H
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void statement (void); /* Process Statement */
+extern void compoundStatement (void); /* Compound statement */
+
+#endif /* __PSTM_H */
diff --git a/misc/pascal/include/ptbl.h b/misc/pascal/include/ptbl.h
new file mode 100644
index 000000000..70d318846
--- /dev/null
+++ b/misc/pascal/include/ptbl.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * ptbl.h
+ * External Declarations associated with ptbl.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PTBL_H
+#define __PTBL_H
+
+/***************************************************************************
+ * Included Files
+ ***************************************************************************/
+
+#include "config.h"
+
+/***************************************************************************
+ * Global Variables
+ ***************************************************************************/
+
+extern STYPE *parentInteger;
+extern STYPE *parentString;
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern const RTYPE *findReservedWord (char *name);
+extern STYPE *findSymbol (char *inName);
+extern STYPE *addTypeDefine (char *name, ubyte type, uint16 size,
+ STYPE *parent);
+extern STYPE *addConstant (char *name, ubyte type, sint32 *value,
+ STYPE *parent);
+extern STYPE *addStringConst (char *name, uint32 offset, uint32 size);
+extern STYPE *addFile (char *name, uint16 fileNumber);
+extern STYPE *addLabel (char *name, uint16 label);
+extern STYPE *addProcedure (char *name, ubyte type, uint16 label,
+ uint16 nParms, STYPE *parent);
+extern STYPE *addVariable (char *name, ubyte type, uint16 offset,
+ uint16 size, STYPE *parent);
+extern STYPE *addField (char *name, STYPE *record);
+extern void primeSymbolTable (unsigned long symbolTableSize);
+extern void verifyLabels (sint32 symIndex);
+
+#if CONFIG_DEBUG
+extern void dumpTables (void);
+#endif
+
+#endif /* __PTBL_H */
diff --git a/misc/pascal/include/ptdefs.h b/misc/pascal/include/ptdefs.h
new file mode 100644
index 000000000..d7a079e13
--- /dev/null
+++ b/misc/pascal/include/ptdefs.h
@@ -0,0 +1,209 @@
+/***********************************************************************
+ * ptdefs.h
+ * Token and Symbol Table Definitions
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PTDEFS_H
+#define __PTDEFS_H
+
+/***********************************************************************/
+/* Token Values 0-0x20 reserved for get_token identification */
+
+#define tIDENT 0x01
+#define tINT_CONST 0x02
+#define tCHAR_CONST 0x03
+#define tBOOLEAN_CONST 0x04
+#define tREAL_CONST 0x05
+#define tSTRING_CONST 0x06
+
+#define tLE 0x07
+#define tGE 0x08
+#define tASSIGN 0x09
+#define tSUBRANGE 0x0A
+
+/* Token Values 0x21-0x2F (except 0x24) are for ASCII character tokens */
+
+#define tNE ('#')
+#define SQUOTE 0x27
+#define tMUL ('*')
+#define tFDIV ('/')
+
+/* Token Values 0x30-0x39 are spare */
+/* Token Values 0x3A-0x40 are for ASCII character tokens */
+
+#define tLT ('<')
+#define tEQ ('=')
+#define tGT ('>')
+
+/* Token Values 0x41-0x5A are SYMBOL TABLE definitions */
+
+#define sPROC 0x41
+#define sFUNC 0x42
+#define sLABEL 0x43
+#define sTYPE 0x44
+#define sFILE 0x45
+#define sINT 0x46
+#define sBOOLEAN 0x47
+#define sCHAR 0x48
+#define sREAL 0x49
+#define sTEXT 0x4a
+#define sSTRING 0x4b /* String storage type */
+#define sRSTRING 0x4c /* String reference type */
+#define sSTRING_CONST 0x4d
+#define sPOINTER 0x4e
+#define sSCALAR 0x4f
+#define sSCALAR_OBJECT 0x50
+#define sSUBRANGE 0x51
+#define sSET_OF 0x52
+#define sARRAY 0x53
+#define sRECORD 0x54
+#define sRECORD_OBJECT 0x55
+#define sFILE_OF 0x56
+#define sVAR_PARM 0x57
+
+/* Token Values 0x5B-0x60 (except 0x5F) are for ASCII character tokens */
+/* Token Values 0x61-0x7a are SYMBOL TABLE definitions */
+
+/* Token Values 0x7b-0x7f are for ASCII character tokens */
+/* Token Value 0x7f is spare */
+
+/* Token Values 0x80-0xef are for RESERVED WORDS */
+
+/* Standard constants (TRUE, FALSE, MAXINT) and standard files (INPUT, OUTPUT)
+ * are hard initialized into the constant/symbol table and are transparent
+ * to the compiler */
+
+/* Reserved Words 0x80-0xaf*/
+
+#define tAND 0x80
+#define tARRAY 0x81
+#define tBEGIN 0x82
+#define tCASE 0x83
+#define tCONST 0x84
+#define tDIV 0x85
+#define tDO 0x86
+#define tDOWNTO 0x87
+#define tELSE 0x88
+#define tEND 0x89
+#define tFILE 0x8a
+#define tFOR 0x8b
+#define tFUNCTION 0x8c
+#define tGOTO 0x8d
+#define tIF 0x8e
+#define tIMPLEMENTATION 0x08f /* Extended pascal */
+#define tIN 0x90
+#define tINTERFACE 0x91 /* Extended pascal */
+#define tLABEL 0x92
+#define tMOD 0x93
+#define tNIL 0x94
+#define tNOT 0x95
+#define tOF 0x96
+#define tOR 0x97
+#define tPACKED 0x98
+#define tPROCEDURE 0x99
+#define tPROGRAM 0x9a
+#define tRECORD 0x9b
+#define tREPEAT 0x9c
+#define tSET 0x9d
+#define tSHL 0x9e
+#define tSHR 0x9f
+#define tTHEN 0xa0
+#define tTO 0xa1
+#define tTYPE 0xa2
+#define tUNIT 0xa3 /* Extended pascal */
+#define tUNTIL 0xa4
+#define tUSES 0xa5 /* Extended pascal */
+#define tVAR 0xa6
+#define tWHILE 0xa7
+#define tWITH 0xa8
+
+/* The following codes indicate that the token is a built-in procedure
+ * or function recognized by the compiler. An additional code will be
+ * place in tknSubType by the tokenizer to indicate which built-in
+ * procedure or function applies.
+ */
+
+#define tFUNC 0xb0
+#define tPROC 0xb1
+
+/***********************************************************************/
+/* Codes to indentify built-in functions and procedures */
+
+#define txNONE 0x00
+
+/* Standard Functions 0x01-0x1f*/
+
+#define txABS 0x01
+#define txARCTAN 0x02
+#define txCHR 0x03
+#define txCOS 0x04
+#define txEOF 0x05
+#define txEOLN 0x06
+#define txEXP 0x07
+#define txLN 0x08
+#define txODD 0x09
+#define txORD 0x0a
+#define txPRED 0x0b
+#define txROUND 0x0c
+#define txSIN 0x0d
+#define txSQR 0x0e
+#define txSQRT 0x0f
+#define txSUCC 0x10
+#define txTRUNC 0x11
+
+/* "Less than standard" Functions 0x20-0x7f */
+
+#define txGETENV 0x20
+
+/* Standard Procedures 0x81-0xbf */
+
+#define txGET 0x80
+#define txNEW 0x81
+#define txPACK 0x82
+#define txPAGE 0x83
+#define txPUT 0x84
+#define txREAD 0x85
+#define txREADLN 0x86
+#define txRESET 0x87
+#define txREWRITE 0x88
+#define txUNPACK 0x89
+#define txWRITE 0x8a
+#define txWRITELN 0x8b
+
+/* "Less than standard" Procedures 0xc0-0xff */
+
+#define txVAL 0xc0
+
+#endif /* __PTDEFS_H */
+
diff --git a/misc/pascal/include/ptkn.h b/misc/pascal/include/ptkn.h
new file mode 100644
index 000000000..d30333e0c
--- /dev/null
+++ b/misc/pascal/include/ptkn.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * ptkn.h
+ * External Declarations associated with ptkn.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PTKN_H
+#define __PTKN_H
+
+/***************************************************************************
+ * Public Variables
+ ***************************************************************************/
+
+/* String stack access variables */
+
+extern char *tkn_strt; /* Start of token in string stack */
+extern char *stringSP; /* Top of string stack */
+
+/***************************************************************************
+ * Public Function Prototypes
+ ***************************************************************************/
+
+extern void getToken (void);
+extern char getNextCharacter (boolean skipWhiteSpace);
+extern sint16 primeTokenizer (unsigned long stringStackSize);
+extern sint16 rePrimeTokenizer (void);
+
+#endif /* __PTKN_H */
diff --git a/misc/pascal/include/punit.h b/misc/pascal/include/punit.h
new file mode 100644
index 000000000..128ec7198
--- /dev/null
+++ b/misc/pascal/include/punit.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * punit.h
+ * External Declarations associated with punit.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***************************************************************************/
+
+#ifndef __PUNIT_H
+#define __PUNIT_H
+
+/***************************************************************************
+ * Public Types
+ ***************************************************************************/
+
+/***************************************************************************
+ * Global Function Prototypes
+ ***************************************************************************/
+
+extern void unitImplementation(void);
+extern void unitInterface(void);
+
+#endif /* __PUNIT_H */
diff --git a/misc/pascal/include/pxdefs.h b/misc/pascal/include/pxdefs.h
new file mode 100644
index 000000000..1638028fa
--- /dev/null
+++ b/misc/pascal/include/pxdefs.h
@@ -0,0 +1,232 @@
+/***********************************************************************
+ * pxdefs.h
+ * Definitions of the arguments of the oSYSIO opcode
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ***********************************************************************/
+
+#ifndef __PXDEFS_H
+#define __PXDEFS_H
+
+/***********************************************************************/
+/* Codes for system IO calls associated with standard Pascal procedure
+ * and function calls. These must be confined to the range 0x0000
+ * through 0xffff.
+ */
+
+#define xEOF (0x0001)
+#define xEOLN (0x0002)
+#define xRESET (0x0003)
+#define xREWRITE (0x0004)
+
+#define xREADLN (0x0010)
+#define xREAD_PAGE (0x0011)
+#define xREAD_BINARY (0x0012)
+#define xREAD_INT (0x0013)
+#define xREAD_CHAR (0x0014)
+#define xREAD_STRING (0x0015)
+#define xREAD_REAL (0x0016)
+
+#define xWRITELN (0x0020)
+#define xWRITE_PAGE (0x0021)
+#define xWRITE_BINARY (0x0022)
+#define xWRITE_INT (0x0023)
+#define xWRITE_CHAR (0x0024)
+#define xWRITE_STRING (0x0025)
+#define xWRITE_REAL (0x0026)
+
+#define MAX_XOP (0x0027)
+
+/***********************************************************************/
+/* Codes for runtime library interfaces. These must be confined to the
+ * range 0x0000 through 0xffff.
+ */
+
+/* Get an environment string.
+ * function getent(name : string) : cstring;
+ * ON INPUT:
+ * TOS(0)=length of string
+ * TOS(1)=pointer to string
+ * ON RETURN: actual parameters released
+ * TOS(0,1)=32-bit absolute address of string
+ */
+
+#define lbGETENV (0x0000)
+
+/* Copy pascal string to a pascal string
+ * procedure str2str(src : string; var dest : string)
+ * ON INPUT:
+ * TOS(0)=address of dest string
+ * TOS(1)=length of source string
+ * TOS(2)=pointer to source string
+ * ON RETURN: actual parameters released.
+ */
+
+#define lbSTR2STR (0x0001)
+
+/* Copy C string to a pascal string
+ * procedure cstr2str(src : cstring; var dest : string)
+ * ON INPUT:
+ * TOS(0)=address of dest string
+ * TOS(1,2)=32-bit absolute address of C string
+ * ON RETURN: actual parameters released
+ */
+
+#define lbCSTR2STR (0x0002)
+
+/* Copy pascal string to a pascal string reference
+ * procedure str2rstr(src : string; var dest : rstring)
+ * ON INPUT:
+ * TOS(0)=address of dest string reference
+ * TOS(1)=length of source string
+ * TOS(2)=pointer to source string
+ * ON RETURN: actual parameters released.
+ */
+
+#define lbSTR2RSTR (0x0003)
+
+/* Copy C string to a pascal string reference
+ * procedure cstr2str(src : cstring; var dest : string)
+ * ON INPUT:
+ * TOS(0)=address of dest string reference
+ * TOS(0)=MS 16-bits of 32-bit C source string pointer
+ * TOS(1)=LS 16-bits of 32-bit C source string pointer
+ * ON RETURN: actual parameters released
+ */
+
+#define lbCSTR2RSTR (0x0004)
+
+/* Convert a string to a numeric value
+ * procedure val(const s : string; var v; var code : word);
+ *
+ * Description:
+ * val() converts the value represented in the string S to a numerical
+ * value, and stores this value in the variable V, which can be of type
+ * Longint, Real and Byte. If the conversion isn¡Çt succesfull, then the
+ * parameter Code contains the index of the character in S which
+ * prevented the conversion. The string S is allowed to contain spaces
+ * in the beginning.
+ *
+ * The string S can contain a number in decimal, hexadecimal, binary or
+ * octal format, as described in the language reference.
+ *
+ * Errors:
+ * If the conversion doesn¡Çt succeed, the value of Code indicates the
+ * position where the conversion went wrong.
+ *
+ * ON INPUT
+ * TOS(0)=address of Code
+ * TOS(1)=address of v
+ * TOS(2)=length of source string
+ * TOS(3)=pointer to source string
+ * ON RETURN: actual parameters released
+ */
+
+#define lbVAL (0x0005)
+
+/* Create an empty string
+ * function mkstk : string;
+ * ON INPUT
+ * ON RETURN
+ * TOS(0)=length of new string
+ * TOS(1)=pointer to new string
+ */
+
+#define lbMKSTK (0x0006)
+
+/* Replace a string with a duplicate string residing in allocated
+ * string stack.
+ * function mkstkstr(name : string) : string;
+ * ON INPUT
+ * TOS(0)=length of original string
+ * TOS(1)=pointer to original string
+ * ON RETURN
+ * TOS(0)=length of new string
+ * TOS(1)=pointer to new string
+ */
+
+#define lbMKSTKSTR (0x0007)
+
+/* Replace a character with a string residing in allocated string stack.
+ * function mkstkc(c : char) : string;
+ * ON INPUT
+ * TOS(0)=Character value
+ * ON RETURN
+ * TOS(0)=length of new string
+ * TOS(1)=pointer to new string
+ */
+
+#define lbMKSTKC (0x0008)
+
+/* Concatenate a string to the end of a string.
+ * function strcat(name : string, c : char) : string;
+ * ON INPUT
+ * TOS(0)=length of string
+ * TOS(1)=pointer to string
+ * TOS(2)=length of string
+ * TOS(3)=pointer to string
+ * ON OUTPUT
+ * TOS(1)=new length of string
+ * TOS(2)=pointer to string
+ */
+
+#define lbSTRCAT (0x0009)
+
+/* Concatenate a character to the end of a string.
+ * function strcatc(name : string, c : char) : string;
+ * ON INPUT
+ * TOS(0)=character to concatenate
+ * TOS(1)=length of string
+ * TOS(2)=pointer to string
+ * ON OUTPUT
+ * TOS(1)=new length of string
+ * TOS(2)=pointer to string
+ */
+
+#define lbSTRCATC (0x000a)
+
+/* Compare two pascal strings
+ * function strcmp(name1 : string, name2 : string) : integer;
+ * ON INPUT
+ * TOS(1)=length of string2
+ * TOS(2)=address of string2 data
+ * TOS(3)=length of string1
+ * TOS(4)=address of string1 data
+ * ON OUTPUT
+ * TOS(0)=(-1=less than, 0=equal, 1=greater than}
+ */
+
+#define lbSTRCMP (0x000b)
+
+#define MAX_LBOP (0x000c)
+
+#endif /* __PXDEFS_H */