How to correctly use coercions such that no parenthesis are needed? - bnfc

Why does the following grammar does not recognize nat -> nat but does recognize (nat -> nat) and how can I fix that?
TNat . Typ4 ::= "nat" ;
TVoid . Typ4 ::= "<>" ;
TProd . Typ3 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TArrow . Typ1 ::= Typ1 "->" Typ2;
coercions Typ 4;

Inverting the order of declaration fixed the issue
TArrow . Typ ::= Typ "->" Typ1;
TSum . Typ1 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TNat . Typ3 ::= "nat" ;
TVoid . Typ3 ::= "<>" ;
coercions Typ 3;

Related

Trying to get SNMP Data from a badly documented system

I'm trying to receive snmp data from a badly documented Device. I'll attach a copy of the docs I have.
It would be awesome if you could help me to get a snmpget command.
Best Regards
Niklas
Here are the credentials and the IP Adress:
IP: 192.168.62.219
Security Name: snmpadmin
Auth Protocol: MD5
Auth Password: 12345678
Privacy Protocol: DES
Privacy Password: ezcastdes
AM-SNMP-MIB DEFINITIONS ::= BEGIN
-- Design notes:
--
-- The design of this mib may seem unusual in parts, as it was
-- designed for ease of numerical management routines.
--
-- In that light, most sub-sections of this mib have four common
-- numerical oid consistencies:
--
-- (iana requeted).ID.1 : an integer index value. In scalers, this is always
-- of value 1. In tables it is a row index.
-- (47659).ID.2 : a name of the script, process, etc. that this row represents.
-- (47659).ID.100 : An error flag indicating if an error is present on
-- that row (a threshold value was crossed, etc).
-- (47659).ID.101 : An error string describing why the error flag is non-0.
--
-- These conventions enable managers to easy examine portions of the
-- mib by setting the ID to the sub-section they are interested in
-- monitoring, and then scanning the .100 value to check for an
-- error(s), and get a more specific error message from .101 for the
-- named check found in .2.
--
-- Row numbers between 2 and 100 are sub-section specific.
--
-- Mib sections utilizing the above conventions:
-- Tables: procTable, execTable, diskTable, loadTable
-- Scalers: memory, snmperrs
IMPORTS
OBJECT-TYPE, NOTIFICATION-TYPE, MODULE-IDENTITY,
Integer32, Opaque, enterprises, Counter32, Unsigned32
FROM SNMPv2-SMI
TEXTUAL-CONVENTION, DisplayString, TruthValue
FROM SNMPv2-TC;
actionsmicro MODULE-IDENTITY
LAST-UPDATED "201603310000Z"
ORGANIZATION "Actions MicroEletronics Co. Ltd."
CONTACT-INFO
" http://www.actions-micro.com
postal: Actions MicroEletronics Co. Ltd.
4F.-5, No.736, Jhongjheng Rd., Jhonghe Dist.,
New Taipei City, Taiwan 23511
email: darrelllao#actions-micro.com
"
DESCRIPTION
"This file defines the private AM(ActionsMicro) SNMP MIB extensions."
REVISION "201603310000Z"
DESCRIPTION
"New object for number of CPUs as counted by the agent"
REVISION "201105140000Z"
DESCRIPTION
"New objects for monitoring CPU Steal, Guest and Nice values"
REVISION "200901190000Z"
DESCRIPTION
"New 64-bit objects for monitoring large disk usage"
REVISION "200611220000Z"
DESCRIPTION
"Clarify behaviour of objects in the memory & systemStats groups
(including updated versions of malnamed mem*Text objects).
Define suitable TCs to describe error reporting/fix behaviour."
REVISION "200404070000Z"
DESCRIPTION
"Added ssCpuRawSoftIRQ for Linux (2.6) and forgotten raw swap counters."
REVISION "200209050000Z"
DESCRIPTION
"Deprecate the non-raw objects."
REVISION "200109200000Z"
DESCRIPTION
"Group to monitor log files"
REVISION "200101170000Z"
DESCRIPTION
"Added raw CPU and IO counters."
REVISION "9912090000Z"
DESCRIPTION
"SMIv2 version converted from older MIB definitions."
::= { enterprises 47659 }
-- Current AM core mib table entries:
-- amNetworkMIB OBJECT IDENTIFIER ::= { actionsMicro 1 } - AM-NETWORK-MIB
-- amProjectorMIB OBJECT IDENTIFIER ::= { actionsMicro 2 }
-- Older mib table entries that were changed to new locations above:
-- (TBD) OBJECT IDENTIFIER ::= { actionsMicro 1 }
-- Never implemented and removed from the mib:
-- (TBD) OBJECT IDENTIFIER ::= { actionsMicro 5 }
--
-- Define the Float Textual Convention
-- This definition was written by David Perkins.
--
Float ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"A single precision floating-point number. The semantics
and encoding are identical for type 'single' defined in
IEEE Standard for Binary Floating-Point,
ANSI/IEEE Std 754-1985.
The value is restricted to the BER serialization of
the following ASN.1 type:
FLOATTYPE ::= [120] IMPLICIT FloatType
(note: the value 120 is the sum of '30'h and '48'h)
The BER serialization of the length for values of
this type must use the definite length, short
encoding form.
For example, the BER serialization of value 123
of type FLOATTYPE is '9f780442f60000'h. (The tag
is '9f78'h; the length is '04'h; and the value is
'42f60000'h.) The BER serialization of value
'9f780442f60000'h of data type Opaque is
'44079f780442f60000'h. (The tag is '44'h; the length
is '07'h; and the value is '9f780442f60000'h."
SYNTAX Opaque (SIZE (7))
AMErrorFlag ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents a possible error condition"
SYNTAX INTEGER { noError(0), error(1) }
AMErrorFix ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents a 'push-button' object, to invoke a suitable
configured action. Will always return 0 when read."
SYNTAX INTEGER { noError(0), runFix(1) }
--
-- Process table checks
-- (TBD)
--
-- Memory usage/watch reporting.
-- Not supported on all systems!
-- See agent/mibgroup/ucd_snmp.h to see if its loaded for your architecture.
-- (TBD)
-- SYNTAX OBJECT IDENTIFIER
-- MAX-ACCESS read-only
-- STATUS current
-- DESCRIPTION
-- "The registry slot of a mibmodule."
-- ::= { mrEntry 1 }
-- possibly used in the future:
--
-- ssErrorFlag OBJECT-TYPE
-- SYNTAX AMErrorFlag
-- MAX-ACCESS read-only
-- STATUS current
-- DESCRIPTION
-- "Error flag."
-- ::= { systemStats 100 }
--
-- ssErrMessage OBJECT-TYPE
-- SYNTAX DisplayString
-- MAX-ACCESS read-only
-- STATUS current
-- DESCRIPTION
-- "Error message describing the errorflag condition."
-- ::= { systemStats 101 }
END
AM-SETUP-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32 FROM SNMPv2-SMI
actionsmicro FROM AM-SNMP-MIB;
amSetUp MODULE-IDENTITY
LAST-UPDATED "201607080000Z"
ORGANIZATION "Actions MicroEletronics Co. Ltd."
CONTACT-INFO
" http://www.actions-micro.com
postal: Actions MicroEletronics Co. Ltd.
4F.-5, No.736, Jhongjheng Rd., Jhonghe Dist.,
New Taipei City, Taiwan 23511
email: darrelllao#actions-micro.com
"
DESCRIPTION
"The AM-SNMP setup MIB."
REVISION "201603310000Z"
DESCRIPTION
"SMIv2 version converted from older MIB definitions."
::= { actionsmicro 1 }
amAirSetup OBJECT IDENTIFIER ::= { amSetUp 1 }
amDeviceManagemant OBJECT IDENTIFIER ::= { amSetUp 2 }
amAccessControl OBJECT IDENTIFIER ::= { amSetUp 3 }
amNetworkSetup OBJECT IDENTIFIER ::= { amSetUp 4 }
amAdvancedSetup OBJECT IDENTIFIER ::= { amSetUp 5 }
amSystemInfo OBJECT IDENTIFIER ::= { amSetUp 6 }
amWifiWlan0 OBJECT IDENTIFIER ::= { amSystemInfo 1 }
amWifiWlan1 OBJECT IDENTIFIER ::= { amSystemInfo 2 }
amWifiWlan2 OBJECT IDENTIFIER ::= { amSystemInfo 3 }
amWifiWlan3 OBJECT IDENTIFIER ::= { amSystemInfo 4 }
amMibLan OBJECT IDENTIFIER ::= { amSystemInfo 5 }
amMibVersion OBJECT IDENTIFIER ::= { amSystemInfo 6}
amMibCurstatus OBJECT IDENTIFIER ::= { amSystemInfo 7}
AddNetwork OBJECT IDENTIFIER ::= { amNetworkSetup 5}
--
-- AirSetup
--
SoftApPassWord OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(8..64))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"WiFi 2.4G and 5G use the same PSK password."
::= { amAirSetup 1 }
SoftApHideSSID OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(8..64))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"0:ssid is open,you can see it ;1:ssid is hidden"
::= { amAirSetup 2 }
EZAir OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(8..64))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"0:Mirror+Streaming;1:Mirror Only."
::= { amAirSetup 3 }
--
-- DeviceManagemant
--
Language OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..2))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"0:en; 1:fr; 2:de; 3:es; 4:zh-CN; 5:zh-TW; 6:ja; 7:ko; 8:it;
9:ru; 10:nl; 11:pt; 12:tr; 13:ar; 14:tha; 15:fa; 16:auto"
::= { amDeviceManagemant 1 }
ChangeSSID OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(8..15))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"The SSID length should be 1~20 characters."
::= { amDeviceManagemant 2 }
Resolution OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Get/set resolution;
HDMI_TAB id:
0:1280x720_50P; 1:1280x720_60P; 2:1920x1080_24P; 3:1920x1080_50P;
4:1920x1080_60P; 5:3840x2160_24P; 6:3840x2160_25P; 7:3840x2160_30P;
8:4096x2160_24P"
::= { amDeviceManagemant 3}
EDIDTable OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1024))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"the system resolution of EDID Table."
::= { amDeviceManagemant 4 }
MaxConNum OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..3))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Maximum number of connections in the system.
0: 4 users; 1: 8 users; 2: 16 users; 3: 32 users; 4: 64 users;"
::= { amDeviceManagemant 5 }
--
-- AccessControl
--
CastCodeControl OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..8))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"CastCodeControl 0:OFF;1:Random;2:Fixed,only 4 bit digits are allowed.
set example:(1)0; (2)1; (3)2;6688;"
::= { amAccessControl 1 }
InternetAccessControl OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..8))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"InternetAccessControl 0:All allowed; 1:Casting users allowed; 2:All
denied."
::= { amAccessControl 2 }
PassowrdHidden OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Get/Set the password status, 0:off 1:on."
::= {amAccessControl 3}
AirView OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Get/Set the airview, 0:off 1:on.frame_rate:{5000,15000,30000,60000,0},
example:1;5000;"
::= {amAccessControl 4}
--
-- NetworkSetup
--
RouterOrDirectOnly OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"0:Via Router Allowed; 1:Direct Link Only; 2:Via Router Only"
::= { amNetworkSetup 1 }
SoftApChannel OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..128))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"5G WiFiChannel.Warning!!,Configure without connect router.Channel Auto, input Auto.BandWidth:20/80.SetExample:5G;America;2;Auto;80;
channel5g_regiontbl[]={
1,South Africa,{36,40,44,48};
1,Israel,{36,40,44,48};
1,Turkey,{36,40,44,48};
1,Egypt,{36,40,44,48};
1,Tunisia,{36,40,44,48};
1,Kuwait,{36,40,44,48};
1,United Arab Emirates,{36,40,44,48};
2,Russia,{36,40,44,48,149,153,157,161};
2,Singapore,{36,40,44,48,149,153,157,161};
1,South America,{36,40,44,48};
1,Saudi Arabia,{36,40,44,48};
2,America,{36,40,44,48,149,153,157,161};
2,Australia,{36,40,44,48,149,153,157,161};
2,Canada,{36,40,44,48,149,153,157,161};
2,India,{36,40,44,48,149,153,157,161};
2,Korea,{36,40,44,48,149,153,157,161};
2,Malaysia,{36,40,44,48,149,153,157,161};
2,Mexico,{36,40,44,48,149,153,157,161};
2,China,{36,40,44,48,149,153,157,161};
3,Iran,{149,153,157,161};
3,Labanon,{149,153,157,161};
3,Qatar,{149,153,157,161};
2,Europe,{36,40,44,48,149,153,157,161};
1,Japan,{36,40,44,48};
2,Taiwan,{36,40,44,48,149,153,157,161};
}"
::= { amNetworkSetup 2 }
WiFiManual OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..128))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"set wifi IP;Gateway;Netmask;DNS; setexample:192.168.48.68;192.168.48.1;255.255.255.0;192.168.48.1;"
::= { amNetworkSetup 3 }
LanSet OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..128))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"set lan IP;Gateway;Netmask;DNS; setexample:192.168.48.68;192.168.48.1;255.255.255.0;192.168.48.1;"
::= { amNetworkSetup 4 }
--
-- AddNetwork
--
AddNetworkApply OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..1))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"add network parameters format:ssid;authen;psk;
set example:action;WPA-PSK;12345678;"
::= { AddNetwork 1 }
ScanNetwork OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..1))
MAX-ACCESS write-only
STATUS current
DESCRIPTION
"Do not need to enter any value ,just press SET key and it will scan
network."
::= { AddNetwork 2 }
ScanresultNetwork OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..8192))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"get the scan network results.
format:SSID;Authen;unknown;networkid;macaddr;"
::= { AddNetwork 3 }
ConnectNetwork OBJECT-TYPE
SYNTAX OCTET STRING(SIZE(0..128))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"set connect network ssid;authen;psk;mac;networkid;
set example:action;WPA-PSK;12345678;84:1b:5e:d7:3a:83;-1;"
::= { AddNetwork 4 }
--
-- AdvancedSetup
--
OTAURL OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..128))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"OTA Server,such as http://www.iezvu.com"
::= { amAdvancedSetup 1 }
AdminPassword OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(6..64))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"admin password,Password must be between 6 and 64 characters long.It is
md5 encrypted password when you GET it"
::= { amAdvancedSetup 2 }
--
-- SystemInfo
--
Wlan0MacAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC of wlan0."
::= { amWifiWlan0 1 }
Wlan0IPAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP of wlan0."
::= { amWifiWlan0 2 }
Wlan0LinkStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The link status of WLAN0 interface."
::= { amWifiWlan0 3 }
Wlan1MacAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC of wlan1."
::= { amWifiWlan1 1 }
Wlan1IPAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP of wlan1."
::= { amWifiWlan1 2 }
Wlan1LinkStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The link status of WLAN1 interface."
::= { amWifiWlan1 3 }
Wlan2MacAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC of wlan2."
::= { amWifiWlan2 1 }
Wlan2IPAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP of wlan2."
::= { amWifiWlan2 2 }
Wlan2LinkStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The link status of WLAN2 interface."
::= { amWifiWlan2 3 }
Wlan3MacAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC of wlan3."
::= { amWifiWlan3 1 }
Wlan3IPAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP of wlan3."
::= { amWifiWlan3 2 }
Wlan3LinkStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The link status of WLAN3 interface."
::= { amWifiWlan3 3 }
LanMacAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC of LAN."
::= { amMibLan 1 }
LanIPAddress OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP of LAN."
::= { amMibLan 2 }
LanLinkStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The link status of LAN interface."
::= { amMibLan 3 }
FWLocalVersion OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Local Software Version."
::= { amMibVersion 1 }
FWOTAServerVersion OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"OTA Server Version."
::= { amMibVersion 2 }
LoginUserNum OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Current Login user num."
::= { amMibCurstatus 1 }
InternetStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Current Internet status."
::= { amMibCurstatus 2 }
END

