Skip to content
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.

Commit

Permalink
replaced syntax error message with a generic one until parser error m…
Browse files Browse the repository at this point in the history
…essages are improved #39
  • Loading branch information
facundoq committed Aug 8, 2017
1 parent 4714b1b commit f7588e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/scala/vonsim/assembly/i18n/CompilerLanguage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ abstract class CompilerLanguage {
def DWordWordOperands:String
def indirectPointerTypeUndefined:String
def WordDWordOperands:String
def parserError:String

}
1 change: 1 addition & 0 deletions src/main/scala/vonsim/assembly/i18n/English.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ class English extends CompilerLanguage{
def DWordWordOperands="The second operand needs only 8 bits to be encoded, but the first operand has 16 bits, so it is not clear if you want to set the first or last 8 bits."
def indirectPointerTypeUndefined= "Indirect addressing with an immediate operand requires specifying the type of pointer with WORD PTR or BYTE PTR before [BX]."
def WordDWordOperands="The second operand needs 16 bits to be encoded, but the first one only has 8 bits."
def parserError="Syntax error."
}
3 changes: 2 additions & 1 deletion src/main/scala/vonsim/assembly/i18n/Spanish.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Spanish extends CompilerLanguage{
def memoryMemory= "Ambos operandos acceden a la memoria. No se puede acceder a la memoria con dos operandos distintos en una misma instrucción."
def DWordWordOperands="El segundo operando requiere solo 8 bits para representarsepero el primer operando tiene 16 bits. Entonces, no está claro si se debe escribir el resultado sobre los primeros o últimos 8 bits."
def indirectPointerTypeUndefined= "El direccionamiento indirecto ([bx]) con un operando inmediato requiere que se especifique el tipo de puntero con las palabras clave WORD PTR (para operandos inmediatos de 16 bits) o BYTE PTR (para operandos de 8 bits). Por ejemplo, MOV WORD PTR [BX], 15."
def WordDWordOperands="El segundo operando requiere 16 bits para representarse, pero el primero sólo tiene 8 bits"
def WordDWordOperands="El segundo operando requiere 16 bits para representarse, pero el primero sólo tiene 8 bits"
def parserError="Error sintáctico."

}
4 changes: 3 additions & 1 deletion src/main/scala/vonsim/assembly/parser/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ object Parser extends MyParsers {

def apply(tokens: Seq[Token]): Either[ParserError, Instruction] = {
val reader = new TokenReader(tokens)
val defaultMessage=compilerLanguage.parserError // temporary until the parser is improved
program(reader) match {
case NoSuccess(msg, next) => Left(ParserError(Location(next.pos.line, next.pos.column), msg))

case NoSuccess(msg, next) => Left(ParserError(Location(next.pos.line, next.pos.column), defaultMessage))
case Success(result, next) => Right(result)
}
}
Expand Down

0 comments on commit f7588e2

Please sign in to comment.