Convert my .g4 to .flex and .bnf for IDEA syntax highlighter

I have never used JFlex before, and I have no idea how it works. Basically, I've built a runtime for a scheme-esque language in Java, and the parser I have for it was generated using Antlr 4, so I have a .g4 file, which looks like this:
program: expression EOF;
expression: lambdaAbstraction | application| literal;
lambdaAbstraction: LP WS? LAMBDA (WS IDENTIFIER)* WS expression WS? RP;
application: LP WS? expression (WS expression)* WS? RP;
literal: FLOAT_LITERAL | INTEGER_LITERAL | IDENTIFIER | STRING_LITERAL;
STRING_LITERAL: '"' ~["]* '"' | '\'' ~[']* '\'' ;
FLOAT_LITERAL: [0-9]+ '.' [0-9]+;
INTEGER_LITERAL: [0-9]+;
IDENTIFIER: [a-zA-Z+/*-=?#]+;
LAMBDA: '\\';
LP: '(';
RP: ')';
WS: [ \n\r\t]+;
Some examples (so you can get a feel for the grammar).
(+ 1 2) = 3
((\ a b (+ a b)) 1 2) = 3
(+ "Hello, " "World") = "Hello, World"
What I'm trying to do is build a syntax-highlighter plugin for IntelliJ-IDEA for this language using this guide: http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support_tutorial.html.
Here is my .flex file
package com.michaelsnowden.yalcil_plugin;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
import com.michaelsnowden.yalcil_plugin.psi.YalcilTypes;
import com.intellij.psi.TokenType;
%%
%class YalcilLexer
%implements FlexLexer
%unicode
%function advance
%type IElementType
%eof{ return;
%eof}
STRING_LITERAL= "\"" [^\"&]* "\"";
FLOAT_LITERAL=[0-9]+ '.' [0-9]+;
INTEGER_LITERAL=[0-9]+;
IDENTIFIER=[a-zA-Z+/*-=?#]+;
LAMBDA="\\";
LP="(";
RP=")";
WS=[ \n\r\t]+;
%%
<YYINITIAL> {
{LAMBDA} { yybegin(YYINITIAL); return YalcilTypes.LAMBDA; }
{FLOAT_LITERAL} { yybegin(YYINITIAL); return YalcilTypes.LAMBDA; }
{INTEGER_LITERAL} { yybegin(YYINITIAL); return YalcilTypes.INTEGER_LITERAL; }
{IDENTIFIER} { yybegin(YYINITIAL); return YalcilTypes.IDENTIFIER; }
{LP} { yybegin(YYINITIAL); return YalcilTypes.LP; }
{RP} { yybegin(YYINITIAL); return YalcilTypes.RP; }
{WS} { yybegin(YYINITIAL); return YalcilTypes.WS; }
{STRING_LITERAL} { yybegin(YYINITIAL); return YalcilTypes.STRING_LITERAL; }
}
. { return TokenType.BAD_CHARACTER; }
And here is my .bnf file
{
parserClass="com.michaelsnowden.yalcil_plugin.YalcilParser"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="Yalcil"
psiImplClassSuffix="Impl"
psiPackage="com.michaelsnowden.yalcil_plugin.psi"
psiImplPackage="com.michaelsnowden.yalcil_plugin.psi.impl"
elementTypeHolderClass="com.michaelsnowden.yalcil_plugin.psi.YalcilTypes"
elementTypeClass="com.michaelsnowden.yalcil_plugin.psi.YalcilElementType"
tokenTypeClass="com.michaelsnowden.yalcil_plugin.psi.YalcilTokenType"
}
program ::= expression;
expression ::= lambdaAbstraction | application| literal;
lambdaAbstraction ::= LP WS? LAMBDA (WS IDENTIFIER)* WS expression WS? RP;
application ::= LP WS? expression (WS expression)* WS? RP;
literal ::= FLOAT_LITERAL | INTEGER_LITERAL | IDENTIFIER | STRING_LITERAL;
I get basically nothing but errors when I run this.
For some reason, only strings are highlighted.
The PsiViewer looks like this:
Does anyone see any explanation for why this isn't working?

SNMP MIB ERROR scalar's parent node must be simple node Object Not Imported

I have the following file and I get
X-MIB.txt:26: scalar's parent node must be simple node Object Not
Imported
X-MIB.txt:35: scalar's parent node must be simple node Object Not
Imported
X-MIB.txt:45: scalar's parent node must be simple node Object Not
Imported
X-MIB.txt:55: scalar's parent node must be simple node Object Not
Imported
Here's the MIB file (after emitting my company name and replacing names with "x" and "y")
X-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE, Integer32 FROM SNMPv2-SMI
DisplayString FROM RFC1213-MIB
OBJECT-GROUP, NOTIFICATION-GROUP FROM SNMPv2-CONF
y FROM Y-MIB;
x MODULE-IDENTITY
LAST-UPDATED "201411060000Z"
ORGANIZATION "Y Corporation"
CONTACT-INFO
"Y Corporation
www.y.com"
DESCRIPTION
"The Structure of Management Information for the Y X enterprise."
REVISION "201411060000Z"
DESCRIPTION
"Initial version of this MIB."
::= { y 101 }
-- 1.3.6.1.4.1.1139.101.1
xAlert OBJECT IDENTIFIER ::= { x 1 }
-- 1.3.6.1.4.1.1139.101.1.1
xAlertSeverity OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Severity of the event"
::= { xAlert 1 }
-- 1.3.6.1.4.1.1139.101.1.2
xAlertType OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Type of the alert"
::= { xAlert 2 }
-- 1.3.6.1.4.1.1139.101.1.3
xAlertSourceObjectId OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Object id for which the alert was created"
::= { xAlert 3 }
-- 1.3.6.1.4.1.1139.101.1.4
xAlertActionCode OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Action code of the alert"
::= { scaleioAlert 4 }
-- 1.3.6.1.4.1.1139.101.1.5
xGroups OBJECT IDENTIFIER ::= { xAlert 5 }
-- 1.3.6.1.4.1.1139.101.1.5.1
currentObjectGroup OBJECT-GROUP
OBJECTS { xAlertSeverity,
xAlertType,
xAlertSourceObjectId,
xAlertActionCode }
STATUS current
DESCRIPTION
"x-MIB-V2 OBJECT-GROUP."
::= { xGroups 1 }
-- 1.3.6.1.4.1.1139.101.1.5.2
currentNotificationGroup NOTIFICATION-GROUP
NOTIFICATIONS { xAEAlert }
STATUS current
DESCRIPTION
"x-MIB-V2 NOTIFICATION-GROUP."
::= { xGroups 2 }
xAEAlert NOTIFICATION-TYPE
OBJECTS { xAlertSeverity, xAlertType, xAlertSourceObjectId, xAlertActionCode }
STATUS current
DESCRIPTION "x Alert"
::= { x 1 }
END
Don't import DisplayString from RFC1213-MIB. You are mixing SMIv1 and SMIv2. Import DisplayString from SNMPv2-TC instead.
Try adding an intermediate OBJECT IDENTIFIER between you module identity and xAlert. I was able to get the warning for scalar's parent node must be simple node to go away by doing this.
xMibObjects OBJECT IDENTIFIER ::= { x 1 }
xAlert OBJECT IDENTIFIER ::= { xMibObjects 1 }
I don't have the text for your Y-MIB, so I couldn't complete the imports.

wrong expression type on ocamlyacc

As part of a school project I have to recognize a .dot file and produce the corresponding parse tree. To accomplish this, I have to use ocamllex and ocamlyacc which whom I've difficulties...
This is my ocaml .mli types file :
type id = string
and node = id
and attr = id * id
and attr_list = attr list list
and attr_stmt =
Graphs of (attr_list)
| Nodes of (attr_list)
| Edge of (attr_list)
and node_stmt = node * attr_list
and node_subgraph =
Node of (node)
| Subgraphs of (graph)
and edge_stmt = node_subgraph * (node_subgraph list) * attr_list
and stmt =
Node_stmt of (node_stmt)
| Edge_stmt of (edge_stmt)
| Attr_stmt of (attr_stmt)
| Attr of (attr)
| Subgraph of graph
and graph =
Graph_node of (node * stmt list)
| Graph of (stmt list);;
this is my lexer file :
{
open Parser
}
rule token = parse
(* Espacements *)
| [ ' ' '\t' '\n']+ {token lexbuf}
(* *)
| "graph" {GRAPH}
| "subgraph" {SUBGRAPH}
| "--" {EDGE}
(* Délimiteurs *)
| "{" {LEFT_ACC}
| "}" {RIGHT_ACC}
| "(" {LEFT_PAR}
| ")" {RIGHT_PAR}
| "[" {LEFT_BRA}
| "]" {RIGHT_BRA}
| "," {COMMA}
| ";" {SEMICOLON}
| "=" {EQUAL}
| ":" {TWOPOINT}
| ['a'-'z''A'-'Z''0'-'9']* as id {ID (id)}
| eof { raise End_of_file }
and this is my not finished yacc file :
%{
open Types
%}
%token <string> ID
%token <string> STR
%token GRAPH SUBGRAPH EDGE
%token LEFT_ACC RIGHT_ACC LEFT_PAR RIGHT_PAR LEFT_BRA RIGHT_BRA
%token COMME SEMICOLON EQUAL TWOPOINT EOF
%start main
%type <graph> main
%%
main:
graph EOF { $1 }
graph:
GRAPH ID LEFT_ACC content RIGHT_ACC {$4}
| GRAPH LEFT_ACC content RIGHT_ACC {$3}
subgraph:
SUBGRAPH ID LEFT_ACC content RIGHT_ACC {$4}
| SUBGRAPH LEFT_ACC content RIGHT_ACC {$3}
content:
| ID EDGE ID SEMICOLON {[($1,$3)]}
It seems enough for recognizing a simple dot file like
graph D {
A -- B ;
}
But when I try to compile my parser interface I get this error :
This expression has type 'a list
but an expression was expected of type Types.graph (refers to ID EDGE ID SEMICOLON {[$1,$3)]} line )
I don't understand because {[$1,$3]} has a (string * string) list type. And if we are looking to types.mli that can be a graph.
Otherwise, have I correctly understand the running of ocamllex and ocamlyacc ?
A value of type graph has to start with either Graph or Graph_node. This is not at all the same as (string * string) list.

OCaml: new_line equivalent before 3.11

I'm trying to compile Libra toolkit on a machine running Ubuntu Hardy with OCaml 3.10, I can't upgrade the OS nor update OCaml, and I don't know anything about OCaml. There is only one line that gives me an unbound value error because it uses the new_line function, which was introduced in OCaml 3.11 (http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lexing.html), could someone tell me how to change it to be compatible with OCaml 3.10? It's the line near the end of this code:
{
open MnParseTypes;;
open MnParser;;
(* Raised when parsing ends *)
exception Eof;;
module L = Lexing
let linenum lexbuf = lexbuf.L.lex_curr_p.L.pos_lnum
let line = ref 1;;
let keywords = Hashtbl.create 10
let _ =
List.iter2 (Hashtbl.add keywords)
["mn"; "features"; "tree"; "table"; "w"; "eof"]
[Tmn; Tfeatures; Ttree; Ttable; Tweight; EOF];;
}
let digits = ['0'-'9']+
let identifier = ['a'-'z' 'A'-'Z']+
rule lexer = parse
(* eat blank characters *)
[' ' '\t'] {lexer lexbuf}
(* | "Feature list:" {lexer lexbuf} *)
| '{' {Tlbrace}
| '}' {Trbrace}
| '(' {Tlparen}
| ')' {Trparen}
| ('-')? "inf" {Tfloat( float_of_string(L.lexeme lexbuf))}
| identifier {
let x = String.lowercase (Lexing.lexeme lexbuf) in
try Hashtbl.find keywords x
with Not_found ->
failwith((Lexing.lexeme lexbuf)
^ ": unknown identifier on line " ^ string_of_int (linenum lexbuf))}
| digits {Tint (int_of_string (L.lexeme lexbuf))}
| ('-')? digits ('.' digits)? (['e' 'E'] ['+' '-']? digits)?
{Tfloat( float_of_string(L.lexeme lexbuf))}
| '+' 'v' (digits as var) '_' (digits as value)
{Tcond(true, int_of_string var, int_of_string value)}
| '-' 'v' (digits as var) '_' (digits as value)
{Tcond(false, int_of_string var, int_of_string value)}
| 'v' (digits as var) '_' (digits as value)
{Tvar( int_of_string var, int_of_string value)}
| ['\n' '\r']+ {L.new_line lexbuf; TEOL} (* THIS GIVES THE ERROR *)
| eof {EOF}
| _ {failwith((L.lexeme lexbuf) ^
": mistake on line " ^ string_of_int lexbuf.L.lex_curr_p.L.pos_lnum)}
In the directory of the OCaml sources (from SVN or a relase tarball), the source of the module Foo of the standard library will be in stdlib/foo.{ml,mli} (.mli is the interface file, .ml the implementation file). Looking at stdlib/lexing.ml gives you:
let new_line lexbuf =
let lcp = lexbuf.lex_curr_p in
lexbuf.lex_curr_p <- { lcp with
pos_lnum = lcp.pos_lnum + 1;
pos_bol = lcp.pos_cnum;
}
You can implement this in your code as well, using open Lexing to have the field names in scope, or using lexbuf.Lexing.lex_curr_p, and { lcp with Lexing.pos_lnum = lcp.Lexing.pos_lnum ... instead.
Edit: as you probably don't plan to hack the OCaml code yourself, let's give you the full thing:
let new_line lexbuf =
let lcp = lexbuf.Lexing.lex_curr_p in
lexbuf.Lexing.lex_curr_p <- { lcp with
Lexing.pos_lnum = lcp.Lexing.pos_lnum + 1;
Lexing.pos_bol = lcp.Lexing.pos_cnum;
}
add this at the top of the file that uses new_line (if it says Lexing.new_line, turn it into new_line), and you should be fine.
You can implement new_line yourself but I think upgrading OCaml would be better. I know that you said you can't upgrade the OS but installing the newer version of Ocaml can be done in your home directory without the need of any superuser privilege. OPAM is a packet manager for OCaml that makes it very easy to install the latest version of OCaml.

Resources